Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6596189pxv; Thu, 29 Jul 2021 19:47:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr9to9f5XTq7eWkIvvyI35Ip2ID+T+Z3RwZQEe5aCsvBt4hLNIYwlSxbG2he1Le78rl5O+ X-Received: by 2002:a92:6503:: with SMTP id z3mr245628ilb.258.1627613243648; Thu, 29 Jul 2021 19:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627613243; cv=none; d=google.com; s=arc-20160816; b=TPgGvLEzZVnSnAmJClTVobFjivs2zNKkUGp3FX6yB03uZFouKeuwG5wbqLRMq1Extc MtHmnGKA4t2ZSnzb9lwW/k8/xK9pN2MMatxobJkn7eKwYmBQm7kLqkXIdexBSlmqNpPT 93cdNdOixbyY+DDKwOnBxifMNYiUHwUlhb6fTPmtuvZ3VJgmlUPE1rQ8iaZOoUVZL1+L I/ydTxnyCwv1hQdgSKjRnVI75f84BoARkliWIR5CgWAJknCIhIhxRDP1Nuh/vuqOKvgO 7/MzuQNI197d0ZH/WkY7cO8IDZ8c9anYrZT4a8Yh3O7YQ3EpTNh6TKP0OwjD8N3fDwTy 7rww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=O3zNfyVQoe5bVhMYQ0wEPTbj5P6soBVDBHqx9Zun+ro=; b=Uw5/KSSl5kuwiVmpsQeO8rXkH7+I8ZgQCVntt9JH01BmePoXL2UgEzTMQ38L5LBIcu vmqg/Uz/2gUTNdf5+R9wIRX8MMNPEpZAW9AgJp688GTJTMV8JiqFvaIlhQjbmvHBPVsT nxsUBzh3Dc6bKc9sHkTfSUO5rHnePN/6ws42+BZW89M9JMLmRQMR6HvyNq1Z9oRabobp TUeivzcp+7ITzOg6w8RaJtqGxFJLsS4cCW3wplHAQcbfgjemClZ951o8PqWqC6OW5uwq CF+l3I4okbvq5OKPw4TY75KLE3oW9ZkgzKF7BFYYALfDEJ7LxjMBl+YPeW6Qo73Iipjb EjDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si82612jal.126.2021.07.29.19.47.11; Thu, 29 Jul 2021 19:47:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235692AbhG3Cqc (ORCPT + 99 others); Thu, 29 Jul 2021 22:46:32 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:12332 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbhG3Cqb (ORCPT ); Thu, 29 Jul 2021 22:46:31 -0400 Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GbWr36KL3z80M9; Fri, 30 Jul 2021 10:41:39 +0800 (CST) Received: from [10.174.178.209] (10.174.178.209) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 30 Jul 2021 10:46:24 +0800 Subject: Re: [External] Re: [PATCH 5/5] mm, memcg: always call __mod_node_page_state() with preempt disabled To: Muchun Song CC: Shakeel Butt , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Roman Gushchin , Matthew Wilcox , Alex Shi , Wei Yang , Linux MM , LKML , Cgroups References: <20210729125755.16871-1-linmiaohe@huawei.com> <20210729125755.16871-6-linmiaohe@huawei.com> <29c4bb2a-ceaf-6c8b-c222-38b30460780f@huawei.com> From: Miaohe Lin Message-ID: <0077ebd3-abef-5763-8f50-7a937734c54b@huawei.com> Date: Fri, 30 Jul 2021 10:46:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.209] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/7/30 10:33, Muchun Song wrote: > On Fri, Jul 30, 2021 at 9:52 AM Miaohe Lin wrote: >> >> On 2021/7/29 22:39, Shakeel Butt wrote: >>> On Thu, Jul 29, 2021 at 5:58 AM Miaohe Lin wrote: >>>> >>>> We should always ensure __mod_node_page_state() is called with preempt >>>> disabled or percpu ops may manipulate the wrong cpu when preempt happened. >>>> >>>> Fixes: b4e0b68fbd9d ("mm: memcontrol: use obj_cgroup APIs to charge kmem pages") >>>> Signed-off-by: Miaohe Lin >>>> --- >>>> mm/memcontrol.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >>>> index 70a32174e7c4..616d1a72ece3 100644 >>>> --- a/mm/memcontrol.c >>>> +++ b/mm/memcontrol.c >>>> @@ -697,8 +697,8 @@ void __mod_lruvec_page_state(struct page *page, enum node_stat_item idx, >>>> memcg = page_memcg(head); >>>> /* Untracked pages have no memcg, no lruvec. Update only the node */ >>>> if (!memcg) { >>>> - rcu_read_unlock(); >>>> __mod_node_page_state(pgdat, idx, val); >>>> + rcu_read_unlock(); >>> >>> This rcu is for page_memcg. The preemption and interrupts are disabled >>> across __mod_lruvec_page_state(). >>> >> >> I thought it's used to protect __mod_node_page_state(). Looks somewhat confusing for me. >> Many thanks for pointing this out! > > Hi Miaohe, > > git show b4e0b68fbd9d can help you find out why we add > the rcu read lock around it. Thanks for your tip. That's my overlook when I checked this commit. I should have looked at this more closely. :( > > Thanks. > >> >>>> return; >>>> } >>>> >>>> -- >>>> 2.23.0 >>>> >>> . >>> >> > . >