From patchwork Sat Jul 8 02:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13305547 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 23DAAEB64DA for ; Sat, 8 Jul 2023 02:32:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5365E6B0071; Fri, 7 Jul 2023 22:32:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E5A78D0001; Fri, 7 Jul 2023 22:32:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D3C56B0074; Fri, 7 Jul 2023 22:32:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 207B16B0071 for ; Fri, 7 Jul 2023 22:32:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C9E0CC0179 for ; Sat, 8 Jul 2023 02:32:57 +0000 (UTC) X-FDA: 80986871994.27.407239B Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 6EACE8000A for ; Sat, 8 Jul 2023 02:32:53 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688783575; 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: references; bh=LR6p5w/daub/wt79iMHOIl+yrsKd/h8CYq/TYKikr7I=; b=l+ynxs5Rl+1Dnt3uKdYWuhrHxi7Ffwi/Qi+KepdOo9+Ed765D5BmyLPgTcciBHHJ6qfwht tGYLBzR8vmpAkuZabGIFh1slNEwCODrk1VrMhfLPAh2VB/gZ70bbAIWziSAPJRqF2QmPjP Kmq2AfmAXmP9O3yONxcTPGVVrZtfu3o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688783575; a=rsa-sha256; cv=none; b=uyIyBXT9JtsUKxJ7uOuHYbPV6e8Tk4gJHKQPq4LYGAdBpp78iuJTO2Nlf6fROTfOTy5ZtM y5MGl0GBdKvdiKaIbFl2BBLxrLqXkBeyQdRy8HY95+sKg4Cue03GYbOYuaMqmdeelfHX8c WLCRTtj57fuIQ3r+lhTCI8BchT4JYJ0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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 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 X-Rspamd-Queue-Id: 6EACE8000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: i4bg4g9c5jiw1dodth7tbafxqpwsoat7 X-HE-Tag: 1688783573-974341 X-HE-Meta: U2FsdGVkX19pzQj4icZ74oytIdggLo//C3wux5pqMyZsfg08G6oQ+nR1Tct0+Q+3KDPitdf8jMsxETnuSLExtlSARUNicBTTgmdVILIPeJwFPZfU3Fp/rcVK3JfheedNyvwXp9y+OZwO6ennHvyU+Ue1WhTtxbSU7DZ+JGS3OJocFEN40CnJOgBVESNYowT9ELbhykkUpNDm6C3a4H3KUDto4c6EWT+ZhL+LRcr2YS7iArWONavl4/fuwF4UUeR7aDGNZhBimb2FNyZyAkXaxFM629HurseyEH5ioLY97hCGfc/8rKEhlnA6YOcD/dhu4u/8RgozM73XOPj+ZM5U6aMdwtjW//ngCZWx2cF4fQuMhHM8dK7NySoJi9ofIfFMbPl/zO7SxFZcAJCDN/+KxPsvVGY5aMx5iCi3fZiC78cydsmfjltwayJE9wfGxUUldohq+5TPm/1g/jaNp6k7B178s+uVV4iEkMR7nSfNfjpNLMcHKVcibxhadVw/NGTSgOYcm074DmX+R4Ijk85dzcKyhTzZti2VreWK4W/4iPvoBDoM71rGVL/4EORE75A0xdq5vcdUMQ5hHKzU8amvWdoXW0JrvBdw3mT36qL1otxn3rHFKnRvcUBwbXqG++oQ5VAHbm7of9XKmIBMot8zjum1IrDXQV1C/ctwja+8UCXcph2kwF5DFs8z1gp+GVfSEgxexeYrdy+61oe4D1FK2gENQEo3yFJF5SswcUOvsaiVMT6YWhphRQV6G6yoVbmOwiUx40m1NdkbBhc+8uKAgANbXFyTo79sNVoKFKxG+Y1NdiTN/c/b9PN//NNHkNV7dfvCWKGIBtyhC+NfzbKSdUOCgkQPcceFNruEGLpKqnFNSeWRPyTxpa71oPHil+1gYTZCK15AvFsRC2gMVuGrHj7k9XVGtpD8DdTGUen1diCfamLDjx//sTksRpGWirPNsrolIz+DaT8570kcQPw EZqt3+vL 5B37PeMuaOdIvkeEnvDzwcKgjYEo+s96edNE3ONaA4YA9rRvDdLJkONajcFeJgWGEPgOW+AN8iYZTt52IWU7aftnhcttl+dDp7P+PEyoS4bh/2NMxMtRUzBgpVlkmBqAozLUf80UXxl0piEU5IJq0xp8ctghInalRFq+I62cBPsTWdLDTuXfz0AFuLC+899c3DQ0PcHaPP6XYplDrkAREaf3aieRUKysy8X2xbuxdCG39gTNN48oWQZNqmr4QO2J8p8OO 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: 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 #define MEM_CGROUP_ID_SHIFT 16 -#define MEM_CGROUP_ID_MAX USHRT_MAX 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 */ #define MEM_CGROUP_ID_SHIFT 0 -#define MEM_CGROUP_ID_MAX 0 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[] = { * those references are manageable from userspace. */ +#define MEM_CGROUP_ID_MAX ((1UL << MEM_CGROUP_ID_SHIFT) - 1) static DEFINE_IDR(mem_cgroup_idr); static void mem_cgroup_id_remove(struct mem_cgroup *memcg)