Skip to content

arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys

Mark Rutland linux-arm-kernel lkml 4 versions – Applied

Status from this message: The following commit has been merged into the sched/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest7 patches 3 repliesApplied
  2. v37 patches 12 repliesSuperseded
  3. v27 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v16 patches12 repliesSuperseded

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/7sched/preempt: move PREEMPT_DYNAMIC logic laterkernel/sched/core.c+136 -1360 replies
2/7sched/preempt: refactor sched_dynamic_update()arch/x86/include/asm/preempt.h include/linux/entry-common.h kernel/sched/core.c+45 -260 replies
3/7sched/preempt: simplify irqentry_exit_cond_resched() callersinclude/linux/entry-common.h kernel/entry/common.c+10 -110 replies
4/7sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRYarch/Kconfig kernel/sched/core.c+2 -10 replies
5/7sched/preempt: add PREEMPT_DYNAMIC using static keysarch/Kconfig arch/x86/Kconfig include/linux/entry-common.h +5 more+122 -111 reply
6/7arm64: entry: centralize preemption decisionarch/arm64/kernel/entry-common.c+11 -90 replies
7/7arm64: support PREEMPT_DYNAMICarch/arm64/Kconfig arch/arm64/include/asm/preempt.h arch/arm64/kernel/entry-common.c+27 -30 replies

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchArd BiesheuvelCatalin MarinasFrederic Weisbecker
SeriesA-b
1/7A-b
2/7A-b
3/7A-b
4/7A-b
5/7A-b
6/7A-b A-b
7/7A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys

This series enables PREEMPT_DYNAMIC on arm64. To do so, it adds a new mechanism allowing the preemption functions to be enabled/disabled using static keys rather than static calls, with architectures selecting whether they use static calls or static keys.

With non-inline static calls, each function call results in a call to the (out-of-line) trampoline which either tail-calls its associated callee or performs an early return.

The key idea is that where we're only enabling/disabling a single callee, we can inline this trampoline into the start of the callee, using a static key to decide whether to return early, and leaving the remaining codegen to the compiler. The overhead should be similar to (and likely lower than) using a static call trampoline. Since most codegen is up to the compiler, we sidestep a number of implementation pain-points (e.g. things like CFI should "just work" as well as they do for any other functions).

The bulk of the diffstat for kernel/sched/core.c is shuffling the PREEMPT_DYNAMIC code later in the file, and the actual additions are fairly trivial.

I've given this very light build+boot testing so far.

Since v1 [1]:
* Rework Kconfig text to be clearer
* Rework arm64 entry code
* Clarify commit messages.

Since v2 [2]:
* Add missing includes
* Always provide prototype for preempt_schedule()
* Always provide prototype for preempt_schedule_notrace()
* Fix __cond_resched() to default to disabled
* Fix might_resched() to default to disabled
* Clarify example in commit message

Since v3 [3]:
* Add acks (including those missing from v3)
* Fix Kconfig dependencies for jump labels
* Don't default-enable PREEMPT_DYNAMIC when using static keys
* Clarify generated assembly examples

[1] https://lore.kernel.org/r/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/
[3] https://lore.kernel.org/r/[email protected]/

Thanks,
Mark.

Mark Rutland (7):
sched/preempt: move PREEMPT_DYNAMIC logic later sched/preempt: refactor sched_dynamic_update() sched/preempt: simplify irqentry_exit_cond_resched() callers sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRY sched/preempt: add PREEMPT_DYNAMIC using static keys
arm64: entry: centralize preemption decision
arm64: support PREEMPT_DYNAMIC

 arch/Kconfig                     |  37 +++-
 arch/arm64/Kconfig               |   1 +
 arch/arm64/include/asm/preempt.h |  19 +-
 arch/arm64/kernel/entry-common.c |  28 ++-
 arch/x86/Kconfig                 |   2 +-
 arch/x86/include/asm/preempt.h   |  10 +-
 include/linux/entry-common.h     |  15 +-
 include/linux/kernel.h           |   7 +-
 include/linux/sched.h            |  10 +-
 kernel/Kconfig.preempt           |   3 +-
 kernel/entry/common.c            |  23 +-
 kernel/sched/core.c              | 347 ++++++++++++++++++-------------
 12 files changed, 329 insertions(+), 173 deletions(-)
Signature · 1 line
2.30.2