* [PATCH 0/1] arm64: enable PREEMPT_LAZY
@ 2025-03-05 10:49 Valentin Schneider
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Valentin Schneider @ 2025-03-05 10:49 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-rt-users
Cc: Catalin Marinas, Will Deacon, Mike Galbraith, Peter Collingbourne,
Mark Rutland, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Sebastian Andrzej Siewior, Petr Tesarik, Jinjie Ruan, Juri Lelli,
Phil Auld
Hey folks,
This is a resubmission of Mark's patch [1]. I didn't end up changing anything
other than fluffing up the changelog.
I ran this under an arm64 VM, added some trace_printk's and checked that
sched_switch's between runnable hackbench threads would occurr in the right
conditions:
o with TIF_NEED_RESCHED_LAZY set
o at the tick
o at do_notify_resume()
o with TIF_NEED_RESCHED set
[1]: https://lore.kernel.org/linux-rt-users/Z2B5y3HiLuRHPfdv@J2N7QTR9R3.cambridge.arm.com/
Cheers,
Valentin
Mark Rutland (1):
arm64: enable PREEMPT_LAZY
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
arch/arm64/kernel/entry-common.c | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 [PATCH 0/1] arm64: enable PREEMPT_LAZY Valentin Schneider
@ 2025-03-05 10:49 ` Valentin Schneider
2025-03-05 11:06 ` Sebastian Andrzej Siewior
` (3 more replies)
2025-03-05 14:03 ` [PATCH 0/1] " Phil Auld
2025-04-29 20:27 ` Will Deacon
2 siblings, 4 replies; 12+ messages in thread
From: Valentin Schneider @ 2025-03-05 10:49 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-rt-users
Cc: Mark Rutland, Mike Galbraith, Catalin Marinas, Will Deacon,
Peter Collingbourne, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Sebastian Andrzej Siewior, Petr Tesarik, Jinjie Ruan, Juri Lelli,
Phil Auld
From: Mark Rutland <mark.rutland@arm.com>
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>
---
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
arch/arm64/kernel/entry-common.c | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index fcdd0ed3eca89..7789d7fb6f191 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -41,6 +41,7 @@ config ARM64
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
+ select ARCH_HAS_PREEMPT_LAZY
select ARCH_HAS_PTE_DEVMAP
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_HW_PTE_YOUNG
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index 1114c1c3300a1..4443ef2789758 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -59,11 +59,12 @@ void arch_setup_new_exec(void);
#define TIF_SIGPENDING 0 /* signal pending */
#define TIF_NEED_RESCHED 1 /* rescheduling necessary */
-#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
-#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
-#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
-#define TIF_MTE_ASYNC_FAULT 5 /* MTE Asynchronous Tag Check Fault */
-#define TIF_NOTIFY_SIGNAL 6 /* signal notifications exist */
+#define TIF_NEED_RESCHED_LAZY 2 /* Lazy rescheduling needed */
+#define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
+#define TIF_FOREIGN_FPSTATE 4 /* CPU's FP state is not current's */
+#define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */
+#define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */
+#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */
#define TIF_SYSCALL_TRACE 8 /* syscall trace active */
#define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
#define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
@@ -85,6 +86,7 @@ void arch_setup_new_exec(void);
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
+#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
@@ -100,10 +102,10 @@ void arch_setup_new_exec(void);
#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
#define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV)
-#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
+#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
_TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
_TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
- _TIF_NOTIFY_SIGNAL)
+ _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING)
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
_TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index b260ddc4d3e9a..7993fab0cab4c 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -132,7 +132,7 @@ static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
do {
local_irq_enable();
- if (thread_flags & _TIF_NEED_RESCHED)
+ if (thread_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
schedule();
if (thread_flags & _TIF_UPROBE)
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
@ 2025-03-05 11:06 ` Sebastian Andrzej Siewior
2025-03-05 12:15 ` Mark Rutland
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-03-05 11:06 UTC (permalink / raw)
To: Valentin Schneider
Cc: linux-arm-kernel, linux-kernel, linux-rt-users, Mark Rutland,
Mike Galbraith, Catalin Marinas, Will Deacon, Peter Collingbourne,
Thomas Gleixner, Neeraj Upadhyay, Thiago Jung Bauermann,
Mark Brown, Kristina Martsenko, Petr Tesarik, Jinjie Ruan,
Juri Lelli, Phil Auld, Clark Williams
On 2025-03-05 11:49:25 [+0100], Valentin Schneider wrote:
> From: Mark Rutland <mark.rutland@arm.com>
>
> 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>
I somehow assumed it was already merged. For what it is worth, this
looks like patch Mike posted in
https://lore.kernel.org/a198a7dd9076f97b89d8882bb249b3bf303564ef.camel@gmx.de
and tested
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Sebastian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
2025-03-05 11:06 ` Sebastian Andrzej Siewior
@ 2025-03-05 12:15 ` Mark Rutland
2025-03-06 12:23 ` Petr Tesarik
2025-03-31 9:07 ` Sebastian Andrzej Siewior
2025-03-05 12:48 ` Thomas Gleixner
2025-05-07 22:51 ` Paul E. McKenney
3 siblings, 2 replies; 12+ messages in thread
From: Mark Rutland @ 2025-03-05 12:15 UTC (permalink / raw)
To: Valentin Schneider, Catalin Marinas, Will Deacon
Cc: linux-arm-kernel, linux-kernel, linux-rt-users, Mike Galbraith,
Peter Collingbourne, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Sebastian Andrzej Siewior, Petr Tesarik, Jinjie Ruan, Juri Lelli,
Phil Auld
On Wed, Mar 05, 2025 at 11:49:25AM +0100, Valentin Schneider wrote:
> From: Mark Rutland <mark.rutland@arm.com>
>
> 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>
> ---
> arch/arm64/Kconfig | 1 +
> arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
> arch/arm64/kernel/entry-common.c | 2 +-
> 3 files changed, 11 insertions(+), 8 deletions(-)
Catalin, Will, given this is small and self-contained, I reckon it makes
sense to pick this up ahead of Jinjie's series to move arm64 over to the
generic entry library (which is on my queue of things to review). Even
if we pick up both, it'll be easier to bisect and debug issues caused by
this patch alone.
The fixes/cleanups from Mike and Valentin look right to me, so FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index fcdd0ed3eca89..7789d7fb6f191 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -41,6 +41,7 @@ config ARM64
> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
> select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
> + select ARCH_HAS_PREEMPT_LAZY
> select ARCH_HAS_PTE_DEVMAP
> select ARCH_HAS_PTE_SPECIAL
> select ARCH_HAS_HW_PTE_YOUNG
> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
> index 1114c1c3300a1..4443ef2789758 100644
> --- a/arch/arm64/include/asm/thread_info.h
> +++ b/arch/arm64/include/asm/thread_info.h
> @@ -59,11 +59,12 @@ void arch_setup_new_exec(void);
>
> #define TIF_SIGPENDING 0 /* signal pending */
> #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
> -#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
> -#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
> -#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
> -#define TIF_MTE_ASYNC_FAULT 5 /* MTE Asynchronous Tag Check Fault */
> -#define TIF_NOTIFY_SIGNAL 6 /* signal notifications exist */
> +#define TIF_NEED_RESCHED_LAZY 2 /* Lazy rescheduling needed */
> +#define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
> +#define TIF_FOREIGN_FPSTATE 4 /* CPU's FP state is not current's */
> +#define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */
> +#define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */
> +#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */
> #define TIF_SYSCALL_TRACE 8 /* syscall trace active */
> #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
> #define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
> @@ -85,6 +86,7 @@ void arch_setup_new_exec(void);
>
> #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
> #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
> +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
> #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
> #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
> #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
> @@ -100,10 +102,10 @@ void arch_setup_new_exec(void);
> #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
> #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV)
>
> -#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
> +#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
> _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
> _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
> - _TIF_NOTIFY_SIGNAL)
> + _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING)
>
> #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index b260ddc4d3e9a..7993fab0cab4c 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -132,7 +132,7 @@ static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
> do {
> local_irq_enable();
>
> - if (thread_flags & _TIF_NEED_RESCHED)
> + if (thread_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
> schedule();
>
> if (thread_flags & _TIF_UPROBE)
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
2025-03-05 11:06 ` Sebastian Andrzej Siewior
2025-03-05 12:15 ` Mark Rutland
@ 2025-03-05 12:48 ` Thomas Gleixner
2025-05-07 22:51 ` Paul E. McKenney
3 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2025-03-05 12:48 UTC (permalink / raw)
To: Valentin Schneider, linux-arm-kernel, linux-kernel,
linux-rt-users
Cc: Mark Rutland, Mike Galbraith, Catalin Marinas, Will Deacon,
Peter Collingbourne, Neeraj Upadhyay, Thiago Jung Bauermann,
Mark Brown, Kristina Martsenko, Sebastian Andrzej Siewior,
Petr Tesarik, Jinjie Ruan, Juri Lelli, Phil Auld
On Wed, Mar 05 2025 at 11:49, Valentin Schneider wrote:
> From: Mark Rutland <mark.rutland@arm.com>
>
> 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>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 [PATCH 0/1] arm64: enable PREEMPT_LAZY Valentin Schneider
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
@ 2025-03-05 14:03 ` Phil Auld
2025-04-29 20:27 ` Will Deacon
2 siblings, 0 replies; 12+ messages in thread
From: Phil Auld @ 2025-03-05 14:03 UTC (permalink / raw)
To: Valentin Schneider
Cc: linux-arm-kernel, linux-kernel, linux-rt-users, Catalin Marinas,
Will Deacon, Mike Galbraith, Peter Collingbourne, Mark Rutland,
Thomas Gleixner, Neeraj Upadhyay, Thiago Jung Bauermann,
Mark Brown, Kristina Martsenko, Sebastian Andrzej Siewior,
Petr Tesarik, Jinjie Ruan, Juri Lelli
On Wed, Mar 05, 2025 at 11:49:24AM +0100 Valentin Schneider wrote:
> Hey folks,
>
> This is a resubmission of Mark's patch [1]. I didn't end up changing anything
> other than fluffing up the changelog.
>
> I ran this under an arm64 VM, added some trace_printk's and checked that
> sched_switch's between runnable hackbench threads would occurr in the right
> conditions:
> o with TIF_NEED_RESCHED_LAZY set
> o at the tick
> o at do_notify_resume()
> o with TIF_NEED_RESCHED set
>
> [1]: https://lore.kernel.org/linux-rt-users/Z2B5y3HiLuRHPfdv@J2N7QTR9R3.cambridge.arm.com/
>
Thanks! I was looking for this the other day :)
Cheers,
Phil
> Cheers,
> Valentin
>
> Mark Rutland (1):
> arm64: enable PREEMPT_LAZY
>
> arch/arm64/Kconfig | 1 +
> arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
> arch/arm64/kernel/entry-common.c | 2 +-
> 3 files changed, 11 insertions(+), 8 deletions(-)
>
> --
> 2.43.0
>
--
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 12:15 ` Mark Rutland
@ 2025-03-06 12:23 ` Petr Tesarik
2025-03-31 9:07 ` Sebastian Andrzej Siewior
1 sibling, 0 replies; 12+ messages in thread
From: Petr Tesarik @ 2025-03-06 12:23 UTC (permalink / raw)
To: Mark Rutland
Cc: Valentin Schneider, Catalin Marinas, Will Deacon,
linux-arm-kernel, linux-kernel, linux-rt-users, Mike Galbraith,
Peter Collingbourne, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Sebastian Andrzej Siewior, Jinjie Ruan, Juri Lelli, Phil Auld
On Wed, 5 Mar 2025 12:15:35 +0000
Mark Rutland <mark.rutland@arm.com> wrote:
> On Wed, Mar 05, 2025 at 11:49:25AM +0100, Valentin Schneider wrote:
> > From: Mark Rutland <mark.rutland@arm.com>
> >
> > 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>
> > ---
> > arch/arm64/Kconfig | 1 +
> > arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
> > arch/arm64/kernel/entry-common.c | 2 +-
> > 3 files changed, 11 insertions(+), 8 deletions(-)
>
> Catalin, Will, given this is small and self-contained, I reckon it makes
> sense to pick this up ahead of Jinjie's series to move arm64 over to the
> generic entry library (which is on my queue of things to review). Even
> if we pick up both, it'll be easier to bisect and debug issues caused by
> this patch alone.
>
> The fixes/cleanups from Mike and Valentin look right to me, so FWIW:
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
Thank you, all. Much appreciated.
Petr T
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 12:15 ` Mark Rutland
2025-03-06 12:23 ` Petr Tesarik
@ 2025-03-31 9:07 ` Sebastian Andrzej Siewior
2025-04-29 12:45 ` Will Deacon
1 sibling, 1 reply; 12+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-03-31 9:07 UTC (permalink / raw)
To: Mark Rutland
Cc: Valentin Schneider, Catalin Marinas, Will Deacon,
linux-arm-kernel, linux-kernel, linux-rt-users, Mike Galbraith,
Peter Collingbourne, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Petr Tesarik, Jinjie Ruan, Juri Lelli, Phil Auld
On 2025-03-05 12:15:35 [+0000], Mark Rutland wrote:
> Catalin, Will, given this is small and self-contained, I reckon it makes
> sense to pick this up ahead of Jinjie's series to move arm64 over to the
> generic entry library (which is on my queue of things to review). Even
> if we pick up both, it'll be easier to bisect and debug issues caused by
> this patch alone.
Any updates here? I know it is the merge window but I don't know if
upstream considers this or wants to sit on it until the generic entry
gets in.
In the meantime I stuff it into my RT tree so it does not get lost.
> Mark.
Sebastian
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-31 9:07 ` Sebastian Andrzej Siewior
@ 2025-04-29 12:45 ` Will Deacon
0 siblings, 0 replies; 12+ messages in thread
From: Will Deacon @ 2025-04-29 12:45 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Mark Rutland, Valentin Schneider, Catalin Marinas,
linux-arm-kernel, linux-kernel, linux-rt-users, Mike Galbraith,
Peter Collingbourne, Thomas Gleixner, Neeraj Upadhyay,
Thiago Jung Bauermann, Mark Brown, Kristina Martsenko,
Petr Tesarik, Jinjie Ruan, Juri Lelli, Phil Auld
On Mon, Mar 31, 2025 at 11:07:56AM +0200, Sebastian Andrzej Siewior wrote:
> On 2025-03-05 12:15:35 [+0000], Mark Rutland wrote:
> > Catalin, Will, given this is small and self-contained, I reckon it makes
> > sense to pick this up ahead of Jinjie's series to move arm64 over to the
> > generic entry library (which is on my queue of things to review). Even
> > if we pick up both, it'll be easier to bisect and debug issues caused by
> > this patch alone.
>
> Any updates here? I know it is the merge window but I don't know if
> upstream considers this or wants to sit on it until the generic entry
> gets in.
> In the meantime I stuff it into my RT tree so it does not get lost.
Sorry for the delay; I'll pick this up in the arm64 tree today.
Will
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 [PATCH 0/1] arm64: enable PREEMPT_LAZY Valentin Schneider
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
2025-03-05 14:03 ` [PATCH 0/1] " Phil Auld
@ 2025-04-29 20:27 ` Will Deacon
2025-04-30 8:38 ` Petr Tesarik
2 siblings, 1 reply; 12+ messages in thread
From: Will Deacon @ 2025-04-29 20:27 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-rt-users,
Valentin Schneider
Cc: catalin.marinas, kernel-team, Will Deacon, Mike Galbraith,
Peter Collingbourne, Mark Rutland, Thomas Gleixner,
Neeraj Upadhyay, Thiago Jung Bauermann, Mark Brown,
Kristina Martsenko, Sebastian Andrzej Siewior, Petr Tesarik,
Jinjie Ruan, Juri Lelli, Phil Auld
On Wed, 05 Mar 2025 11:49:24 +0100, Valentin Schneider wrote:
> Hey folks,
>
> This is a resubmission of Mark's patch [1]. I didn't end up changing anything
> other than fluffing up the changelog.
>
> I ran this under an arm64 VM, added some trace_printk's and checked that
> sched_switch's between runnable hackbench threads would occurr in the right
> conditions:
> o with TIF_NEED_RESCHED_LAZY set
> o at the tick
> o at do_notify_resume()
> o with TIF_NEED_RESCHED set
>
> [...]
Applied to arm64 (for-next/entry), thanks!
[1/1] arm64: enable PREEMPT_LAZY
https://git.kernel.org/arm64/c/c8597e2dd8b6
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/1] arm64: enable PREEMPT_LAZY
2025-04-29 20:27 ` Will Deacon
@ 2025-04-30 8:38 ` Petr Tesarik
0 siblings, 0 replies; 12+ messages in thread
From: Petr Tesarik @ 2025-04-30 8:38 UTC (permalink / raw)
To: Will Deacon
Cc: linux-arm-kernel, linux-kernel, linux-rt-users,
Valentin Schneider, catalin.marinas, kernel-team, Mike Galbraith,
Peter Collingbourne, Mark Rutland, Thomas Gleixner,
Neeraj Upadhyay, Thiago Jung Bauermann, Mark Brown,
Kristina Martsenko, Sebastian Andrzej Siewior, Jinjie Ruan,
Juri Lelli, Phil Auld
On Tue, 29 Apr 2025 21:27:52 +0100
Will Deacon <will@kernel.org> wrote:
> On Wed, 05 Mar 2025 11:49:24 +0100, Valentin Schneider wrote:
> > Hey folks,
> >
> > This is a resubmission of Mark's patch [1]. I didn't end up changing anything
> > other than fluffing up the changelog.
> >
> > I ran this under an arm64 VM, added some trace_printk's and checked that
> > sched_switch's between runnable hackbench threads would occurr in the right
> > conditions:
> > o with TIF_NEED_RESCHED_LAZY set
> > o at the tick
> > o at do_notify_resume()
> > o with TIF_NEED_RESCHED set
> >
> > [...]
>
> Applied to arm64 (for-next/entry), thanks!
>
> [1/1] arm64: enable PREEMPT_LAZY
> https://git.kernel.org/arm64/c/c8597e2dd8b6
Great news. Thank you!
Petr T
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/1] arm64: enable PREEMPT_LAZY
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
` (2 preceding siblings ...)
2025-03-05 12:48 ` Thomas Gleixner
@ 2025-05-07 22:51 ` Paul E. McKenney
3 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2025-05-07 22:51 UTC (permalink / raw)
To: Valentin Schneider
Cc: linux-arm-kernel, linux-kernel, linux-rt-users, Mark Rutland,
Mike Galbraith, Catalin Marinas, Will Deacon, Peter Collingbourne,
Thomas Gleixner, Neeraj Upadhyay, Thiago Jung Bauermann,
Mark Brown, Kristina Martsenko, Sebastian Andrzej Siewior,
Petr Tesarik, Jinjie Ruan, Juri Lelli, Phil Auld
On Wed, Mar 05, 2025 at 11:49:25AM +0100, Valentin Schneider wrote:
> From: Mark Rutland <mark.rutland@arm.com>
>
> 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>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Nice! This gets rid of the .config complaints that you otherwise get
when running the rcutorture TREE07 scenario on arm64:
Tested-by: Paul E. McKenney <paulmck@kernel.org>
> ---
> arch/arm64/Kconfig | 1 +
> arch/arm64/include/asm/thread_info.h | 16 +++++++++-------
> arch/arm64/kernel/entry-common.c | 2 +-
> 3 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index fcdd0ed3eca89..7789d7fb6f191 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -41,6 +41,7 @@ config ARM64
> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
> select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
> + select ARCH_HAS_PREEMPT_LAZY
> select ARCH_HAS_PTE_DEVMAP
> select ARCH_HAS_PTE_SPECIAL
> select ARCH_HAS_HW_PTE_YOUNG
> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
> index 1114c1c3300a1..4443ef2789758 100644
> --- a/arch/arm64/include/asm/thread_info.h
> +++ b/arch/arm64/include/asm/thread_info.h
> @@ -59,11 +59,12 @@ void arch_setup_new_exec(void);
>
> #define TIF_SIGPENDING 0 /* signal pending */
> #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
> -#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
> -#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
> -#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
> -#define TIF_MTE_ASYNC_FAULT 5 /* MTE Asynchronous Tag Check Fault */
> -#define TIF_NOTIFY_SIGNAL 6 /* signal notifications exist */
> +#define TIF_NEED_RESCHED_LAZY 2 /* Lazy rescheduling needed */
> +#define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
> +#define TIF_FOREIGN_FPSTATE 4 /* CPU's FP state is not current's */
> +#define TIF_UPROBE 5 /* uprobe breakpoint or singlestep */
> +#define TIF_MTE_ASYNC_FAULT 6 /* MTE Asynchronous Tag Check Fault */
> +#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */
> #define TIF_SYSCALL_TRACE 8 /* syscall trace active */
> #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
> #define TIF_SYSCALL_TRACEPOINT 10 /* syscall tracepoint for ftrace */
> @@ -85,6 +86,7 @@ void arch_setup_new_exec(void);
>
> #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
> #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
> +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
> #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
> #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
> #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
> @@ -100,10 +102,10 @@ void arch_setup_new_exec(void);
> #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
> #define _TIF_TSC_SIGSEGV (1 << TIF_TSC_SIGSEGV)
>
> -#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
> +#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY | \
> _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
> _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT | \
> - _TIF_NOTIFY_SIGNAL)
> + _TIF_NOTIFY_SIGNAL | _TIF_SIGPENDING)
>
> #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
> _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index b260ddc4d3e9a..7993fab0cab4c 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -132,7 +132,7 @@ static void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags)
> do {
> local_irq_enable();
>
> - if (thread_flags & _TIF_NEED_RESCHED)
> + if (thread_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
> schedule();
>
> if (thread_flags & _TIF_UPROBE)
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-05-07 22:53 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 10:49 [PATCH 0/1] arm64: enable PREEMPT_LAZY Valentin Schneider
2025-03-05 10:49 ` [PATCH 1/1] " Valentin Schneider
2025-03-05 11:06 ` Sebastian Andrzej Siewior
2025-03-05 12:15 ` Mark Rutland
2025-03-06 12:23 ` Petr Tesarik
2025-03-31 9:07 ` Sebastian Andrzej Siewior
2025-04-29 12:45 ` Will Deacon
2025-03-05 12:48 ` Thomas Gleixner
2025-05-07 22:51 ` Paul E. McKenney
2025-03-05 14:03 ` [PATCH 0/1] " Phil Auld
2025-04-29 20:27 ` Will Deacon
2025-04-30 8:38 ` Petr Tesarik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).