public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Jan Blunck <jblunck@suse.de>
Cc: linux-kernel@vger.kernel.org, paulus@samba.org
Subject: Re: [PATCH] fix vmstat per cpu usage
Date: Wed, 2 Aug 2006 07:43:08 -0700	[thread overview]
Message-ID: <20060802074308.babd264e.akpm@osdl.org> (raw)
In-Reply-To: <20060802133006.GP4995@hasse.suse.de>

On Wed, 2 Aug 2006 15:30:06 +0200
Jan Blunck <jblunck@suse.de> wrote:

> Here comes another idea. To find further wrong usage of percpu variables I
> wrote the following patch. It still needs some work for the other archs but
> I'm interested in your feedback about that.
> 
> ...
> 
> Index: linux-2.6/include/asm-generic/percpu.h
> ===================================================================
> --- linux-2.6.orig/include/asm-generic/percpu.h
> +++ linux-2.6/include/asm-generic/percpu.h
> @@ -14,7 +14,9 @@ extern unsigned long __per_cpu_offset[NR
>      __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
>  
>  /* var is in discarded region: offset to particular copy we want */
> -#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
> +#define per_cpu(var, cpu) (*({				\
> +	int user_error_##var __attribute__ ((unused));	\
> +	RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); }))

What's it do?  Forces a syntax error if `var' isn't a simple identifier?

Seems sane, although I'd check that the compiler doesn't accidentally
waste a stack slot for that local.  Perhaps it's be safer to make
it a non-existing function:

	extern int user_error#var(void);


  reply	other threads:[~2006-08-02 14:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-01 17:36 [PATCH] fix vmstat per cpu usage Jan Blunck
2006-08-01 21:07 ` Andrew Morton
2006-08-01 22:44   ` Paul Mackerras
2006-08-02  9:01   ` Jan Blunck
2006-08-02 13:30   ` Jan Blunck
2006-08-02 14:43     ` Andrew Morton [this message]
2006-08-07 12:42       ` Jan Blunck
2006-08-02 16:54 ` Steve Fox

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=20060802074308.babd264e.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=jblunck@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.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