rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rcu/urgent 0/2] Adjust for updated scheduler CPU-affinity semantics
@ 2021-07-14 20:49 Paul E. McKenney
  2021-07-14 20:50 ` [PATCH rcu/urgent 1/2] scftorture: Avoid false-positive warnings in scftorture_invoker() Paul E. McKenney
  2021-07-14 20:50 ` [PATCH rcu/urgent 2/2] refscale: Avoid false-positive warnings in ref_scale_reader() Paul E. McKenney
  0 siblings, 2 replies; 3+ messages in thread
From: Paul E. McKenney @ 2021-07-14 20:49 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, valentin.schneider

Hello!

This series converts smp_processor_id() calls to raw_smp_processor_id()
calls in kthreads that are intended to be bound to a single CPU, but
which are subject to human rebinding.  While in the area, it warns if
set_cpus_allowed_ptr() returns failure.  The patches are as follows:

1.	Avoid false-positive warnings in scftorture_invoker().

2.	Avoid false-positive warnings in ref_scale_reader().

						Thanx, Paul

------------------------------------------------------------------------

 rcu/refscale.c |    6 +++---
 scftorture.c   |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH rcu/urgent 1/2] scftorture: Avoid false-positive warnings in scftorture_invoker()
  2021-07-14 20:49 [PATCH rcu/urgent 0/2] Adjust for updated scheduler CPU-affinity semantics Paul E. McKenney
@ 2021-07-14 20:50 ` Paul E. McKenney
  2021-07-14 20:50 ` [PATCH rcu/urgent 2/2] refscale: Avoid false-positive warnings in ref_scale_reader() Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2021-07-14 20:50 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, valentin.schneider,
	Paul E. McKenney

If the call to set_cpus_allowed_ptr() in scftorture_invoker()
fails, a later WARN_ONCE() complains.  But with the advent of
570a752b7a9b ("lib/smp_processor_id: Use is_percpu_thread() instead of
nr_cpus_allowed"), this complaint can be drowned out by complaints from
smp_processor_id().  The rationale for this change is that scftorture's
kthreads are not marked with PF_NO_SETAFFINITY, which means that a system
administrator could change affinity at any time.

However, scftorture is a torture test, and the system administrator might
well have a valid test-the-test reason for changing affinity.  This commit
therefore changes to raw_smp_processor_id() in order to avoid the noise,
and also adds a WARN_ON_ONCE() to the call to set_cpus_allowed_ptr() in
order to directly detect immediate failure.  There is no WARN_ON_ONCE()
within the test loop, allowing human-reflex-based affinity resetting,
if desired.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/scftorture.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 2377cbb32474..29e8fc5d91a7 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -405,15 +405,15 @@ static int scftorture_invoker(void *arg)
 
 	VERBOSE_SCFTORTOUT("scftorture_invoker %d: task started", scfp->cpu);
 	cpu = scfp->cpu % nr_cpu_ids;
-	set_cpus_allowed_ptr(current, cpumask_of(cpu));
+	WARN_ON_ONCE(set_cpus_allowed_ptr(current, cpumask_of(cpu)));
 	set_user_nice(current, MAX_NICE);
 	if (holdoff)
 		schedule_timeout_interruptible(holdoff * HZ);
 
-	VERBOSE_SCFTORTOUT("scftorture_invoker %d: Waiting for all SCF torturers from cpu %d", scfp->cpu, smp_processor_id());
+	VERBOSE_SCFTORTOUT("scftorture_invoker %d: Waiting for all SCF torturers from cpu %d", scfp->cpu, raw_smp_processor_id());
 
 	// Make sure that the CPU is affinitized appropriately during testing.
-	curcpu = smp_processor_id();
+	curcpu = raw_smp_processor_id();
 	WARN_ONCE(curcpu != scfp->cpu % nr_cpu_ids,
 		  "%s: Wanted CPU %d, running on %d, nr_cpu_ids = %d\n",
 		  __func__, scfp->cpu, curcpu, nr_cpu_ids);
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH rcu/urgent 2/2] refscale: Avoid false-positive warnings in ref_scale_reader()
  2021-07-14 20:49 [PATCH rcu/urgent 0/2] Adjust for updated scheduler CPU-affinity semantics Paul E. McKenney
  2021-07-14 20:50 ` [PATCH rcu/urgent 1/2] scftorture: Avoid false-positive warnings in scftorture_invoker() Paul E. McKenney
@ 2021-07-14 20:50 ` Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2021-07-14 20:50 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, mingo, jiangshanlai, akpm,
	mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells,
	edumazet, fweisbec, oleg, joel, valentin.schneider,
	Paul E. McKenney

If the call to set_cpus_allowed_ptr() in ref_scale_reader()
fails, a later WARN_ONCE() complains.  But with the advent of
570a752b7a9b ("lib/smp_processor_id: Use is_percpu_thread() instead of
nr_cpus_allowed"), this complaint can be drowned out by complaints from
smp_processor_id().  The rationale for this change is that refscale's
kthreads are not marked with PF_NO_SETAFFINITY, which means that a system
administrator could change affinity at any time.

However, refscale is a performance/stress test, and the system
administrator might well have a valid test-the-test reason for changing
affinity.  This commit therefore changes to raw_smp_processor_id()
in order to avoid the noise, and also adds a WARN_ON_ONCE() to the
call to set_cpus_allowed_ptr() in order to directly detect immediate
failure.  There is no WARN_ON_ONCE() within the test loop, allowing
human-reflex-based affinity resetting, if desired.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/refscale.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index 313d4547cbc7..d998a76fb542 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -487,13 +487,13 @@ ref_scale_reader(void *arg)
 	s64 duration;
 
 	VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: task started", me);
-	set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids));
+	WARN_ON_ONCE(set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids)));
 	set_user_nice(current, MAX_NICE);
 	atomic_inc(&n_init);
 	if (holdoff)
 		schedule_timeout_interruptible(holdoff * HZ);
 repeat:
-	VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: waiting to start next experiment on cpu %d", me, smp_processor_id());
+	VERBOSE_SCALEOUT_BATCH("ref_scale_reader %ld: waiting to start next experiment on cpu %d", me, raw_smp_processor_id());
 
 	// Wait for signal that this reader can start.
 	wait_event(rt->wq, (atomic_read(&nreaders_exp) && smp_load_acquire(&rt->start_reader)) ||
@@ -503,7 +503,7 @@ ref_scale_reader(void *arg)
 		goto end;
 
 	// Make sure that the CPU is affinitized appropriately during testing.
-	WARN_ON_ONCE(smp_processor_id() != me);
+	WARN_ON_ONCE(raw_smp_processor_id() != me);
 
 	WRITE_ONCE(rt->start_reader, 0);
 	if (!atomic_dec_return(&n_started))
-- 
2.31.1.189.g2e36527f23


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-14 20:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 20:49 [PATCH rcu/urgent 0/2] Adjust for updated scheduler CPU-affinity semantics Paul E. McKenney
2021-07-14 20:50 ` [PATCH rcu/urgent 1/2] scftorture: Avoid false-positive warnings in scftorture_invoker() Paul E. McKenney
2021-07-14 20:50 ` [PATCH rcu/urgent 2/2] refscale: Avoid false-positive warnings in ref_scale_reader() Paul E. McKenney

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).