All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Christoph Lameter <cl@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, rusty@rustcorp.com.au,
	mingo@redhat.com, tglx@linutronix.de, akpm@linux-foundation.org,
	rostedt@goodmis.org, hpa@zytor.com, cebbert@redhat.com,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 16/16] percpu: make accessors check for percpu pointer in sparse
Date: Thu, 15 Oct 2009 18:08:28 +0900	[thread overview]
Message-ID: <4AD6E68C.8020902@kernel.org> (raw)
In-Reply-To: <alpine.DEB.1.10.0910141039290.26476@gentwo.org>

Christoph Lameter wrote:
> On Wed, 14 Oct 2009, Tejun Heo wrote:
> 
>>  #ifndef SHIFT_PERCPU_PTR
>>  /* Weird cast keeps both GCC and sparse happy. */
>> -#define SHIFT_PERCPU_PTR(__p, __offset)				\
>> -	RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset))
>> +#define SHIFT_PERCPU_PTR(__p, __offset)	({				\
>> +	__verify_pcpu_ptr((__p));					\
>> +	RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset)); \
>> +})
> 
> If you have the verification in SHIFT_PER_CPU_PTR then why do you need it
> elsewhere?

Because this_cpu_*() macros might not calculate addresses using
SHIFT_PERCPU_PTR().

>>  #define __pcpu_size_call_return(stem, variable)				\
>>  ({	typeof(variable) pscr_ret__;					\
>> +	__verify_pcpu_ptr(&(variable));					\
>>  	switch(sizeof(variable)) {					\
>>  	case 1: pscr_ret__ = stem##1(variable);break;			\
>>  	case 2: pscr_ret__ = stem##2(variable);break;			\
>> @@ -250,6 +251,7 @@ extern void __bad_size_call_parameter(void);
>>
>>  #define __pcpu_size_call(stem, variable, ...)				\
>>  do {									\
>> +	__verify_pcpu_ptr(&(variable));					\
>>  	switch(sizeof(variable)) {					\
>>  		case 1: stem##1(variable, __VA_ARGS__);break;		\
>>  		case 2: stem##2(variable, __VA_ARGS__);break;		\
> 
> Would it not be better to put the verification in the arch code? The
> percpu_to/from_op may have multiple callsites (at least they have now). If
> you put it in there then all other stuff is covered.

I don't know.  The way these ops are defined, adding
__verify_pcpu_ptr() to size_call macros reliably cover all percpu
cases and I much prefer things like this being done in generic code
rather than requiring each arch to do it.  It's just more reliable
this way.

Thanks.

-- 
tejun

  reply	other threads:[~2009-10-15  9:09 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14  6:01 [RFC percpu#for-next] percpu: drop per_cpu__ prefix and add sparse annotations, take#2 Tejun Heo
2009-10-14  6:01 ` [PATCH 01/16] vmalloc: fix use of non-existent percpu variable in put_cpu_var() Tejun Heo
2009-10-14 15:06   ` Christoph Lameter
2009-10-15  9:10     ` Tejun Heo
2009-10-14  6:01 ` [PATCH 02/16] percpu: make alloc_percpu() handle array types Tejun Heo
2009-10-14  6:01 ` [PATCH 03/16] percpu: remove some sparse warnings Tejun Heo
2009-10-14 14:20   ` Christoph Lameter
2009-10-14  6:01 ` [PATCH 04/16] percpu: make percpu symbols under kernel/ and mm/ unique Tejun Heo
2009-10-14  6:01 ` [PATCH 05/16] percpu: make percpu symbols in tracer unique Tejun Heo
2009-10-14  6:01 ` [PATCH 06/16] percpu: make percpu symbols in oprofile unique Tejun Heo
2009-10-14  6:01 ` [PATCH 07/16] percpu: make percpu symbols in cpufreq unique Tejun Heo
2009-10-14  6:01 ` [PATCH 08/16] percpu: make percpu symbols in xen unique Tejun Heo
2009-10-14  6:01 ` [PATCH 09/16] percpu: make percpu symbols in x86 unique Tejun Heo
2009-10-14  6:01 ` [PATCH 10/16] percpu: make percpu symbols in powerpc unique Tejun Heo
2009-10-14  6:01   ` Tejun Heo
2009-10-27  3:19   ` Benjamin Herrenschmidt
2009-10-27  3:19     ` Benjamin Herrenschmidt
2009-10-14  6:02 ` [PATCH 11/16] percpu: make percpu symbols in ia64 unique Tejun Heo
2009-10-14  6:02   ` Tejun Heo
2009-10-14  6:02 ` [PATCH 12/16] percpu: make misc percpu symbols unique Tejun Heo
2009-10-14  6:02 ` [PATCH 13/16] percpu: remove per_cpu__ prefix Tejun Heo
2009-10-14 14:36   ` Christoph Lameter
2009-10-14 16:42     ` Luck, Tony
2009-10-14 17:38       ` H. Peter Anvin
2009-10-14 18:26         ` Christoph Lameter
2009-10-15  8:57         ` Tejun Heo
2009-10-14 18:22       ` Christoph Lameter
2009-10-14 18:36         ` Luck, Tony
2009-10-14 18:51           ` Christoph Lameter
2009-10-15  8:51             ` Tejun Heo
2009-10-16 16:23               ` Christoph Lameter
2009-10-15  9:24     ` Tejun Heo
2009-10-16  6:04       ` Michal Simek
2009-10-18  2:58         ` Tejun Heo
2009-10-19 13:41           ` Michal Simek
2009-10-29 11:11             ` Tejun Heo
2009-11-02 16:35               ` Michal Simek
2009-10-19 13:40       ` Michal Simek
2009-10-29 12:06         ` Tejun Heo
2009-10-14  6:02 ` [PATCH 14/16] percpu: make access macros universal Tejun Heo
2009-10-14 14:38   ` Christoph Lameter
2009-10-15  9:27     ` Tejun Heo
2009-10-14  6:02 ` [PATCH 15/16] percpu: add __percpu for sparse Tejun Heo
2009-10-14  6:02 ` [PATCH 16/16] percpu: make accessors check for percpu pointer in sparse Tejun Heo
2009-10-14 14:41   ` Christoph Lameter
2009-10-15  9:08     ` Tejun Heo [this message]
2009-10-29 13:40 ` [RFC percpu#for-next] percpu: drop per_cpu__ prefix and add sparse annotations, take#2 Tejun Heo

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=4AD6E68C.8020902@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cebbert@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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.