Skip to contentSkip to conversation

Patch "vmstat: disable vmstat_work on vmstat_cpu_down_prep()" has been added to the 6.12-stable tree

DISCUSSION Koichiro Den 2 participants 2 messages Jan 6, 2025 1 message not in the archive Stable branch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 2025010620-glazing-parakeet-e197@gregkh

#1 lore raw
Quoted 8 lines · On Mon, Jan 06, 2025 at 11:41:20AM +0100, [email protected] wrote:

This is a note to let you know that I've just added the patch titled

vmstat: disable vmstat_work on vmstat_cpu_down_prep()

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Quoted 6 lines

The filename of the patch is:
vmstat-disable-vmstat_work-on-vmstat_cpu_down_prep.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Hi, could you hold off on adding this for now? It's broken [1] and needs to be fixed. Once a follow-up fix is ready, I'll make sure to notify you.

[1] https://lore.kernel.org/linux-mm/[email protected]/T/#m758eb53a012a4348c256ee8a723a6a29f86906df

Thanks.

-Koichiro Den

Quoted 73 lines

From adcfb264c3ed51fbbf5068ddf10d309a63683868 Mon Sep 17 00:00:00 2001
From: Koichiro Den <[email protected]>
Date: Sat, 21 Dec 2024 12:33:20 +0900
Subject: vmstat: disable vmstat_work on vmstat_cpu_down_prep()

From: Koichiro Den <[email protected]>

commit adcfb264c3ed51fbbf5068ddf10d309a63683868 upstream.

Even after mm/vmstat:online teardown, shepherd may still queue work for the dying cpu until the cpu is removed from online mask. While it's quite rare, this means that after unbind_workers() unbinds a per-cpu kworker, it potentially runs vmstat_update for the dying CPU on an irrelevant cpu before entering atomic AP states. When CONFIG_DEBUG_PREEMPT=y, it results in the following error with the backtrace.

  BUG: using smp_processor_id() in preemptible [00000000] code: \
                                               kworker/7:3/1702
  caller is refresh_cpu_vm_stats+0x235/0x5f0
  CPU: 0 UID: 0 PID: 1702 Comm: kworker/7:3 Tainted: G
  Tainted: [N]=TEST
  Workqueue: mm_percpu_wq vmstat_update
  Call Trace:
   <TASK>
   dump_stack_lvl+0x8d/0xb0
   check_preemption_disabled+0xce/0xe0
   refresh_cpu_vm_stats+0x235/0x5f0
   vmstat_update+0x17/0xa0
   process_one_work+0x869/0x1aa0
   worker_thread+0x5e5/0x1100
   kthread+0x29e/0x380
   ret_from_fork+0x2d/0x70
   ret_from_fork_asm+0x1a/0x30
   </TASK>

So, for mm/vmstat:online, disable vmstat_work reliably on teardown and symmetrically enable it on startup.

---
 mm/vmstat.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmstat.c +2 -1
@@ -2139,13 +2139,14 @@ static int vmstat_cpu_online(unsigned in
 	if (!node_state(cpu_to_node(cpu), N_CPU)) {
 		node_set_state(cpu_to_node(cpu), N_CPU);
 	}
+	enable_delayed_work(&per_cpu(vmstat_work, cpu));
 
 	return 0;
 }
 
 static int vmstat_cpu_down_prep(unsigned int cpu)
 {
-	cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu));
+	disable_delayed_work_sync(&per_cpu(vmstat_work, cpu));
 	return 0;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-6.12/vmstat-disable-vmstat_work-on-vmstat_cpu_down_prep.patch

maintainer
#2 lore raw
Quoted 13 lines · Koichiro Den
Quoted 12 lines · On Mon, Jan 06, 2025 at 11:41:20AM +0100, [email protected] wrote:

This is a note to let you know that I've just added the patch titled

vmstat: disable vmstat_work on vmstat_cpu_down_prep()

to the 6.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
vmstat-disable-vmstat_work-on-vmstat_cpu_down_prep.patch
and it can be found in the queue-6.12 subdirectory.

Quoted 7 lines
Quoted 2 lines

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Hi, could you hold off on adding this for now? It's broken [1] and needs to be fixed. Once a follow-up fix is ready, I'll make sure to notify you.

[1] https://lore.kernel.org/linux-mm/[email protected]/T/#m758eb53a012a4348c256ee8a723a6a29f86906df

Now dropped, thanks.

greg k-h