Hi Valentin.

On 10/10/25 9:08 PM, Valentin Schneider wrote:
smp_call_function() & friends have the unfortunate habit of sending IPIs to
isolated, NOHZ_FULL, in-userspace CPUs, as they blindly target all online
CPUs.

Some callsites can be bent into doing the right, such as done by commit:

   cc9e303c91f5 ("x86/cpu: Disable frequency requests via aperfmperf IPI for 
nohz_full CPUs")

Unfortunately, not all SMP callbacks can be omitted in this
fashion. However, some of them only affect execution in kernelspace, which
means they don't have to be executed *immediately* if the target CPU is in
userspace: stashing the callback and executing it upon the next kernel entry
would suffice. x86 kernel instruction patching or kernel TLB invalidation
are prime examples of it.

Reduce the RCU dynticks counter width to free up some bits to be used as a
deferred callback bitmask. Add some build-time checks to validate that
setup.

Presence of CT_RCU_WATCHING in the ct_state prevents queuing deferred work.

Later commits introduce the bit:callback mappings.

Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Nicolas Saenz Julienne <[email protected]>
Signed-off-by: Valentin Schneider <[email protected]>
---
  arch/Kconfig                                 |  9 +++
  arch/x86/Kconfig                             |  1 +
  arch/x86/include/asm/context_tracking_work.h | 16 +++++
  include/linux/context_tracking.h             | 21 ++++++
  include/linux/context_tracking_state.h       | 30 ++++++---
  include/linux/context_tracking_work.h        | 26 ++++++++
  kernel/context_tracking.c                    | 69 +++++++++++++++++++-
  kernel/time/Kconfig                          |  5 ++
  8 files changed, 165 insertions(+), 12 deletions(-)
  create mode 100644 arch/x86/include/asm/context_tracking_work.h
  create mode 100644 include/linux/context_tracking_work.h

diff --git a/include/linux/context_tracking_work.h 
b/include/linux/context_tracking_work.h
new file mode 100644
index 0000000000000..c68245f8d77c5
--- /dev/null
+++ b/include/linux/context_tracking_work.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_CONTEXT_TRACKING_WORK_H
+#define _LINUX_CONTEXT_TRACKING_WORK_H
+
+#include <linux/bitops.h>
+
+enum {
+       CT_WORK_n_OFFSET,
+       CT_WORK_MAX_OFFSET
+};
+
+enum ct_work {
+       CT_WORK_n        = BIT(CT_WORK_n_OFFSET),
+       CT_WORK_MAX      = BIT(CT_WORK_MAX_OFFSET)
+};
+
+#include <asm/context_tracking_work.h>
+

It fails to compile on powerpc (likey any arch other than x86)

In file included from ./include/linux/context_tracking_state.h:8,
                 from ./include/linux/hardirq.h:5,
                 from ./include/linux/interrupt.h:11,
                 from ./include/linux/kernel_stat.h:8,
                 from ./include/linux/cgroup.h:27,
                 from ./include/linux/memcontrol.h:13,
                 from ./include/linux/swap.h:9,
                 from ./include/linux/suspend.h:5,
                 from arch/powerpc/kernel/asm-offsets.c:21:
./include/linux/context_tracking_work.h:17:10: fatal error: asm/context_tracking_work.h: No such file or directory
   17 | #include <asm/context_tracking_work.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Gating works for compile, but no benefit of the series.

+#ifdef HAVE_CONTEXT_TRACKING_WORK
 #include <asm/context_tracking_work.h>
+#endif


I have been trying to debug/understand the issue seen with isolcpus= and
nohz_full=. system is idle, even then it occasionally woken up to do some work. So I was interesting if this series can help.

Reply via email to