Re: [RFC 09/15] PM / Hibernate: user, implement user_ops writer

Pavel Machek
2010-03-25T21:36:42Z

On Wed 2010-03-24 22:40:56, Jiri Slaby wrote:
> On 03/24/2010 09:42 PM, Pavel Machek wrote:
> >> + if (test_bit(TODO_CLOSED, to_do_flags))
> >> + return -EIO;
> >> +
> >> + to_do_buf = buf;
> >> + wmb();
> >> + set_bit(TODO_WORK, to_do_flags);
> >> + wake_up_interruptible(&to_do_wait);
> >
> > Uhuh, open-coded barriers... these need to be commented, and I guess
> > you just should not play this kind of trickery.
>
> It's just to ensure the to_do_buf store is not reordered with the
> set_bit. I wanted to avoid locks as too heavy tools here.

Locks are the only sane choice here. Open coding them is not an option.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html