LWN.net Logo

Re: [PATCH] synchronize_irq needs a barrier

From:  Andrew Morton <akpm-AT-linux-foundation.org>
To:  benh-AT-kernel.crashing.org
Subject:  Re: [PATCH] synchronize_irq needs a barrier
Date:  Wed, 17 Oct 2007 18:45:12 -0700
Message-ID:  <20071017184512.a1c647b2.akpm@linux-foundation.org>
Cc:  torvalds-AT-linux-foundation.org, linux-kernel-AT-vger.kernel.org, linuxppc-dev-AT-ozlabs.org
Archive-link:  Article, Thread

On Thu, 18 Oct 2007 11:25:42 +1000
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> synchronize_irq needs at the very least a compiler barrier and a
> read barrier on SMP,

Why?

> but there are enough cases around where a
> write barrier is also needed and it's not a hot path so I prefer
> using a full smp_mb() here.
> 
> It will degrade to a compiler barrier on !SMP.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 
> Index: linux-work/kernel/irq/manage.c
> ===================================================================
> --- linux-work.orig/kernel/irq/manage.c	2007-10-18 11:22:16.000000000 +1000
> +++ linux-work/kernel/irq/manage.c	2007-10-18 11:22:20.000000000 +1000
> @@ -33,6 +33,7 @@ void synchronize_irq(unsigned int irq)
>  	if (irq >= NR_IRQS)
>  		return;
>  
> +	smp_mb();
>  	while (desc->status & IRQ_INPROGRESS)
>  		cpu_relax();
>  }

Anyone reading this code is going to ask "wtf is that for".  It needs a
comment telling them.


mb() is the new lock_kernel().  Sigh.


(Log in to post comments)

Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds