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 array of the comming patch.
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
mm/hugetlb_cgroup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index e20339a346b9..45f94a869776 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -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 */
--
2.34.1
On Wed, Jun 05, 2024 at 07:01:31AM +0000, Xiu Jianfeng wrote: > 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 array of the comming patch. > > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Nit below: > --- > mm/hugetlb_cgroup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c > index e20339a346b9..45f94a869776 100644 > --- a/mm/hugetlb_cgroup.c > +++ b/mm/hugetlb_cgroup.c > @@ -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); Do we still have to set it to '0'? Is it not by default? -- Oscar Salvador SUSE Labs
On 2024/6/10 13:03, Oscar Salvador wrote: > On Wed, Jun 05, 2024 at 07:01:31AM +0000, Xiu Jianfeng wrote: >> 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 array of the comming patch. >> >> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> > > Reviewed-by: Oscar Salvador <osalvador@suse.de> > > Nit below: > >> --- >> mm/hugetlb_cgroup.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c >> index e20339a346b9..45f94a869776 100644 >> --- a/mm/hugetlb_cgroup.c >> +++ b/mm/hugetlb_cgroup.c >> @@ -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); > > Do we still have to set it to '0'? > Is it not by default? > Hi Oscar, Thanks for your review. Not all files care about the value of the second argument of MEMFILE_PRIVATE(), but all files care about the value of the first argument 'idx', so the .private must be explicitly set, and passing 0 as the second argument can be treated as 'not caring what its value is'. Setting it to 0 or 1 does not affect the functionality, but it makes the semantics more clear, IMO. However, you've reminded me that the reassignment of .private in the second patch is problematic, and I will make a comment on that patch.
© 2016 - 2026 Red Hat, Inc.