From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>,
linux-kernel@vger.kernel.org, mingo@elte.hu, dipankar@in.ibm.com,
akpm@linux-foundation.org, josh@joshtriplett.org, niv@us.ibm.com,
tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
dhowells@redhat.com, edumazet@google.com, darren@dvhart.com,
fweisbec@gmail.com, sbw@mit.edu,
Sedat Dilek <sedat.dilek@gmail.com>,
Davidlohr Bueso <davidlohr.bueso@hp.com>,
Rik van Riel <riel@surriel.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH tip/core/rcu 1/5] rcu: Add duplicate-callback tests to rcutorture
Date: Sat, 24 Aug 2013 15:25:36 -0400 [thread overview]
Message-ID: <20130824192536.GE13216@Krystal> (raw)
In-Reply-To: <20130820183843.GK29406@linux.vnet.ibm.com>
* Paul E. McKenney (paulmck@linux.vnet.ibm.com) wrote:
[...]
> The result is as follows. Better?
Hi Paul,
Pitching in late in the thread, so that I can get a share of the fun ;-)
> Thanx, Paul
>
> #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
> static void rcu_torture_leak_cb(struct rcu_head *rhp)
> {
> }
>
> static void rcu_torture_err_cb(struct rcu_head *rhp)
> {
> /*
> * This -might- happen due to race conditions, but is unlikely.
> * The scenario that leads to this happening is that the
> * first of the pair of duplicate callbacks is queued,
> * someone else starts a grace period that includes that
> * callback, then the second of the pair must wait for the
> * next grace period. Unlikely, but can happen. If it
> * does happen, the debug-objects subsystem won't have splatted.
> */
> pr_alert("rcutorture: duplicated callback was invoked.\n");
> }
> #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
>
Hrm. Putting an #ifdef within a function when not utterly needed is
usually a bad idea. How about:
/*
* Verify that double-free causes debug-objects to complain, but only
* if CONFIG_DEBUG_OBJECTS_RCU_HEAD=y. Otherwise, say that the test
* cannot be carried out.
*/
#ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
static void rcu_test_debug_objects(void)
{
struct rcu_head rh1;
struct rcu_head rh2;
init_rcu_head_on_stack(&rh1);
init_rcu_head_on_stack(&rh2);
pr_alert("rcutorture: WARN: Duplicate call_rcu() test starting.\n");
preempt_disable(); /* Prevent preemption from interrupting test. */
rcu_read_lock(); /* Make it impossible to finish a grace period. */
call_rcu(&rh1, rcu_torture_leak_cb); /* Start grace period. */
local_irq_disable(); /* Make it harder to start a new grace period. */
call_rcu(&rh2, rcu_torture_leak_cb);
call_rcu(&rh2, rcu_torture_err_cb); /* Duplicate callback. */
local_irq_enable();
rcu_read_unlock();
preempt_enable();
rcu_barrier();
pr_alert("rcutorture: WARN: Duplicate call_rcu() test complete.\n");
destroy_rcu_head_on_stack(&rh1);
destroy_rcu_head_on_stack(&rh2);
}
#else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
static void rcu_test_debug_objects(void)
{
pr_alert("rcutorture: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n");
}
#endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
More comments inlined in the code below,
> /*
> * Verify that double-free causes debug-objects to complain, but only
> * if CONFIG_DEBUG_OBJECTS_RCU_HEAD=y. Otherwise, say that the test
> * cannot be carried out.
> */
> static void rcu_test_debug_objects(void)
> {
> #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
> struct rcu_head rh1;
> struct rcu_head rh2;
>
> init_rcu_head_on_stack(&rh1);
> init_rcu_head_on_stack(&rh2);
> pr_alert("rcutorture: WARN: Duplicate call_rcu() test starting.\n");
> preempt_disable(); /* Prevent preemption from interrupting test. */
> rcu_read_lock(); /* Make it impossible to finish a grace period. */
> call_rcu(&rh1, rcu_torture_leak_cb); /* Start grace period. */
Are we really "starting" a grace period ? If rcu_test_debug_objects() is
executed after some callbacks are already queued, are we, by definition,
"starting" the grace period ?
Also, I find it weird to have, in that order:
1) preempt_disable()
2) rcu_read_lock()
3) local_irq_disable()
I would rather expect:
1) rcu_read_lock()
2) preempt_disable()
3) local_irq_disable()
So they come in increasing order of impact on the system: with
non-preemptable RCU, the read-lock and preempt disable mean the same
thing, however, with preemptable RCU, the impact of preempt disable
seems larger than the impact of RCU read lock: preemption is still
enabled when within a RCU critical section. Both will work, but I find
this call order slightly weird.
Also, if your goal is to increase the chances that call_rcu() enqueues
both callbacks into the same grace period, you might want to issue a
rcu_barrier() early in this function, so that call_rcu() has even more
chances to enqueue the callbacks into the same grace period.
However, if you care about testing enqueue into same _and_ different
grace periods, you might want to turn this single-shot test into a
stress-test by calling it repeatedly.
Thanks!
Mathieu
> local_irq_disable(); /* Make it harder to start a new grace period. */
> call_rcu(&rh2, rcu_torture_leak_cb);
> call_rcu(&rh2, rcu_torture_err_cb); /* Duplicate callback. */
> local_irq_enable();
> rcu_read_unlock();
> preempt_enable();
> rcu_barrier();
> pr_alert("rcutorture: WARN: Duplicate call_rcu() test complete.\n");
> destroy_rcu_head_on_stack(&rh1);
> destroy_rcu_head_on_stack(&rh2);
> #else /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
> pr_alert("rcutorture: !CONFIG_DEBUG_OBJECTS_RCU_HEAD, not testing duplicate call_rcu()\n");
> #endif /* #else #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
> }
>
> > > +
> > > static int __init
> > > rcu_torture_init(void)
> > > {
> > > @@ -2163,6 +2206,8 @@ rcu_torture_init(void)
> > > firsterr = retval;
> > > goto unwind;
> > > }
> > > + if (object_debug)
> > > + rcu_test_debug_objects();
> > > rcutorture_record_test_transition();
> > > mutex_unlock(&fullstop_mutex);
> > > return 0;
> >
>
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2013-08-24 19:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-18 2:24 [PATCH tip/core/rcu 0/5] rcutorture updates for 3.12 Paul E. McKenney
2013-08-18 2:25 ` [PATCH tip/core/rcu 1/5] rcu: Add duplicate-callback tests to rcutorture Paul E. McKenney
2013-08-18 2:25 ` [PATCH tip/core/rcu 2/5] rcu: Increase rcutorture test coverage Paul E. McKenney
2013-08-18 2:25 ` [PATCH tip/core/rcu 3/5] rcu: Sort rcutorture module parameters Paul E. McKenney
2013-08-18 2:57 ` Josh Triplett
2013-08-19 4:03 ` Paul E. McKenney
2013-08-18 2:25 ` [PATCH tip/core/rcu 4/5] rcu: Remove unused variable from rcu_torture_writer() Paul E. McKenney
2013-08-18 2:25 ` [PATCH tip/core/rcu 5/5] rcu: Make rcutorture emit online failures if verbose Paul E. McKenney
2013-08-18 2:59 ` Josh Triplett
2013-08-19 4:05 ` Paul E. McKenney
2013-08-18 2:54 ` [PATCH tip/core/rcu 1/5] rcu: Add duplicate-callback tests to rcutorture Josh Triplett
2013-08-19 3:55 ` Paul E. McKenney
2013-08-19 4:19 ` Josh Triplett
2013-08-19 16:09 ` Paul E. McKenney
2013-08-19 17:16 ` Josh Triplett
2013-08-20 2:05 ` Paul E. McKenney
2013-08-20 3:20 ` Josh Triplett
2013-08-18 2:59 ` [PATCH tip/core/rcu 0/5] rcutorture updates for 3.12 Josh Triplett
2013-08-20 2:51 ` [PATCH tip/core/rcu 1/5] rcu: Add duplicate-callback tests to rcutorture Paul E. McKenney
2013-08-20 2:51 ` [PATCH tip/core/rcu 2/5] rcu: Increase rcutorture test coverage Paul E. McKenney
2013-08-20 2:51 ` [PATCH tip/core/rcu 3/5] rcu: Sort rcutorture module parameters Paul E. McKenney
2013-08-20 2:51 ` [PATCH tip/core/rcu 4/5] rcu: Remove unused variable from rcu_torture_writer() Paul E. McKenney
2013-08-20 2:51 ` [PATCH tip/core/rcu 5/5] rcu: Make rcutorture emit online failures if verbose Paul E. McKenney
2013-08-20 3:24 ` [PATCH tip/core/rcu 1/5] rcu: Add duplicate-callback tests to rcutorture Josh Triplett
2013-08-20 10:02 ` Lai Jiangshan
2013-08-20 18:38 ` Paul E. McKenney
2013-08-21 2:40 ` Lai Jiangshan
2013-08-21 3:03 ` Paul E. McKenney
2013-08-24 19:25 ` Mathieu Desnoyers [this message]
2013-08-25 19:34 ` Paul E. McKenney
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=20130824192536.GE13216@Krystal \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=darren@dvhart.com \
--cc=davidlohr.bueso@hp.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=niv@us.ibm.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=rostedt@goodmis.org \
--cc=sbw@mit.edu \
--cc=sedat.dilek@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).