* [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
@ 2026-06-04 13:42 Imran Khan
2026-06-04 17:04 ` Joshua Hahn
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Imran Khan @ 2026-06-04 13:42 UTC (permalink / raw)
To: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko
Cc: linux-mm, linux-kernel
frag_show_print() just reads zone->free_area[order].nr_free, so
it can safely do this without needing the zone->lock.
Pass nolock=true from frag_show(), so that walk_zones_in_node()
can skip the zone->lock acquisition.
Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
---
mm/vmstat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/vmstat.c b/mm/vmstat.c
index f534972f517de..7b93fbf9af092 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
static int frag_show(struct seq_file *m, void *arg)
{
pg_data_t *pgdat = (pg_data_t *)arg;
- walk_zones_in_node(m, pgdat, true, false, frag_show_print);
+ walk_zones_in_node(m, pgdat, true, true, frag_show_print);
return 0;
}
base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
@ 2026-06-04 17:04 ` Joshua Hahn
2026-06-05 12:14 ` Vlastimil Babka (SUSE)
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Joshua Hahn @ 2026-06-04 17:04 UTC (permalink / raw)
To: Imran Khan
Cc: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, linux-mm,
linux-kernel
On Thu, 4 Jun 2026 21:42:45 +0800 Imran Khan <imran.f.khan@oracle.com> wrote:
> frag_show_print() just reads zone->free_area[order].nr_free, so
> it can safely do this without needing the zone->lock.
>
> Pass nolock=true from frag_show(), so that walk_zones_in_node()
> can skip the zone->lock acquisition.
Hello Imran, thank you for the patch!
Seems reasonable to me, and I think this sentiment was already explicitly
encoded in a comment block in frag_show_print:
/*
* Access to nr_free is lockless as nr_free is used only for
* printing purposes. Use data_race to avoid KCSAN warning.
*/
seq_printf(m, "%6lu ", data_race(zone->free_area[order].nr_free));
Plus, we have a data_race() here so it seems like lockless reading was
always the intent anyways. So:
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Digging into this a bit more, I did find something worth noting.
Commit af1c31acc85325 "mm/vmstat: annotate data race for
zone->free_area[order].nr_free" was the commit that added the
data_race() here, in response to a KCSAN report. But looking into it, I
don't think KCSAN was reporting a data race for this callsite, it was
actually reporting it for a different one in
extfrag_for_order->fill_contig_page_info. Maybe the author there added
the data_race() for frag_show_print just to be safe as well, even though
at the time it was protected by a zone->lock anyways.
Just something I thought was interesting to note. Thanks again!
Joshua
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
> mm/vmstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index f534972f517de..7b93fbf9af092 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
> static int frag_show(struct seq_file *m, void *arg)
> {
> pg_data_t *pgdat = (pg_data_t *)arg;
> - walk_zones_in_node(m, pgdat, true, false, frag_show_print);
> + walk_zones_in_node(m, pgdat, true, true, frag_show_print);
> return 0;
> }
>
>
> base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
2026-06-04 17:04 ` Joshua Hahn
@ 2026-06-05 12:14 ` Vlastimil Babka (SUSE)
2026-06-08 8:17 ` Lorenzo Stoakes
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-06-05 12:14 UTC (permalink / raw)
To: Imran Khan, akpm, david, ljs, liam, rppt, surenb, mhocko
Cc: linux-mm, linux-kernel
On 6/4/26 15:42, Imran Khan wrote:
> frag_show_print() just reads zone->free_area[order].nr_free, so
> it can safely do this without needing the zone->lock.
>
> Pass nolock=true from frag_show(), so that walk_zones_in_node()
> can skip the zone->lock acquisition.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
> ---
> mm/vmstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index f534972f517de..7b93fbf9af092 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
> static int frag_show(struct seq_file *m, void *arg)
> {
> pg_data_t *pgdat = (pg_data_t *)arg;
> - walk_zones_in_node(m, pgdat, true, false, frag_show_print);
> + walk_zones_in_node(m, pgdat, true, true, frag_show_print);
> return 0;
> }
>
>
> base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
2026-06-04 17:04 ` Joshua Hahn
2026-06-05 12:14 ` Vlastimil Babka (SUSE)
@ 2026-06-08 8:17 ` Lorenzo Stoakes
2026-06-24 7:16 ` Lorenzo Stoakes
2026-06-24 7:17 ` David Hildenbrand (Arm)
4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2026-06-08 8:17 UTC (permalink / raw)
To: Imran Khan
Cc: akpm, david, liam, vbabka, rppt, surenb, mhocko, linux-mm,
linux-kernel
On Thu, Jun 04, 2026 at 09:42:45PM +0800, Imran Khan wrote:
> frag_show_print() just reads zone->free_area[order].nr_free, so
> it can safely do this without needing the zone->lock.
>
> Pass nolock=true from frag_show(), so that walk_zones_in_node()
> can skip the zone->lock acquisition.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
LGTM, so:
Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
> ---
> mm/vmstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index f534972f517de..7b93fbf9af092 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
> static int frag_show(struct seq_file *m, void *arg)
> {
> pg_data_t *pgdat = (pg_data_t *)arg;
> - walk_zones_in_node(m, pgdat, true, false, frag_show_print);
> + walk_zones_in_node(m, pgdat, true, true, frag_show_print);
> return 0;
> }
>
>
> base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
> --
> 2.34.1
>
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
` (2 preceding siblings ...)
2026-06-08 8:17 ` Lorenzo Stoakes
@ 2026-06-24 7:16 ` Lorenzo Stoakes
2026-06-24 7:17 ` David Hildenbrand (Arm)
4 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2026-06-24 7:16 UTC (permalink / raw)
To: akpm
Cc: Imran Khan, david, liam, vbabka, rppt, surenb, mhocko, linux-mm,
linux-kernel
Hi Andrew,
I think this one got missed last cycle? I don't see it in any mm- tree, and has
a bunch of tags.
I guess Imran will need to resend it at -rc1?
Cheers, Lorenzo
On Thu, Jun 04, 2026 at 09:42:45PM +0800, Imran Khan wrote:
> frag_show_print() just reads zone->free_area[order].nr_free, so
> it can safely do this without needing the zone->lock.
>
> Pass nolock=true from frag_show(), so that walk_zones_in_node()
> can skip the zone->lock acquisition.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
> mm/vmstat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index f534972f517de..7b93fbf9af092 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1568,7 +1568,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
> static int frag_show(struct seq_file *m, void *arg)
> {
> pg_data_t *pgdat = (pg_data_t *)arg;
> - walk_zones_in_node(m, pgdat, true, false, frag_show_print);
> + walk_zones_in_node(m, pgdat, true, true, frag_show_print);
> return 0;
> }
>
>
> base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
` (3 preceding siblings ...)
2026-06-24 7:16 ` Lorenzo Stoakes
@ 2026-06-24 7:17 ` David Hildenbrand (Arm)
4 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-24 7:17 UTC (permalink / raw)
To: Imran Khan, akpm, ljs, liam, vbabka, rppt, surenb, mhocko
Cc: linux-mm, linux-kernel
On 6/4/26 15:42, Imran Khan wrote:
> frag_show_print() just reads zone->free_area[order].nr_free, so
> it can safely do this without needing the zone->lock.
>
> Pass nolock=true from frag_show(), so that walk_zones_in_node()
> can skip the zone->lock acquisition.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-24 7:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 13:42 [PATCH] mm/vmstat: avoid taking zone lock in /proc/buddyinfo reads Imran Khan
2026-06-04 17:04 ` Joshua Hahn
2026-06-05 12:14 ` Vlastimil Babka (SUSE)
2026-06-08 8:17 ` Lorenzo Stoakes
2026-06-24 7:16 ` Lorenzo Stoakes
2026-06-24 7:17 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox