linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: TeJun Huh <tejun@aratech.co.kr>
To: Andrea Arcangeli <andrea@suse.de>
Cc: Stephan von Krawczynski <skraw@ithnet.com>,
	manfred@colorfullife.com, linux-kernel@vger.kernel.org,
	zwane@linuxpower.ca
Subject: Re: Possible race condition in i386 global_irq_lock handling.
Date: Sun, 24 Aug 2003 12:06:51 +0900	[thread overview]
Message-ID: <20030824030651.GA13292@atj.dyndns.org> (raw)
In-Reply-To: <20030822162546.GQ29612@dualathlon.random>

 Hello Andrea,

On Fri, Aug 22, 2003 at 06:25:46PM +0200, Andrea Arcangeli wrote:
> thanks TeJun,
> 
> just one comment
> 
> On Fri, Aug 22, 2003 at 10:18:40AM +0900, TeJun Huh wrote:
> >  3. remove irqs_running() test from synchronize_irq()
> 
> I'm not convinced this one is needed. An irq can still run on another
> cpu but the cli();sti() may execute while it's here:
> 
> 	irq running		synchronize_irq()
> 	--------------		-----------------
> 	do_IRQ
> 	handle_IRQ_event
> 				cli()
> 				sti()
> 
> 	irq_enter -> way too late
> 
> in short, doing irqs_running() doesn't seem to weaken the semantics of
> synchronize_irq() to me.
> 
> I think it should be changed this way instead:
> 
> void synchronize_irq(void)
> {
> 	smp_mb();
> 	if (irqs_running()) {
> 		/* Stupid approach */
> 		cli();
> 		sti();
> 	}
> }
> 
> to be sure to read the local irq area after the previous code (the
> test_and_set_bit of the global_irq_lock of a cli() in your version would
> achieve the same implicit smp_mb too, so maybe your only point for doing
> cli()/sti() was to execute the smp_mb before the irqs_running?).  the
> above version is more finegrined and it looks equivalent to yours.
> 
> Andrea

 Yes, you're right.  Adding just smp_mb() should guarantee that no cpu
is executing interrupt handler which may not see memory contents
modified before synchronize_irq() after synchronize_irq() returns.  I
think we need some decent comments there. :-)

 As now I know that test_and_set_bit() implies memory barrier,
smb_mb__after_clear_bit() can be removed.  I'll make and post a patch
which fixes this race and the bh race of the other thread.

 Thanks.

-- 
tejun

  reply	other threads:[~2003-08-24  3:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-21 17:01 Possible race condition in i386 global_irq_lock handling Manfred Spraul
2003-08-21 17:27 ` Andrea Arcangeli
2003-08-21 21:48   ` Stephan von Krawczynski
2003-08-21 22:44     ` Andrea Arcangeli
2003-08-22  1:18     ` TeJun Huh
2003-08-22 10:07       ` Stephan von Krawczynski
2003-08-22 16:25       ` Andrea Arcangeli
2003-08-24  3:06         ` TeJun Huh [this message]
2003-08-24 22:03           ` Andrea Arcangeli
  -- strict thread matches above, loose matches on Subject: below --
2003-08-21  8:48 TeJun Huh
2003-08-21 10:07 ` Zwane Mwaikambo
2003-08-21 16:15   ` TeJun Huh

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=20030824030651.GA13292@atj.dyndns.org \
    --to=tejun@aratech.co.kr \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=skraw@ithnet.com \
    --cc=zwane@linuxpower.ca \
    /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;
as well as URLs for NNTP newsgroup(s).