From: paulmck@kernel.org
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com,
fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH tip/core/rcu 09/19] scftorture: Add smp_call_function() memory-ordering checks
Date: Mon, 31 Aug 2020 11:07:39 -0700 [thread overview]
Message-ID: <20200831180749.843-9-paulmck@kernel.org> (raw)
In-Reply-To: <20200831180731.GA582@paulmck-ThinkPad-P72>
From: "Paul E. McKenney" <paulmck@kernel.org>
This commit adds checks for memory misordering across calls to and
returns from smp_call_function() in the case where the caller waits.
Misordering results in a splat.
Note that in contrast to smp_call_function_single(), this code does not
test memory ordering into the handler in the no-wait case because none
of the handlers would be able to free the scf_check structure without
introducing heavy synchronization to work out which was last.
[ paulmck: s/GFP_KERNEL/GFP_ATOMIC/ per kernel test robot feedback. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/scftorture.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 3519ad1..0d7299d 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -297,11 +297,13 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
cpus_read_lock();
else
preempt_disable();
- switch (scfsp->scfs_prim) {
- case SCF_PRIM_SINGLE:
+ if (scfsp->scfs_prim == SCF_PRIM_SINGLE || scfsp->scfs_wait) {
scfcp = kmalloc(sizeof(*scfcp), GFP_ATOMIC);
if (WARN_ON_ONCE(!scfcp))
atomic_inc(&n_alloc_errs);
+ }
+ switch (scfsp->scfs_prim) {
+ case SCF_PRIM_SINGLE:
cpu = torture_random(trsp) % nr_cpu_ids;
if (scfsp->scfs_wait)
scfp->n_single_wait++;
@@ -328,11 +330,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
}
break;
case SCF_PRIM_MANY:
- if (scfsp->scfs_wait) {
- scfcp = kmalloc(sizeof(*scfcp), GFP_ATOMIC);
- if (WARN_ON_ONCE(!scfcp))
- atomic_inc(&n_alloc_errs);
- }
if (scfsp->scfs_wait)
scfp->n_many_wait++;
else
@@ -356,7 +353,19 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
scfp->n_all_wait++;
else
scfp->n_all++;
- smp_call_function(scf_handler, NULL, scfsp->scfs_wait);
+ if (scfcp) {
+ scfcp->scfc_cpu = -1;
+ scfcp->scfc_wait = true;
+ scfcp->scfc_out = false;
+ scfcp->scfc_in = true;
+ }
+ smp_call_function(scf_handler, scfcp, scfsp->scfs_wait);
+ if (scfcp) {
+ if (WARN_ON_ONCE(!scfcp->scfc_out))
+ atomic_inc(&n_mb_out_errs); // Leak rather than trash!
+ else
+ kfree(scfcp);
+ }
break;
}
if (use_cpus_read_lock)
--
2.9.5
next prev parent reply other threads:[~2020-08-31 18:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 18:07 [PATCH tip/core/rcu 0/19] New smp_call_function() torture test for v5.10 Paul E. McKenney
2020-08-31 18:07 ` [PATCH tip/core/rcu 01/19] scftorture: Add smp_call_function() torture test paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 02/19] torture: Declare parse-console.sh independence from rcutorture paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 03/19] torture: Add scftorture to the rcutorture scripting paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 04/19] scftorture: Implement weighted primitive selection paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 05/19] tick-sched: Clarify "NOHZ: local_softirq_pending" warning paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 06/19] scftorture: Summarize per-thread statistics paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 07/19] scftorture: Add smp_call_function_single() memory-ordering checks paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 08/19] scftorture: Add smp_call_function_many() " paulmck
2020-08-31 18:07 ` paulmck [this message]
2020-08-31 18:07 ` [PATCH tip/core/rcu 10/19] scftorture: Consolidate scftorture_invoke_one() check and kfree() paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 11/19] scftorture: Consolidate scftorture_invoke_one() scf_check initialization paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 12/19] scftorture: Flag errors in torture-compatible manner paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 13/19] scftorture: Prevent compiler from reducing race probabilities paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 14/19] scftorture: Make symbol 'scf_torture_rand' static paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 15/19] scftorture: Check unexpected "switch" statement value paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 16/19] scftorture: Block scftorture_invoker() kthreads for offline CPUs paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 17/19] scftorture: Adapt memory-ordering test to UP operation paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 18/19] scftorture: Add cond_resched() to test loop paulmck
2020-08-31 18:07 ` [PATCH tip/core/rcu 19/19] rcuperf: Change rcuperf to rcuscale paulmck
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=20200831180749.843-9-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox