public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
	josh@joshtriplett.org, dvhltc@us.ibm.com, niv@us.ibm.com,
	tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
	Valdis.Kletnieks@vt.edu, dhowells@redhat.com,
	eric.dumazet@gmail.com, Christopher Li <sparse@chrisli.org>
Subject: Re: [PATCH tip/core/rcu 31/48] rcu: define __rcu address space modifier for sparse
Date: Tue, 4 May 2010 22:58:19 +0200	[thread overview]
Message-ID: <201005042258.20390.arnd@arndb.de> (raw)
In-Reply-To: <1273004398-19760-31-git-send-email-paulmck@linux.vnet.ibm.com>

On Tuesday 04 May 2010 22:19:41 Paul E. McKenney wrote:
> This patch defines an __rcu annotation that permits sparse to check for
> correct use of RCU-protected pointers.  If a pointer that is annotated
> with __rcu is accessed directly (as opposed to via rcu_dereference(),
> rcu_assign_pointer(), or one of their variants), sparse can be made
> to complain.  To enable such complaints, use the new default-disabled
> CONFIG_SPARSE_RCU_POINTER kernel configuration option.  Please note that
> these sparse complaints are intended to be a debugging aid, -not- a
> code-style-enforcement mechanism.

To add more background, I was thinking that it might make sense to
always leave the address space attribute in place but to make part
part of the checking optional.

The idea would be that we always make sure that an __rcu annotated
pointer cannot be dereferenced or cast directly, while we would
only complain about non-annotated pointers being passed to rcu_dereference
and rcu_assign_pointer if CONFIG_SPARSE_RCU_POINTER is set.

Most of the work I had spent on my tree was about fixing all the
false positives from that, but more work would be needed to get
a clean build from it even with the modified CONFIG_SPARSE_RCU_POINTER
disabled. Since you managed to find the real bugs and fix them,
your series by itself is probably more useful than the full set
that I originally had.

> +/*
> + * Helper functions for rcu_dereference_check(), rcu_dereference_protected()
> + * and rcu_assign_pointer().  Some of these could be folded into their
> + * callers, but they are left separate in order to ease introduction of
> + * multiple flavors of pointers to match the multiple flavors of RCU
> + * (e.g., __rcu_bh, * __rcu_sched, and __srcu), should this make sense in
> + * the future.
> + */
> +#define __rcu_access_pointer(p, space) \
> +	({ \
> +		typeof(*p) *_________p1 = (typeof(*p)*__force )ACCESS_ONCE(p); \
> +		(void) (((typeof (*p) space *)p) == p); \
> +		((typeof(*p) __force __kernel *)(_________p1)); \
> +	})

Do you have specific plans to add these (__rcu_bh etc) back in the future,
or do you just want to leave the options open?

Anyway, good to see that you found your way through my patches and got them
into shape. 

	Arnd

  reply	other threads:[~2010-05-04 20:59 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 20:19 [PATCH tip/core/rcu 0/48] v4 patches queued for 2.6.35 Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 01/48] rcu: optionally leave lockdep enabled after RCU lockdep splat Paul E. McKenney
2010-05-05 22:46   ` Mathieu Desnoyers
2010-05-05 23:05     ` Paul E. McKenney
2010-05-05 23:24       ` Mathieu Desnoyers
2010-05-05 23:36         ` Paul E. McKenney
2010-05-06  2:05           ` Mathieu Desnoyers
2010-05-06 23:09             ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 02/48] rcu: substitute set_need_resched for sending resched IPIs Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 03/48] rcu: make dead code really dead Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 04/48] rcu: move some code from macro to function Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 05/48] rcu: ignore offline CPUs in last non-dyntick-idle CPU check Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 06/48] rcu: Fix bogus CONFIG_PROVE_LOCKING in comments to reflect reality Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 07/48] rcu: fix now-bogus rcu_scheduler_active comments Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 08/48] rcu: shrink rcutiny by making synchronize_rcu_bh() be inline Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 09/48] rcu: rename rcutiny rcu_ctrlblk to rcu_sched_ctrlblk Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 10/48] rcu: refactor RCU's context-switch handling Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 11/48] rcu: slim down rcutiny by removing rcu_scheduler_active and friends Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 12/48] rcu: enable CPU_STALL_VERBOSE by default Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 13/48] rcu: disable CPU stall warnings upon panic Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 14/48] rcu: print boot-time console messages if RCU configs out of ordinary Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 15/48] rcu: improve RCU CPU stall-warning messages Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 16/48] rcu: permit discontiguous cpu_possible_mask CPU numbering Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 17/48] rcu: v2: reduce the number of spurious RCU_SOFTIRQ invocations Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 18/48] rcu: improve the RCU CPU-stall warning documentation Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 19/48] Debugobjects transition check Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 20/48] rcu head introduce rcu head init on stack Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 21/48] remove all rcu head initializations, except on_stack initializations Paul E. McKenney
2010-05-04 20:27   ` Matt Mackall
2010-05-04 20:36     ` Paul E. McKenney
2010-05-04 23:44   ` James Morris
2010-05-05  0:03     ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 22/48] rcu head remove init Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 23/48] tree/tiny rcu: Add debug RCU head objects (v5) Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 24/48] rcu: make SRCU usable in modules Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 25/48] rcu: fix debugobjects rcu head init on stack in rcutree_plugin.h Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 26/48] rcu: RCU_FAST_NO_HZ must check RCU dyntick state Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 27/48] vfs: add fs.h to define struct file Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 28/48] net: Make accesses to ->br_port safe for sparse RCU Paul E. McKenney
2010-05-04 21:26   ` Stephen Hemminger
2010-05-04 21:41     ` Arnd Bergmann
2010-05-05 22:03       ` Paul E. McKenney
2010-05-06 14:09         ` Arnd Bergmann
2010-05-06 23:12           ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 29/48] rcu: add an rcu_dereference_index_check() Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 30/48] mce: convert to rcu_dereference_index_check() Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 31/48] rcu: define __rcu address space modifier for sparse Paul E. McKenney
2010-05-04 20:58   ` Arnd Bergmann [this message]
2010-05-04 23:07     ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 32/48] rculist: avoid __rcu annotations Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 33/48] cgroups: " Paul E. McKenney
2010-05-04 20:48   ` Paul Menage
2010-05-05  0:04     ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 34/48] credentials: rcu annotation Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 35/48] keys: __rcu annotations Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 36/48] nfs: " Paul E. McKenney
2010-05-05 10:14   ` David Howells
2010-05-05 12:44     ` Trond Myklebust
2010-05-05 21:01       ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 37/48] net: __rcu annotations for drivers Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 38/48] perf_event: __rcu annotations Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 39/48] notifiers: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 40/48] radix-tree: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 41/48] idr: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 42/48] input: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 43/48] vhost: add " Paul E. McKenney
2010-05-04 21:39   ` Michael S. Tsirkin
2010-05-04 23:57     ` Paul E. McKenney
2010-05-04 23:59       ` Michael S. Tsirkin
2010-05-05  0:39         ` Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 44/48] net/netfilter: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 45/48] kvm: add " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 46/48] kernel: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 47/48] net: " Paul E. McKenney
2010-05-04 20:19 ` [PATCH tip/core/rcu 48/48] kvm: more " 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=201005042258.20390.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=dvhltc@us.ibm.com \
    --cc=eric.dumazet@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=niv@us.ibm.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sparse@chrisli.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