Skip to content

Commit c8597e2

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: enable PREEMPT_LAZY
For an architecture to enable CONFIG_ARCH_HAS_RESCHED_LAZY, two things are required: 1) Adding a TIF_NEED_RESCHED_LAZY flag definition 2) Checking for TIF_NEED_RESCHED_LAZY in the appropriate locations 2) is handled in a generic manner by CONFIG_GENERIC_ENTRY, which isn't (yet) implemented for arm64. However, outside of core scheduler code, TIF_NEED_RESCHED_LAZY only needs to be checked on a kernel exit, meaning: o return/entry to userspace. o return/entry to guest. The return/entry to a guest is all handled by xfer_to_guest_mode_handle_work() which already does the right thing, so it can be left as-is. arm64 doesn't use common entry's exit_to_user_mode_prepare(), so update its return to user path to check for TIF_NEED_RESCHED_LAZY and call into schedule() accordingly. Link: https://lore.kernel.org/linux-rt-users/20241216190451.1c61977c@mordecai.tesarici.cz/ Link: https://lore.kernel.org/all/xhsmh4j0fl0p3.mognet@vschneid-thinkpadt14sgen2i.remote.csb/ Signed-off-by: Mark Rutland <mark.rutland@arm.com> [testdrive, _TIF_WORK_MASK fixlet and changelog.] Signed-off-by: Mike Galbraith <efault@gmx.de> [Another round of testing; changelog faff] Signed-off-by: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://lore.kernel.org/r/20250305104925.189198-2-vschneid@redhat.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 0af2f6b commit c8597e2

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ config ARM64
4242
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
4343
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
4444
select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
45+
select ARCH_HAS_PREEMPT_LAZY
4546
select ARCH_HAS_PTDUMP
4647
select ARCH_HAS_PTE_DEVMAP
4748
select ARCH_HAS_PTE_SPECIAL

arch/arm64/include/asm/thread_info.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ void arch_setup_new_exec(void);
5959

6060
#define TIF_SIGPENDING 0 /* signal pending */
6161
#define TIF_NEED_RESCHED 1 /* rescheduling necessary */
62-
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
63-
#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
64-
#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
65-
#define TIF_MTE_ASYNC_FAULT 5 /* MTE Asynchronous Tag Check Fault */
66-
#define TIF_NOTIFY_SIGNAL 6 /* signal notifications exist */
62+
#define TIF_NEED_RESCHED_LAZY 2 /* Lazy rescheduling needed */
63+
#define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
64+
#define TIF_FOREIGN_FPSTATE 4 /* CPU's FP state is not current's */
65+
#define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */
66+
#define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */
67+
#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */
6768
#define TIF_SYSCALL_TRACE 8 /* syscall trace active */
6869
#define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
6970
#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
@@ -85,6 +86,7 @@ void arch_setup_new_exec(void);
8586

8687
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
8788
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
89+
#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
8890
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
8991
#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
9092
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
@@ -100,10 +102,10 @@ void arch_setup_new_exec(void);
100102
#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
101103
#define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV)
102104

103-
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
105+
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
104106
_TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
105107
_TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
106-
_TIF_NOTIFY_SIGNAL)
108+
_TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING)
107109

108110
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
109111
_TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \

arch/arm64/kernel/entry-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
132132
do {
133133
local_irq_enable();
134134

135-
if (thread_flags & _TIF_NEED_RESCHED)
135+
if (thread_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
136136
schedule();
137137

138138
if (thread_flags & _TIF_UPROBE)

0 commit comments

Comments
 (0)