From nobody Sun Feb 8 15:07:42 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C642EEB64DA for ; Sat, 8 Jul 2023 02:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbjGHCc4 (ORCPT ); Fri, 7 Jul 2023 22:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjGHCcy (ORCPT ); Fri, 7 Jul 2023 22:32:54 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C34C8E; Fri, 7 Jul 2023 19:32:51 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QyZ3J2NKhzMqGH; Sat, 8 Jul 2023 10:29:32 +0800 (CST) Received: from huawei.com (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 8 Jul 2023 10:32:46 +0800 From: Miaohe Lin To: , , , , CC: , , , , Subject: [PATCH v2] mm/memcg: minor cleanup for MEM_CGROUP_ID_MAX Date: Sat, 8 Jul 2023 10:33:04 +0800 Message-ID: <20230708023304.1184111-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" MEM_CGROUP_ID_MAX is only used when CONFIG_MEMCG is configured. So remove unneeded !CONFIG_MEMCG variant. Also it's only used in mem_cgroup_alloc(), so move it from memcontrol.h to memcontrol.c. And further define it as: #define MEM_CGROUP_ID_MAX ((1UL << MEM_CGROUP_ID_SHIFT) - 1) so if someone changes MEM_CGROUP_ID_SHIFT in the future, then MEM_CGROUP_ID_MAX will be updated accordingly, as suggested by Muchun. Reviewed-by: Muchun Song Signed-off-by: Miaohe Lin --- include/linux/memcontrol.h | 2 -- mm/memcontrol.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5818af8eca5a..58eb7ca65699 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -61,7 +61,6 @@ struct mem_cgroup_reclaim_cookie { #ifdef CONFIG_MEMCG =20 #define MEM_CGROUP_ID_SHIFT 16 -#define MEM_CGROUP_ID_MAX USHRT_MAX =20 struct mem_cgroup_id { int id; @@ -1158,7 +1157,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t= *pgdat, int order, #else /* CONFIG_MEMCG */ =20 #define MEM_CGROUP_ID_SHIFT 0 -#define MEM_CGROUP_ID_MAX 0 =20 static inline struct mem_cgroup *folio_memcg(struct folio *folio) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e8ca4bdcb03c..284396ea8a33 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5165,6 +5165,7 @@ static struct cftype mem_cgroup_legacy_files[] =3D { * those references are manageable from userspace. */ =20 +#define MEM_CGROUP_ID_MAX ((1UL << MEM_CGROUP_ID_SHIFT) - 1) static DEFINE_IDR(mem_cgroup_idr); =20 static void mem_cgroup_id_remove(struct mem_cgroup *memcg) --=20 2.33.0