From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH] mm/vmstat: flush per-cpu node stats when a node goes offline
Date: Sat, 27 Jun 2026 07:41:48 +0000 [thread overview]
Message-ID: <20260627074149.66F9E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260627073107.523499-1-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Recursive acquisition of `cpus_read_lock()` causes a wait-die (AB-BA) reader-writer deadlock with CPU hotplug operations.
- [Medium] Ignoring the `-ENOMEM` return value of `schedule_on_each_cpu()` causes a silent failure, leaving stats permanently orphaned under memory pressure.
--
commit 195f8756c6e31f6d21c338743702f407e4ff93d1
Author: Gregory Price <gourry@gourry.net>
mm/vmstat: flush per-cpu node stats when a node goes offline
This patch flushes per-cpu vmstat deltas to global counters before a node
is offlined. It aims to prevent orphaned statistics that cause throttling
issues by using per-cpu work to synchronize the stats.
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index f534972f517de..ad77343212d37 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -941,6 +941,16 @@ void cpu_vm_stats_fold(int cpu)
> fold_diff(global_zone_diff, global_node_diff);
> }
>
> +static void vmstat_fold_work(struct work_struct *w)
> +{
> + refresh_cpu_vm_stats(false);
> +}
> +
> +void sync_vm_stats(void)
> +{
> + schedule_on_each_cpu(vmstat_fold_work);
[Severity: High]
Can this cause a reader-writer deadlock with CPU hotplug operations?
In the memory hot-remove path, try_remove_memory() acquires the
cpu_hotplug_lock for read via mem_hotplug_begin() before calling
try_offline_node():
mm/memory_hotplug.c:try_remove_memory() {
mem_hotplug_begin();
...
try_offline_node(nid);
}
Then try_offline_node() calls sync_vm_stats(), which bridges into
schedule_on_each_cpu(). The issue is that schedule_on_each_cpu()
unconditionally attempts to acquire the cpu_hotplug_lock for read again:
kernel/workqueue.c:schedule_on_each_cpu() {
...
cpus_read_lock();
}
If a concurrent CPU hotplug operation takes the lock for write between the
first and second read lock acquisitions, it sets the writer-pending flag.
The second read lock attempt will then block waiting for the writer, while
the writer is blocked indefinitely waiting for the first read lock to be
released.
[Severity: Medium]
Does this silently ignore allocation failures?
Under memory pressure, schedule_on_each_cpu() can fail to allocate
the per-cpu work items and return -ENOMEM:
kernel/workqueue.c:schedule_on_each_cpu() {
works = alloc_percpu(struct work_struct);
if (!works)
return -ENOMEM;
...
}
Since sync_vm_stats() returns void, this failure is swallowed. If this
allocation fails during try_offline_node(), the stats will not be flushed
and the per-CPU deltas will be permanently orphaned on a later online,
which is the original bug this patch aims to fix.
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260627073107.523499-1-gourry@gourry.net?part=1
next prev parent reply other threads:[~2026-06-27 7:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 7:31 [PATCH] mm/vmstat: flush per-cpu node stats when a node goes offline Gregory Price
2026-06-27 7:41 ` sashiko-bot [this message]
2026-06-27 8:23 ` Gregory Price
2026-06-27 20:42 ` Gregory Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260627074149.66F9E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gourry@gourry.net \
--cc=linux-cxl@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox