Skip to contentSkip to conversation

rcu,sched: noinstr fixes

PATCH Applied Peter Zijlstra 4 participants 12 messages Sep 28, 2021 – Oct 1, 2021

Subsystems (2)
lore
Share & tools
lore

Peter Zijlstra

author maintainer
#0 lore raw

cover rcu,sched: noinstr fixes

A few noinstr fixes.. I'll stick the sched one in sched/urgent, Paul could you pick up the other two?

author maintainer
#1 lore raw

PATCH 1/3 rcu: Always inline rcu_dynticks_task*_{enter,exit}()

RCU managed to grow a few noinstr violations:

vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter() leaves .noinstr.text section vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit() leaves .noinstr.text section

Fix them by adding __always_inline to the relevant trivial functions.

Also replace the noinstr with __always_inline for the existing rcu_dynticks_task_*() functions since noinstr would force noinline them, even when empty, which seems silly.

Fixes 7d0c9c50c5a1 ("rcu-tasks: Avoid IPIing userspace/idle tasks if kernel is so built")
---
 kernel/rcu/tree_plugin.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/tree_plugin.h +4 -4
@@ -1479,7 +1479,7 @@ static void rcu_bind_gp_kthread(void)
 }
 
 /* Record the current task on dyntick-idle entry. */
-static void noinstr rcu_dynticks_task_enter(void)
+static __always_inline void rcu_dynticks_task_enter(void)
 {
 #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
 	WRITE_ONCE(current->rcu_tasks_idle_cpu, smp_processor_id());
@@ -1487,7 +1487,7 @@ static void noinstr rcu_dynticks_task_en
 }
 
 /* Record no current task on dyntick-idle exit. */
-static void noinstr rcu_dynticks_task_exit(void)
+static __always_inline void rcu_dynticks_task_exit(void)
 {
 #if defined(CONFIG_TASKS_RCU) && defined(CONFIG_NO_HZ_FULL)
 	WRITE_ONCE(current->rcu_tasks_idle_cpu, -1);
@@ -1495,7 +1495,7 @@ static void noinstr rcu_dynticks_task_ex
 }
 
 /* Turn on heavyweight RCU tasks trace readers on idle/user entry. */
-static void rcu_dynticks_task_trace_enter(void)
+static __always_inline void rcu_dynticks_task_trace_enter(void)
 {
 #ifdef CONFIG_TASKS_TRACE_RCU
 	if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
@@ -1504,7 +1504,7 @@ static void rcu_dynticks_task_trace_ente
 }
 
 /* Turn off heavyweight RCU tasks trace readers on idle/user exit. */
-static void rcu_dynticks_task_trace_exit(void)
+static __always_inline void rcu_dynticks_task_trace_exit(void)
 {
 #ifdef CONFIG_TASKS_TRACE_RCU
 	if (IS_ENABLED(CONFIG_TASKS_TRACE_RCU_READ_MB))
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] rcu: Always inline rcu_dynticks_task*_{enter,exit}()

Quoted 7 lines · Peter Zijlstra

RCU managed to grow a few noinstr violations:

vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter() leaves .noinstr.text section vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit() leaves .noinstr.text section

Fix them by adding __always_inline to the relevant trivial functions.

Quoted 7 lines

Also replace the noinstr with __always_inline for the existing rcu_dynticks_task_*() functions since noinstr would force noinline them, even when empty, which seems silly.

Fixes 7d0c9c50c5a1 ("rcu-tasks: Avoid IPIing userspace/idle tasks if kernel is so built")
maintainer
#3 lore raw

Re: [PATCH 1/3] rcu: Always inline rcu_dynticks_task*_{enter,exit}()

Quoted 13 lines · Thomas Gleixner
Quoted 11 lines · Peter Zijlstra

RCU managed to grow a few noinstr violations:

vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter() leaves .noinstr.text section vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit() leaves .noinstr.text section

Fix them by adding __always_inline to the relevant trivial functions.

Also replace the noinstr with __always_inline for the existing rcu_dynticks_task_*() functions since noinstr would force noinline them, even when empty, which seems silly.

Quoted 5 lines
Quoted 3 lines
Fixes 7d0c9c50c5a1 ("rcu-tasks: Avoid IPIing userspace/idle tasks if kernel is so built")

Thank you! I will apply to the pair of RCU commits at the next rebase.

Thanx, Paul

author maintainer
#4 lore raw

PATCH 2/3 rcu: Fix rcu_dynticks_curr_cpu_in_eqs() vs noinstr

In reply to Peter Zijlstra

vmlinux.o: warning: objtool: rcu_nmi_enter()+0x36: call to __kasan_check_read() leaves .noinstr.text section

noinstr cannot have atomic_*() functions in because they're explicitly annotated, use arch_atomic_*().

Fixes 2be57f732889 ("rcu: Weaken ->dynticks accesses and updates")
---
 kernel/rcu/tree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree.c +1 -1
@@ -327,7 +327,7 @@ static void rcu_dynticks_eqs_online(void
  */
 static __always_inline bool rcu_dynticks_curr_cpu_in_eqs(void)
 {
-	return !(atomic_read(this_cpu_ptr(&rcu_data.dynticks)) & 0x1);
+	return !(arch_atomic_read(this_cpu_ptr(&rcu_data.dynticks)) & 0x1);
 }
 
 /*
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] rcu: Fix rcu_dynticks_curr_cpu_in_eqs() vs noinstr

Quoted 8 lines · Peter Zijlstra

vmlinux.o: warning: objtool: rcu_nmi_enter()+0x36: call to __kasan_check_read() leaves .noinstr.text section

noinstr cannot have atomic_*() functions in because they're explicitly annotated, use arch_atomic_*().

Fixes 2be57f732889 ("rcu: Weaken ->dynticks accesses and updates")
author maintainer
#6 lore raw

PATCH 3/3 sched: Always inline is_percpu_thread()

In reply to Peter Zijlstra

vmlinux.o: warning: objtool: check_preemption_disabled()+0x81: call to is_percpu_thread() leaves .noinstr.text section

---
 include/linux/sched.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
@@ -1730,7 +1730,7 @@ extern struct pid *cad_pid;
 #define tsk_used_math(p)			((p)->flags & PF_USED_MATH)
 #define used_math()				tsk_used_math(current)
 
-static inline bool is_percpu_thread(void)
+static __always_inline bool is_percpu_thread(void)
 {
 #ifdef CONFIG_SMP
 	return (current->flags & PF_NO_SETAFFINITY) &&
merge bot Applied
#8 lore raw

[tip: sched/urgent] sched: Always inline is_percpu_thread()

In reply to Peter Zijlstra
The following commit has been merged into the sched/urgent branch of tip:

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     83d40a61046f73103b4e5d8f1310261487ff63b0
Gitweb:        https://git.kernel.org/tip/83d40a61046f73103b4e5d8f1310261487ff63b0
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 20 Sep 2021 15:31:11 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 01 Oct 2021 13:57:57 +02:00

sched: Always inline is_percpu_thread()

vmlinux.o: warning: objtool: check_preemption_disabled()+0x81: call to is_percpu_thread() leaves .noinstr.text section

---
 include/linux/sched.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
index 39039ce..c1a927d 100644
@@ -1720,7 +1720,7 @@ extern struct pid *cad_pid;
 #define tsk_used_math(p)			((p)->flags & PF_USED_MATH)
 #define used_math()				tsk_used_math(current)
 
-static inline bool is_percpu_thread(void)
+static __always_inline bool is_percpu_thread(void)
 {
 #ifdef CONFIG_SMP
 	return (current->flags & PF_NO_SETAFFINITY) &&
maintainer Applied
#9 lore raw
In reply to Peter Zijlstra
Quoted 1 line · Peter Zijlstra

A few noinstr fixes.. I'll stick the sched one in sched/urgent, Paul could you pick up the other two?

I queued those two, thank you! I am guessing that you are looking for me to send them ASAP. If so, not a problem, but please confirm.

After all, yes, these are simple and low-risk, but in the absence of any need to hurry them, extended testing is even lower risk. ;-)

Thanx, Paul

author maintainer
#10 lore raw
Quoted 5 lines · Paul E. McKenney
Quoted 1 line · Peter Zijlstra

A few noinstr fixes.. I'll stick the sched one in sched/urgent, Paul could you pick up the other two?

I queued those two, thank you! I am guessing that you are looking for me to send them ASAP. If so, not a problem, but please confirm.

Either way works, but given syzcaller could potentially trigger these holes (it did find a whole bunch of 'interesting' problems in the early noinstr days) I'd prefer them earlier rather than later.

OTOH, the objtool patches that keep triggering them all over the place are still in objtool/core for the next cycle.

maintainer
#11 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 5 lines · Paul E. McKenney
Quoted 1 line · Peter Zijlstra

A few noinstr fixes.. I'll stick the sched one in sched/urgent, Paul could you pick up the other two?

I queued those two, thank you! I am guessing that you are looking for me to send them ASAP. If so, not a problem, but please confirm.

Quoted 6 lines

Either way works, but given syzcaller could potentially trigger these holes (it did find a whole bunch of 'interesting' problems in the early noinstr days) I'd prefer them earlier rather than later.

OTOH, the objtool patches that keep triggering them all over the place are still in objtool/core for the next cycle.

OK, let's split the difference, then. Instead of the default v5.17 merge window, I will submit them to the upcoming v5.16 merge window.

Thanx, Paul