From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B8D2E7718E for ; Fri, 27 Dec 2024 02:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1C976B007B; Thu, 26 Dec 2024 21:03:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC8A6B0082; Thu, 26 Dec 2024 21:03:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B93B36B0083; Thu, 26 Dec 2024 21:03:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9AE306B007B for ; Thu, 26 Dec 2024 21:03:57 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 45AA816121F for ; Fri, 27 Dec 2024 02:03:57 +0000 (UTC) X-FDA: 82939092894.14.B4E03F9 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by imf13.hostedemail.com (Postfix) with ESMTP id 4387920006 for ; Fri, 27 Dec 2024 02:03:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=bKf+qzj7; spf=pass (imf13.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735264986; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o7eiyI8du7vlvyw9sk7wyWLJDvC8p8O7KuzjSF30GjU=; b=ghFoNwLcF8U3D5cApqmxpSdwZ0PGRB3wWW/9GDbcGtYIfOR/KpXST9uZ8FsfJqwJaFCKfH Ugt9wfW/WwsrPgNFdx9QBayvtKWTiVTqpWRJntMsFUi8MzkUDbQ2r2i8L0deARgxMApcS9 tItXKoZfKZm5Dif/Qo3XKIHOLd/fKPE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735264986; a=rsa-sha256; cv=none; b=A5AR6xQL0EsAdRECC9/99EEMcLQmNJvv489VFyY/+etAybhQ73Hx1ZhgY0NPrXMtH5sNRF ldkPBIEYrNeHIUzN0BTm9hArc6M/BycXbMdLjdUhy7Zpwkazex6cClF+UVphs+m3ETFfeh XvNYjLwia9vzK81BboQhfl/rAFPHMCg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=bKf+qzj7; spf=pass (imf13.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1735265031; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=o7eiyI8du7vlvyw9sk7wyWLJDvC8p8O7KuzjSF30GjU=; b=bKf+qzj7OK8r20Wh4NcMSYn5SdzE+WuZu4rZZVuXbtCLpldZSHPUMEPM5haX5NKs39/Xm6WAiBdnv0Tc2KfI2uIVyI4ovMAiqoJbLHzURn002/tbPHkBufmjfbY1HsTMukAEBCQYqoPM8ugMM5xyLZCZD4MHi1JTDYyc2pvnHVE= Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0WMJXw0r_1735265029 cluster:ay36) by smtp.aliyun-inc.com; Fri, 27 Dec 2024 10:03:50 +0800 From: "Huang, Ying" To: Kairui Song Cc: linux-mm@kvack.org, 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: (Kairui Song's message of "Sun, 22 Dec 2024 22:51:56 +0800") References: <20241218114633.85196-1-ryncsn@gmail.com> <20241218114633.85196-2-ryncsn@gmail.com> <87ed1zj10t.fsf@DESKTOP-5N7EMDA> Date: Fri, 27 Dec 2024 10:03:49 +0800 Message-ID: <875xn5hofu.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4387920006 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: ib5gmyi866efq9858wzmipb5wtjfzsp1 X-HE-Tag: 1735264993-638336 X-HE-Meta: U2FsdGVkX1+18E12vkxBVysZ6h+8t5J8GYTyixTie3tdvOmZt1Dya0NCVDyGWOrHlhLwB2Unv2lPoZvDJRZjyOXyiHI8xfJzCRq8Dmzz9Kp64Iv6LJ3aMFr4TV1r4x2Cxz2qsDs/3Frk5pIIX0JlFMWWoJ50Nar/YxEpa4SpsnvdMcdW0XcujbkviTUeBrKRlFHydE6udUhc4Mgm2Kmta/e9FX8hIvIbwyXboK/RWwR2viVSXo+ghDTrQtqzM3jEWhz8cgG2DBJaciwpCKqhBteI9VVZr2wTrwqa7T3MpDlp7QMlGxVNWfBJ3aahBgTuB9S2KMs7HPkW+CAKWUpQzdcrdDe9gXSeCHKAu89SJVo4DeBlgldJICPE5AsDrPgWimQ0jgbTBpHy/yYIiC9xv0p8hv2mjtkYKInYmFgrv1/HoIU7gNY4+UPhQrI+OgW8uW7aqmqYzuMixd6GC+j54rP3imQIto8VvObdboxLJ6zDoD0eM8KdKUayqGjjxcXb346rsE583qBp4sw+XBMbVhKuvslMXTmjO5XlFkljnoX7kwXB3L8yC0Y2CA4aNyzJz/l2Ezhe9wDcZ1qzxOu8eKJWdE13WEUwzxuQdfTQ8jc8OY1zIDkg7Gs1zm/+FIHNQcPdf7YK9h/0+bQPQZanHU9hgHVCkW9S6Jr/keJmeBi7sum4Fwwio7N6bdP925fodt2c2kl/FcofVjzDrM4gg0tkdvuujRYfnXotJF/5jq1exVhRbEkPEu/RdSlFq+ey2HyStGRRomx2UHoFoJBqACg58Fx75OdC2ege01/md/AEhQtsIjCtV5CPBBxnzlfXa6LKAuIdYmUtl8WlqGXz3sAcM83oeRpCum9KP42fO5udvQCBZirLN+rFAdAm7Ws7LD75t+sZW3yyo4LHKO7KlveICKJoiQxh+T6RrFC2eDaNb+yLdEQ8nkFqVd+ZyBcq7BbHeC1HNu+Vk8fAd3x hFINcjSa wUMx366V/EJqq6BxnVe7d8C/Ml6aUS3ON23nxdxcssEhMzx9YW40UxOPUoN82jJuAGnDF4suMEO/i/J4Kk8AlBDQUNW8gE5hRRO40Gov+JpefNtbjPulbl+nqAdZXZc8MzVrp9UQ8dQ2oVPmQxz20Z2QVSM7GlGUOMks4eamgl1Hh/xuUZ7pMGe9Yce9ncTSBpcjCTGDgeEMBq2GZAR1nQO8Ks/CvBW6G3tuncN+fgpND1l9lMKqArHsrJT15IcLpElLRpmh0Y0WdVjSFDOu5ZQI2YvnGFxlQAH1rtv3QaGDp6VXh5mb7J9xzwaK2ElUJet4UWIG0rYfKQoE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Kairui Song writes: > On Sun, Dec 22, 2024 at 9:33=E2=80=AFPM Huang, Ying > wrote: >> >> Hi, Kairui, > > Hi Ying, > >> >> 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. > > Hmm, just checked memcontrol.c and I saw quite a few extern functions > not doing that, so I think that's not a convention. I still think that it's a good idea to check whether memcg is disabled in the outermost interfaces instead of being buried in some internal functions. >> 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? > > This change is minimal indeed, it only helps to remove a few unneeded > nop, still a gain though. The benefit is minimal too. > I think mem_cgroup_swapin_uncharge_swap should fade away in the future, Good. Then, we don't need to optimize it too. Just let it fade away. > it's only for Cgroup V1, and it's a really simple function, just a > wrapper for mem_cgroup_uncharge_swap, so I think this is not a > problem? > > If you are concerned about this, this patch can be dropped from this > series, rest of the patches still work the same. Just my 2 cents. --- Best Regards, Huang, Ying