Re: [PATCH 3/3] mm/vmstat: simplfy extfrag_show_print with fragmentation_index()

From: Vlastimil Babka
Date: Fri Mar 15 2024 - 07:14:23 EST


On 3/14/24 01:54, Luis Chamberlain wrote:
> fragmentation_index() already uses the stack for the struct contig_page_info,
> so just use that and enhance the documentation for fragmentation_index().
>
> Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

> ---
> mm/vmstat.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index db79935e4a54..582f89b37ccf 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1129,7 +1129,10 @@ unsigned int extfrag_for_order(struct zone *zone, unsigned int order)
> info.free_pages);
> }
>
> -/* Same as __fragmentation index but allocs contig_page_info on stack */
> +/*
> + * Same as __fragmentation index but allocs contig_page_info on stack,
> + * useful when walking a zone as interrupts are disabled.
> + */
> int fragmentation_index(struct zone *zone, unsigned int order)
> {
> struct contig_page_info info;
> @@ -2227,15 +2230,11 @@ static void extfrag_show_print(struct seq_file *m,
> unsigned int order;
> int index;
>
> - /* Alloc on stack as interrupts are disabled for zone walk */
> - struct contig_page_info info;
> -
> seq_printf(m, "Node %d, zone %8s ",
> pgdat->node_id,
> zone->name);
> for (order = 0; order < NR_PAGE_ORDERS; ++order) {
> - fill_contig_page_info(zone, order, &info);
> - index = __fragmentation_index(order, &info);
> + index = fragmentation_index(zone, order);
> seq_printf(m, "%2d.%03d ", index / 1000, index % 1000);
> }
>