From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F274DF59 for ; Sun, 22 Dec 2024 13:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734874399; cv=none; b=rYqAZW5MUWlpj88lli+YNxgYZqoRq2L24qHZbykNzj2azo07ssSuj1ns9PvdCc2wuKXOPpYcPK/vFB2G3GQgRHVeRC2eTzvYWLefsVMcUu7VqcWdMA8PRW7LtgKIrShlPUwJNoJyU+fMXDg5e+/mBZLtZbJ+crAprlnJj1ZyEDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734874399; c=relaxed/simple; bh=A4GXlg84Fv8u8x6tri0jVo44QPJuetEEqf9lt2BVAM0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=MzAP313PSbjkvcXKAy49JTOx3jX0Ijs0C9s8+UFGtUCdVpVTz6MtB9wnZtzjHwTvol3n3lZmv8QzYeRwDN8iWU4yXuXEV4p05fZOqRMLzRGU0nb4h5OzzfHkAZmCGKQ26Rn8ZilvDmw3kg5R2YBr0XLIb/WSfHKDnsbhbKgixJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=cFHKLgv5; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="cFHKLgv5" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1734874388; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=s1ugvjlIbNshvGS9ZZbP8CjQoqKgu4xuN4hxoL5UeBw=; b=cFHKLgv5H3MMHF9LmvYRF5bXEdxiOTkYAr0aknI3BHW4VQyl0CNesUW3pmBkVNrRyWad7via6JEiwZdTWY8SkpfexbqSG6SGxwL6ldMIlDMYLpYBizC55vWLpZRPoFAxIAZpxyCDDSvJm+wdW991m3ngYU4r10x11Bt+kIccMcE= Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0WLysJwu_1734874386 cluster:ay36) by smtp.aliyun-inc.com; Sun, 22 Dec 2024 21:33:07 +0800 From: "Huang, Ying" To: Kairui Song Cc: linux-mm@kvack.org, Kairui Song , Andrew Morton , Chris Li , Hugh Dickins , Yosry Ahmed , Roman Gushchin , Shakeel Butt , Johannes Weiner , Barry Song , Michal Hocko , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/4] mm, memcontrol: avoid duplicated memcg enable check In-Reply-To: <20241218114633.85196-2-ryncsn@gmail.com> (Kairui Song's message of "Wed, 18 Dec 2024 19:46:30 +0800") References: <20241218114633.85196-1-ryncsn@gmail.com> <20241218114633.85196-2-ryncsn@gmail.com> Date: Sun, 22 Dec 2024 21:33:06 +0800 Message-ID: <87ed1zj10t.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Hi, Kairui, Sorry for jumping in so late. Kairui Song writes: > From: Kairui Song > > mem_cgroup_uncharge_swap() includes a mem_cgroup_disabled() check, > so the caller doesn't need to check that. > > Signed-off-by: Kairui Song > Reviewed-by: Yosry Ahmed > Reviewed-by: Roman Gushchin > Acked-by: Shakeel Butt > Acked-by: Chris Li > --- > mm/memcontrol.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 7b3503d12aaf..79900a486ed1 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -4609,7 +4609,7 @@ void mem_cgroup_swapin_uncharge_swap(swp_entry_t entry, unsigned int nr_pages) > * correspond 1:1 to page and swap slot lifetimes: we charge the > * page to memory here, and uncharge swap when the slot is freed. > */ > - if (!mem_cgroup_disabled() && do_memsw_account()) { > + if (do_memsw_account()) { > /* > * The swap entry might not get freed for a long time, > * let's not wait for it. The page already received a I take a look at memcontrol.c, it appears that almost all extern functions check mem_cgroup_disabled() as the first step. So I guess that this is a convention of memcontrol.c? And the benefit of the change is minimal. In contrast, if someone makes more changes to mem_cgroup_swapin_uncharge_swap() in the future, he may forget to add this back. So, it may be unnecessary to make the change? --- Best Regards, Huang, Ying