[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+CK2bBnPc=Z4SOPbnMqnDA1X9oLsq_rzsEnAcxNsA5ZWCUWwQ@mail.gmail.com>
Date: Mon, 11 Dec 2023 12:09:57 -0500
From: Pasha Tatashin <pasha.tatashin@...een.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org,
akpm@...ux-foundation.org, surenb@...gle.com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
souravpanda@...gle.com
Subject: Re: [PATCH] vmstat: don't auto expand the sysfs files
On Mon, Dec 11, 2023 at 12:00 PM Matthew Wilcox <willy@...radead.org> wrote:
>
> On Mon, Dec 11, 2023 at 03:46:44PM +0000, Pasha Tatashin wrote:
> > +++ b/drivers/base/node.c
> > @@ -520,26 +520,34 @@ static ssize_t node_read_vmstat(struct device *dev,
> > int i;
> > int len = 0;
> >
> > - for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
> > - len += sysfs_emit_at(buf, len, "%s %lu\n",
> > - zone_stat_name(i),
> > - sum_zone_node_page_state(nid, i));
> > + for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) {
> > + if (vmstat_text[ZONE_STAT_NAME_IDX(i)].flags & VMSTAT_SHOW_SYSFS) {
> > + len += sysfs_emit_at(buf, len, "%s %lu\n",
> > + zone_stat_name(i),
> > + sum_zone_node_page_state(nid, i));
> > + }
> > + }
>
> This seems overly complicated. Why not do:
>
> for (i = 0; i < NR_VM_ZONE_STAT_SYSFS_ITEMS; i++)
>
> and have assertions that this number doesn't change (and require people
> to add to the list after that point)?
This is what I wanted to do at the beginning. But, the problem is that
vmstat_text[] contains names from a number of different structs of
stats: zone_stat, numa_stat, node_stat, lru_list, writeback_stat,
vm_even. Therefore, we can't simply count the number of
NR_VM_ZONE_STAT_SYSFS_ITEMS, as the new items can be added in the
middle of vmstat_text[] when for example numa_stat is expanded.
Pasha
Powered by blists - more mailing lists