]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/hugetlb_cgroup: identify the legacy using cgroup_subsys_on_dfl()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Wed, 12 Jun 2024 09:24:07 +0000 (09:24 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 02:30:09 +0000 (19:30 -0700)
Patch series "mm/hugetlb_cgroup: rework on cftypes", v3.

This patchset provides an intuitive view of the control files through
static templates of cftypes.  This improves the readability of the code.

This patch (of 3):

Currently the numa_stat file encodes 1 into .private using the micro
MEMFILE_PRIVATE() to identify the legacy.  Actually, we can use
cgroup_subsys_on_dfl() instead.  This is helpful to handle .private in the
static templates in the next patch.

Link: https://lkml.kernel.org/r/20240612092409.2027592-1-xiujianfeng@huawei.com
Link: https://lkml.kernel.org/r/20240612092409.2027592-2-xiujianfeng@huawei.com
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb_cgroup.c

index e20339a346b9353b2eb69101366e1f89411b29ae..45f94a8697762f19f2499e0b738765cd97416358 100644 (file)
@@ -460,7 +460,7 @@ static int hugetlb_cgroup_read_numa_stat(struct seq_file *seq, void *dummy)
        int nid;
        struct cftype *cft = seq_cft(seq);
        int idx = MEMFILE_IDX(cft->private);
-       bool legacy = MEMFILE_ATTR(cft->private);
+       bool legacy = !cgroup_subsys_on_dfl(hugetlb_cgrp_subsys);
        struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(seq_css(seq));
        struct cgroup_subsys_state *css;
        unsigned long usage;
@@ -839,7 +839,7 @@ static void __init __hugetlb_cgroup_file_legacy_init(int idx)
        /* Add the numa stat file */
        cft = &h->cgroup_files_legacy[8];
        snprintf(cft->name, MAX_CFTYPE_NAME, "%s.numa_stat", buf);
-       cft->private = MEMFILE_PRIVATE(idx, 1);
+       cft->private = MEMFILE_PRIVATE(idx, 0);
        cft->seq_show = hugetlb_cgroup_read_numa_stat;
 
        /* NULL terminate the last cft */