All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: ardb@kernel.org, bp@alien8.de, catalin.marinas@arm.com,
	dave.hansen@linux.intel.com, frederic@kernel.org,
	james.morse@arm.com, joey.gouly@arm.com, juri.lelli@redhat.com,
	linux-kernel@vger.kernel.org, luto@kernel.org,
	mark.rutland@arm.com, mingo@redhat.com, peterz@infradead.org,
	tglx@linutronix.de, valentin.schneider@arm.com, will@kernel.org
Subject: [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys
Date: Wed,  9 Feb 2022 15:35:28 +0000	[thread overview]
Message-ID: <20220209153535.818830-1-mark.rutland@arm.com> (raw)

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

[1] https://lore.kernel.org/r/20211109172408.49641-1-mark.rutland@arm.com/
[2] https://lore.kernel.org/r/20220204150557.434610-1-mark.rutland@arm.com/

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 premeption 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/entry/common.c            |  23 +-
 kernel/sched/core.c              | 347 ++++++++++++++++++-------------
 11 files changed, 327 insertions(+), 172 deletions(-)

-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: ardb@kernel.org, bp@alien8.de, catalin.marinas@arm.com,
	dave.hansen@linux.intel.com, frederic@kernel.org,
	james.morse@arm.com, joey.gouly@arm.com, juri.lelli@redhat.com,
	linux-kernel@vger.kernel.org, luto@kernel.org,
	mark.rutland@arm.com, mingo@redhat.com, peterz@infradead.org,
	tglx@linutronix.de, valentin.schneider@arm.com, will@kernel.org
Subject: [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys
Date: Wed,  9 Feb 2022 15:35:28 +0000	[thread overview]
Message-ID: <20220209153535.818830-1-mark.rutland@arm.com> (raw)

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

[1] https://lore.kernel.org/r/20211109172408.49641-1-mark.rutland@arm.com/
[2] https://lore.kernel.org/r/20220204150557.434610-1-mark.rutland@arm.com/

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 premeption 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/entry/common.c            |  23 +-
 kernel/sched/core.c              | 347 ++++++++++++++++++-------------
 11 files changed, 327 insertions(+), 172 deletions(-)

-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2022-02-09 15:36 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 15:35 Mark Rutland [this message]
2022-02-09 15:35 ` [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys Mark Rutland
2022-02-09 15:35 ` [PATCH v3 1/7] sched/preempt: move PREEMPT_DYNAMIC logic later Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 15:35 ` [PATCH v3 2/7] sched/preempt: refactor sched_dynamic_update() Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 15:35 ` [PATCH v3 3/7] sched/preempt: simplify irqentry_exit_cond_resched() callers Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 15:35 ` [PATCH v3 4/7] sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRY Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 15:35 ` [PATCH v3 5/7] sched/preempt: add PREEMPT_DYNAMIC using static keys Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 17:48   ` Frederic Weisbecker
2022-02-09 17:48     ` Frederic Weisbecker
2022-02-10 10:27     ` Mark Rutland
2022-02-10 10:27       ` Mark Rutland
2022-02-10 15:59       ` Frederic Weisbecker
2022-02-10 15:59         ` Frederic Weisbecker
2022-02-09 15:35 ` [PATCH v3 6/7] arm64: entry: centralize premeption decision Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 18:10   ` Catalin Marinas
2022-02-09 18:10     ` Catalin Marinas
2022-02-10  9:19     ` Mark Rutland
2022-02-10  9:19       ` Mark Rutland
2022-02-09 15:35 ` [PATCH v3 7/7] arm64: support PREEMPT_DYNAMIC Mark Rutland
2022-02-09 15:35   ` Mark Rutland
2022-02-09 18:13   ` Catalin Marinas
2022-02-09 18:13     ` Catalin Marinas
2022-02-09 19:57   ` Frederic Weisbecker
2022-02-09 19:57     ` Frederic Weisbecker
2022-02-10  9:38     ` Mark Rutland
2022-02-10  9:38       ` Mark Rutland
2022-02-10 12:00       ` Mark Rutland
2022-02-10 12:00         ` Mark Rutland
2022-02-10 15:58         ` Frederic Weisbecker
2022-02-10 15:58           ` Frederic Weisbecker
2022-02-09 19:58 ` [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys Frederic Weisbecker
2022-02-09 19:58   ` Frederic Weisbecker
2022-02-10  9:29 ` Ard Biesheuvel
2022-02-10  9:29   ` Ard Biesheuvel

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=20220209153535.818830-1-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=frederic@kernel.org \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=valentin.schneider@arm.com \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.