[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Re: [PATCH] Fix cpu offline bug
On 08/03/2011 10:14, "Jan Beulich" <JBeulich@xxxxxxxxxx> wrote: >>>> On 08.03.11 at 10:47, "Liu, Jinsong" <jinsong.liu@xxxxxxxxx> wrote: >> Jan, I'm not quite clear your meaning. >> Why and where need to insert barrier, or volatile cpu_state? > > while ( (seen_state = cpu_state) != CPU_STATE_DEAD ) > { > + barrier(); > BUG_ON(seen_state != CPU_STATE_DYING); > mdelay(100); > cpu_relax(); > > Without this, the compiler is free to eliminate "seen_state" in favor > of reading "cpu_state" twice (irrespective of the optimizer very > likely trying to do exactly the opposite). Haha, you're getting paranoid Jan! What you describe is impossible -- there is no way that C semantics allow a local variable's value to change after it has affected program behaviour (if it hasn't escaped local scope by having its address taken for example). If that could happen then we'd have plenty of other code that doesn't work properly either, I'm sure. In this case, if a second read from cpu_state did occur then we could end up observing seen_state==CPU_STATE_DEAD, in a code block that is predicated on this not being true! -- Keir > Jan > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |