Re: [PATCH] mm/vmstat: add header line to /proc/buddyinfo output

From: Ye Liu
Date: Thu Sep 18 2025 - 04:12:41 EST




在 2025/9/18 15:29, Michal Hocko 写道:
> On Thu 18-09-25 15:17:40, Ye Liu wrote:
>> From: Ye Liu <liuye@xxxxxxxxxx>
>>
>> Add a header line to /proc/buddyinfo that shows the order numbers
>> for better readability and clarity.
>>
>> Before:
>> Node 0, zone DMA 0 0 0 0 0 0 0 ...
>> Node 0, zone DMA32 5 8 6 6 7 5 8 ...
>> Node 0, zone Normal 1113 351 138 65 38 31 25 ...
>>
>> After:
>> Free pages per order 0 1 2 3 4 5 6 ...
>> Node 0, zone DMA 0 0 0 0 0 0 0 ...
>> Node 0, zone DMA32 5 8 6 6 7 5 8 ...
>> Node 0, zone Normal 1113 351 138 65 38 31 25 ...
>
> Why is this needed? And have you considered tha this might break
> existing parsers of the file?
>

Thanks for the review.

The reason for this change is simply to make /proc/buddyinfo self-describing.
Right now you have to know which column is which order; with a header it’s
obvious. This is similar to what /proc/pagetypeinfo already does, e.g.:

Page block order: 9
Pages per block: 512

Free pages count per migrate type at order 0 1 2 3 ...
Node 0, zone DMA, type Unmovable 0 0 0 ...

Regarding existing parsers: the patch does not change any of the existing
“Node … zone …” lines, it only adds a single header line before them. Most
parsers match “Node” lines and ignore everything else, so the risk should be
low. If you know of any existing parser that this would break, please let
me know so I can address it.


>>
>> Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
>> ---
>> mm/vmstat.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/mm/vmstat.c b/mm/vmstat.c
>> index bb09c032eecf..e9606457ab91 100644
>> --- a/mm/vmstat.c
>> +++ b/mm/vmstat.c
>> @@ -1574,7 +1574,14 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
>> */
>> static int frag_show(struct seq_file *m, void *arg)
>> {
>> + int order;
>> pg_data_t *pgdat = (pg_data_t *)arg;
>> + /* Print header */
>> + seq_printf(m, "%-21s ", "Free pages per order");
>> + for (order = 0; order < NR_PAGE_ORDERS; ++order)
>> + seq_printf(m, "%6d ", order);
>> + seq_putc(m, '\n');
>> +
>> walk_zones_in_node(m, pgdat, true, false, frag_show_print);
>> return 0;
>> }
>> --
>> 2.43.0
>>
>

--
Thanks,
Ye Liu