Linux Documentation
 help / color / mirror / Atom feed
* [RFC PATCH 00/12] entry, tracing: Classify early hardirq entry and return tails
@ 2026-10-22  5:16 Karl Mehltretter
  2026-10-22  5:16 ` [RFC PATCH 01/12] sched: Split preempt-count bookkeeping from raw updates Karl Mehltretter
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Karl Mehltretter @ 2026-10-22  5:16 UTC (permalink / raw)
  To: Steven Rostedt, Peter Zijlstra, Thomas Gleixner
  Cc: Karl Mehltretter, Catalin Marinas, Will Deacon, Mark Rutland,
	Ingo Molnar, Andy Lutomirski, Frederic Weisbecker,
	Paul E . McKenney, Sebastian Andrzej Siewior, Boqun Feng,
	Waiman Long, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
	Hongyan Xia, Jonathan Corbet, Shuah Khan, Randy Dunlap,
	Andrew Morton, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, linux-arm-kernel, linux-trace-kernel,
	linux-rt-devel, linux-doc, llvm, linux-kernel

Tracing's transition recursion slot exists because a callback can run after
architectural hardirq entry but before generic entry increments
preempt_count(). Steve asked whether the count could be updated soon enough
to remove that slot. This RFC establishes that entry contract on arm64 and
closes a separate recursion window exposed by the same tests.

This is a design RFC, not a merge-ready proposal. I am looking for
feedback on the entry contract before extending it to other architectures
or removing TRACE_CTX_TRANSITION.

Clang can outline raw preempt-count updates and
__kern_my_cpu_offset() from noinstr entry code. This series applies to a
tree with the following two patches added:

  - Hongyan Xia, "arm64: Always inline raw preempt count updates"
    https://lore.kernel.org/all/c3a90368dd6c096af9d918e036a27728696fb8a4.1786603168.git.hongyan.xia@transsion.com/
  - Will Deacon, "arm64: percpu: Annotate __kern_my_cpu_offset() as
    '__always_inline'"
    https://lore.kernel.org/r/20260918161407.2300-12-will@kernel.org

Those patches are external prerequisites and are not included in this
RFC.

Patches 1 through 11 split raw preempt-count updates from generic IRQ
bookkeeping. On arm64, ordinary interrupts add HARDIRQ_OFFSET after the
pseudo-NMI decision but before instrumentable generic entry work. The
remaining accounting still happens in irq_enter_rcu().

The exit side has a similar gap. Function-graph and MTE callbacks can run
after the real hardirq state has been removed, and kernel return may
schedule before them. The series records ordinary-hardirq provenance and
restores a synthetic hardirq classification after the preemption decision.
That tail changes only preempt-count and lockdep state. It does not repeat
interrupt accounting, RCU, or tick entry.

Patch 12 keeps tracing's recursion state inside one preemption-disabled
interval. It closes the transition collision reproduced at the IRQ-exit
reschedule boundary. TRACE_CTX_TRANSITION remains unchanged because
unconverted architecture entry intervals can still run before
preempt_count() reflects hardirq context. An x86-64 no-transition control
still recorded recursion at system-vector entry and exit and in the
deferred hrtimer return tail.

The base includes "entry: Account the deferred hrtimer rearm as hardirq
context for lockdep" and "softirq: Preserve interrupt context on return
from interrupt".

The main questions are:

  - Should generic entry expose separate raw-update and bookkeeping phases?
  - Are preempt count and lockdep state sufficient for the return tail?
  - Is arm64 a suitable first user of this contract?
  - Should the recursion-lifetime fix travel with the entry conversion?

Karl Mehltretter (12):
  sched: Split preempt-count bookkeeping from raw updates
  lockdep: Use raw access for pinned hardirq state
  entry: Add the pre-counted ordinary-hardirq entry/exit contract
  entry: Skip inactive IRQ-return reschedule calls
  context_tracking: Split IRQ-exit preparation from the EQS transition
  lockdep: Prepare IRQ-on state from a hardirq return tail
  entry: Carry ordinary-hardirq provenance through kernel return
  entry: Classify ordinary hardirq return-tail work as hardirq context
  arm64: Use the pre-counted hardirq lifecycle
  docs: entry: Describe the pre-counted hardirq lifecycle
  locking/selftest: Exercise hardirq return-tail preparation
  tracing: Pin recursion state for its complete lifetime

 Documentation/core-api/entry.rst     |  75 ++++++++++--
 arch/arm64/include/asm/preempt.h     |   2 +-
 arch/arm64/kernel/entry-common.c     |  25 ++--
 include/linux/context_tracking_irq.h |  32 +++++-
 include/linux/hardirq.h              |  29 +++++
 include/linux/interrupt.h            |   2 +-
 include/linux/irq-entry-common.h     |  96 ++++++++++++++--
 include/linux/irqflags.h             |  14 ++-
 include/linux/preempt.h              |   9 ++
 include/linux/trace_recursion.h      |  14 ++-
 kernel/context_tracking.c            |  78 ++++++++++---
 kernel/entry/common.c                |  38 +++++-
 kernel/locking/lockdep.c             |  48 +++++---
 kernel/sched/core.c                  |  68 +++++++++--
 kernel/softirq.c                     | 166 +++++++++++++++++++++++----
 lib/locking-selftest.c               |  53 +++++++++
 16 files changed, 648 insertions(+), 101 deletions(-)


base-commit: 779ab5d73a22c798d1273b4aaf50cf5b8d750be9
prerequisite-patch-id: 9c009809614854fbff979d65aad6732757d006d5
prerequisite-patch-id: 764fd197db36a3889548bbc41890dd5b3d902f99
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-10-22  5:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22  5:16 [RFC PATCH 00/12] entry, tracing: Classify early hardirq entry and return tails Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 01/12] sched: Split preempt-count bookkeeping from raw updates Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 02/12] lockdep: Use raw access for pinned hardirq state Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 03/12] entry: Add the pre-counted ordinary-hardirq entry/exit contract Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 04/12] entry: Skip inactive IRQ-return reschedule calls Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 05/12] context_tracking: Split IRQ-exit preparation from the EQS transition Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 06/12] lockdep: Prepare IRQ-on state from a hardirq return tail Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 07/12] entry: Carry ordinary-hardirq provenance through kernel return Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 08/12] entry: Classify ordinary hardirq return-tail work as hardirq context Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 09/12] arm64: Use the pre-counted hardirq lifecycle Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 10/12] docs: entry: Describe " Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 11/12] locking/selftest: Exercise hardirq return-tail preparation Karl Mehltretter
2026-10-22  5:16 ` [RFC PATCH 12/12] tracing: Pin recursion state for its complete lifetime Karl Mehltretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox