From: Pavel Machek <pavel@ucw.cz>
To: "Zhang, Yanmin" <yanmin.zhang@intel.com>
Cc: linux-kernel@vger.kernel.org, "Pallipadi,
Venkatesh" <venkatesh.pallipadi@intel.com>,
"Shah, Rajesh" <rajesh.shah@intel.com>
Subject: Re: [BUG] Variable stopmachine_state should be volatile
Date: Thu, 1 Dec 2005 04:25:43 +0100 [thread overview]
Message-ID: <20051201032543.GA2387@elf.ucw.cz> (raw)
In-Reply-To: <8126E4F969BA254AB43EA03C59F44E84040B3C8C@pdsmsx404>
Hi!
> >>Hi!
> >>
> >>> The model to access variable stopmachine_state is that a main thread
> >>> writes it and other threads read it. Its declaration has no sign
> >>> volatile. In the while loop in function stopmachine, this variable is
> >>> read, and compiler might optimize it by reading it once before the loop
> >>> and not reading it again in the loop, so the thread might enter dead
> >>> loop.
> >>
> >>No. volatile may look like a solution, but it usually is not. You may
> >>need some barriers, atomic_t or locking.
> >> Pavel
> The original functions already use smp_mb/smp_wmb. My patch just
>tells compiler not to optimize by bringing the reading of
>stopmachine_state out of the while loop.
Those barriers should already prevent compiler optimalization, no? If
they do not, just use some barriers that do.
Pavel
--
Thanks, Sharp!
next prev parent reply other threads:[~2005-12-01 3:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-01 2:58 [BUG] Variable stopmachine_state should be volatile Zhang, Yanmin
2005-12-01 3:25 ` Pavel Machek [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-12-12 7:06 Zhang, Yanmin
2005-12-08 18:53 Luck, Tony
2005-12-08 1:37 Zhang, Yanmin
2005-12-12 13:39 ` Christoph Hellwig
[not found] <88056F38E9E48644A0F562A38C64FB60067BE61C@scsmsx403.amr.corp.intel.com>
2005-12-02 3:53 ` Pavel Machek
2005-12-02 2:48 Zhang, Yanmin
2005-12-01 5:27 Zhang, Yanmin
2005-12-01 10:26 ` Pavel Machek
2005-11-30 2:04 Zhang, Yanmin
2005-11-30 22:19 ` Pavel Machek
2005-12-02 8:04 ` Arjan van de Ven
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=20051201032543.GA2387@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=rajesh.shah@intel.com \
--cc=venkatesh.pallipadi@intel.com \
--cc=yanmin.zhang@intel.com \
/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