diff mbox series

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

Message ID 20240314005436.2962962-4-mcgrof@kernel.org (mailing list archive)
State New
Headers show
Series mm: random cleanups | expand

Commit Message

Luis Chamberlain March 14, 2024, 12:54 a.m. UTC
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@kernel.org>
---
 mm/vmstat.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Vlastimil Babka March 15, 2024, 11:13 a.m. UTC | #1
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@kernel.org>

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  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);
>  	}
>
Davidlohr Bueso March 15, 2024, 2:36 p.m. UTC | #2
On Wed, 13 Mar 2024, 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().
>

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

>Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
diff mbox series

Patch

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);
 	}