All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] remove volatile from nmi.c
Date: Fri, 14 Jul 2006 23:28:29 +1000	[thread overview]
Message-ID: <44B79BFD.10005@yahoo.com.au> (raw)
In-Reply-To: <1152882288.1883.30.camel@localhost.localdomain>

Steven Rostedt wrote:
> OK, I'm using this as something of an exercise to completely understand
> memory barriers.  So if something is incorrect, please let me know.
> 
> This patch removes the volatile keyword from arch/i386/kernel/nmi.c.
> 
> The first removal is trivial, since the barrier in the while loop makes
> it unnecessary. (as proved in "[patch] spinlocks: remove 'volatile'"
> thread)
> http://marc.theaimsgroup.com/?l=linux-kernel&m=115217423929806&w=2
> 
> 
> The second is what I think is correct.  So please review.

Please comment memory barriers if possible.

The second adds memory barriers that weren't there before... how come
they are needed? Basically, the comment should be a pointer to the
read side, or illustrate a typical readside where write reordering
would cause a problem.

> 
> Thanks,
> 
> -- Steve
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> 
> Index: linux-2.6.18-rc1/arch/i386/kernel/nmi.c
> ===================================================================
> --- linux-2.6.18-rc1.orig/arch/i386/kernel/nmi.c	2006-07-14 08:35:00.000000000 -0400
> +++ linux-2.6.18-rc1/arch/i386/kernel/nmi.c	2006-07-14 08:38:07.000000000 -0400
> @@ -106,7 +106,7 @@ int nmi_active;
>   */
>  static __init void nmi_cpu_busy(void *data)
>  {
> -	volatile int *endflag = data;
> +	int *endflag = data;
>  	local_irq_enable_in_hardirq();
>  	/* Intentionally don't use cpu_relax here. This is
>  	   to make sure that the performance counter really ticks,
> @@ -121,7 +121,7 @@ static __init void nmi_cpu_busy(void *da
>  
>  static int __init check_nmi_watchdog(void)
>  {
> -	volatile int endflag = 0;
> +	int endflag = 0;
>  	unsigned int *prev_nmi_count;
>  	int cpu;
>  
> @@ -150,7 +150,7 @@ static int __init check_nmi_watchdog(voi
>  			continue;
>  #endif
>  		if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
> -			endflag = 1;
> +			set_wmb(endflag, 1);
>  			printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
>  				cpu,
>  				prev_nmi_count[cpu],
> @@ -161,7 +161,7 @@ static int __init check_nmi_watchdog(voi
>  			return -1;
>  		}
>  	}
> -	endflag = 1;
> +	set_wmb(endflag, 1);
>  	printk("OK.\n");
>  
>  	/* now that we know it works we can reduce NMI frequency to


-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

  reply	other threads:[~2006-07-15 19:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14 13:04 [PATCH] remove volatile from nmi.c Steven Rostedt
2006-07-14 13:28 ` Nick Piggin [this message]
2006-07-14 15:23 ` Linus Torvalds
2006-07-14 16:32   ` Chase Venters
2006-07-14 16:47     ` Linus Torvalds
2006-07-14 17:00       ` Steven Rostedt
2006-07-14 17:28   ` Linus Torvalds
2006-07-14 17:38     ` Steven Rostedt
2006-07-14 17:41       ` Linus Torvalds
2006-07-14 17:58         ` Andrew Morton
2006-07-14 20:04           ` [PATCH 00/02] remove set_wmb Steven Rostedt
2006-07-14 20:05           ` [PATCH 01/02] remove set_wmb - doc update Steven Rostedt
2006-07-15  2:22             ` Matthew Wilcox
2006-07-15  2:35               ` Steven Rostedt
2006-07-14 20:05           ` [PATCH 02/02] remove set_wmb - arch removal Steven Rostedt

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=44B79BFD.10005@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@osdl.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 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.