Re: [tip:sched/core] sched/wait: Reimplement wait_event_freezable()

From: Pavel Machek
Date: Thu Nov 13 2014 - 09:03:35 EST


Hi!

> > Did you test it with suspend/hibernation? Because I can't really see
> > how it works.
>
> It calls try_to_freeze() after each schedule(). But no, I've not
> actually tried.
>
> If we're stuck in the schedule, waiting for the event, freeze_task()
> will wake us up and then we'll find freeing() true and call into
> __refrigerator().
>
> If we're not stuck in schedule() we're running and the freezer
> can see us running and will wait for us to hit another freeze point.

Ok, let me try it here.

> > > +#define __wait_event_freezable(wq, condition) \
> > > + ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \
> > > + schedule(); try_to_freeze())
> > > +
>
> > _Three_ underscores. And two underscore version exists, too,
> > fortunately it at least has different number of arguments.
>
> Hehe, yeah, there was a discount on underscores that day. The double
> underscore variants can be used in code along with the no underscores
> variants. The tripple one is implementation goo.

Lets see, add 5 underscore variant, and we have contestant for
obfuscated C code contest...

Anyway, it seems it works for me (tested suspend, not hibernation).

Test-by: Pavel Machek <pavel@xxxxxx>

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/