Skip to content

Commit 60b1e24

Browse files
MiaoheLinakpm00
authored andcommitted
mm/memcg: minor cleanup for MEM_CGROUP_ID_MAX
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. Link: https://lkml.kernel.org/r/20230708023304.1184111-1-linmiaohe@huawei.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Shakeel Butt <shakeelb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 22d1e68 commit 60b1e24

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

include/linux/memcontrol.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ struct mem_cgroup_reclaim_cookie {
6161
#ifdef CONFIG_MEMCG
6262

6363
#define MEM_CGROUP_ID_SHIFT 16
64-
#define MEM_CGROUP_ID_MAX USHRT_MAX
6564

6665
struct mem_cgroup_id {
6766
int id;
@@ -1158,7 +1157,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
11581157
#else /* CONFIG_MEMCG */
11591158

11601159
#define MEM_CGROUP_ID_SHIFT 0
1161-
#define MEM_CGROUP_ID_MAX 0
11621160

11631161
static inline struct mem_cgroup *folio_memcg(struct folio *folio)
11641162
{

mm/memcontrol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5155,6 +5155,7 @@ static struct cftype mem_cgroup_legacy_files[] = {
51555155
* those references are manageable from userspace.
51565156
*/
51575157

5158+
#define MEM_CGROUP_ID_MAX ((1UL << MEM_CGROUP_ID_SHIFT) - 1)
51585159
static DEFINE_IDR(mem_cgroup_idr);
51595160

51605161
static void mem_cgroup_id_remove(struct mem_cgroup *memcg)

0 commit comments

Comments
 (0)