From: Josh Triplett <josh@joshtriplett.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
jiangshanlai@gmail.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com,
fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com
Subject: Re: [PATCH tip/core/rcu 10/13] rcu: Add rcu_pointer_handoff()
Date: Tue, 6 Oct 2015 10:36:36 -0700 [thread overview]
Message-ID: <20151006173636.GJ9600@cloud> (raw)
In-Reply-To: <20151006173152.GI3910@linux.vnet.ibm.com>
On Tue, Oct 06, 2015 at 10:31:52AM -0700, Paul E. McKenney wrote:
> On Tue, Oct 06, 2015 at 10:21:28AM -0700, Josh Triplett wrote:
> > On Tue, Oct 06, 2015 at 09:13:45AM -0700, Paul E. McKenney wrote:
> > > This commit adds an rcu_pointer_handoff() that is intended to mark
> > > situations where a structure's protection transitions from RCU to some
> > > other mechanism (locking, reference counting, whatever). These markings
> > > should allow external tools to more easily spot bugs involving leaking
> > > pointers out of RCU read-side critical sections.
> > >
> > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> >
> > Shouldn't this expect the __rcu address space on the pointer, and cast
> > away the __rcu with __force?
>
> I do not believe so, given that the __rcu was already removed by a preceding
> rcu_dereference(). Or am I missing something?
Ah, I see. Per the example, you don't call this on an __rcu pointer
directly, only on a pointer you've already obtained from RCU after
giving it a lifetime of its own. Nevermind.
> > > include/linux/rcupdate.h | 22 ++++++++++++++++++++++
> > > 1 file changed, 22 insertions(+)
> > >
> > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > index 6c3ceceb6148..587eb057e2fa 100644
> > > --- a/include/linux/rcupdate.h
> > > +++ b/include/linux/rcupdate.h
> > > @@ -813,6 +813,28 @@ static inline void rcu_preempt_sleep_check(void)
> > > #define rcu_dereference_sched(p) rcu_dereference_sched_check(p, 0)
> > >
> > > /**
> > > + * rcu_pointer_handoff() - Hand off a pointer from RCU to other mechanism
> > > + * @p: The pointer to hand off
> > > + *
> > > + * This is simply an identity function, but it documents where a pointer
> > > + * is handed off from RCU to some other synchronization mechanism, for
> > > + * example, reference counting or locking. In C11, it would map to
> > > + * kill_dependency(). It could be used as follows:
> > > + *
> > > + * rcu_read_lock();
> > > + * p = rcu_dereference(gp);
> > > + * long_lived = is_long_lived(p);
> > > + * if (long_lived) {
> > > + * if (!atomic_inc_not_zero(p->refcnt))
> > > + * long_lived = false;
> > > + * else
> > > + * p = rcu_pointer_handoff(p);
> > > + * }
> > > + * rcu_read_unlock();
> > > + */
> > > +#define rcu_pointer_handoff(p) (p)
> > > +
> > > +/**
> > > * rcu_read_lock() - mark the beginning of an RCU read-side critical section
> > > *
> > > * When synchronize_rcu() is invoked on one CPU while other CPUs
> > > --
> > > 2.5.2
> > >
> >
>
next prev parent reply other threads:[~2015-10-06 17:36 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 16:13 [PATCH tip/core/rcu 0/13] Miscellaneous fixes for 4.4 Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 01/13] sched: Export sched_setscheduler_nocheck Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 02/13] rcu: Use rcu_callback_t in call_rcu*() and friends Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 03/13] rcu: Use call_rcu_func_t to replace explicit type equivalents Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 04/13] rcu: Don't disable preemption for Tiny and Tree RCU readers Paul E. McKenney
2015-10-06 16:20 ` [Kernel networking modules.] OSI levels 2 & 3, Assistance - If anyone knows anyone in the US. North West region John D Allen, Leveridge Systems INC
2015-10-06 16:44 ` [PATCH tip/core/rcu 04/13] rcu: Don't disable preemption for Tiny and Tree RCU readers Josh Triplett
2015-10-06 17:01 ` Paul E. McKenney
2015-10-06 17:16 ` Josh Triplett
2015-10-06 17:42 ` Paul E. McKenney
2015-10-06 17:46 ` Josh Triplett
2015-10-06 20:05 ` Peter Zijlstra
2015-10-06 20:18 ` Paul E. McKenney
2015-10-06 20:52 ` Peter Zijlstra
2015-10-06 21:05 ` Paul E. McKenney
2015-10-07 7:19 ` Peter Zijlstra
2015-10-06 16:13 ` [PATCH tip/core/rcu 05/13] rcu: Eliminate panic when silly boot-time fanout specified Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 06/13] rcu: Add online/offline info to stall warning message Paul E. McKenney
2015-10-06 17:15 ` Josh Triplett
2015-10-06 16:13 ` [PATCH tip/core/rcu 07/13] rcu: Move preemption disabling out of __srcu_read_lock() Paul E. McKenney
2015-10-06 17:18 ` Josh Triplett
2015-10-06 17:36 ` Paul E. McKenney
2015-10-06 17:43 ` Josh Triplett
2015-10-06 18:07 ` Paul E. McKenney
2015-10-06 20:07 ` Peter Zijlstra
2015-10-06 20:19 ` Paul E. McKenney
2015-10-06 20:32 ` Peter Zijlstra
2015-10-06 21:03 ` Paul E. McKenney
2015-10-07 7:20 ` Peter Zijlstra
2015-10-07 14:18 ` Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 08/13] rcu: Finish folding ->fqs_state into ->gp_state Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 09/13] rcu: Correct comment for values of ->gp_state field Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 10/13] rcu: Add rcu_pointer_handoff() Paul E. McKenney
2015-10-06 17:21 ` Josh Triplett
2015-10-06 17:31 ` Paul E. McKenney
2015-10-06 17:36 ` Josh Triplett [this message]
2015-10-06 20:27 ` Peter Zijlstra
2015-10-06 21:02 ` Paul E. McKenney
2015-10-07 7:22 ` Peter Zijlstra
2015-10-07 14:20 ` Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 11/13] rculist: Make list_entry_rcu() use lockless_dereference() Paul E. McKenney
2015-10-26 8:45 ` Ingo Molnar
2015-10-26 14:55 ` Paul E. McKenney
2015-10-26 18:02 ` Ingo Molnar
2015-10-27 3:37 ` Linus Torvalds
2015-10-27 5:19 ` Tejun Heo
2015-10-27 5:33 ` Paul E. McKenney
2015-10-28 8:33 ` Ingo Molnar
2015-10-28 20:35 ` Patrick Marlier
2015-10-29 0:00 ` Paul E. McKenney
2015-10-29 2:13 ` Tejun Heo
2015-10-28 20:58 ` [tip:core/rcu] fs/writeback, rcu: Don't use list_entry_rcu() for pointer offsetting in bdi_split_work_to_wbs() tip-bot for Tejun Heo
2015-10-27 5:32 ` [PATCH tip/core/rcu 11/13] rculist: Make list_entry_rcu() use lockless_dereference() Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 12/13] rcu: Remove deprecated rcu_lockdep_assert() Paul E. McKenney
2015-10-06 16:13 ` [PATCH tip/core/rcu 13/13] rculist: Use WRITE_ONCE() when deleting from reader-visible list Paul E. McKenney
2015-10-06 17:23 ` [PATCH tip/core/rcu 0/13] Miscellaneous fixes for 4.4 Josh Triplett
2015-10-06 17:38 ` 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=20151006173636.GJ9600@cloud \
--to=josh@joshtriplett.org \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhart@linux.intel.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.