Re: [PATCH 00/11] nested sleeps, fixes and debug infrastructure

Oleg Nesterov
2014-10-27T23:11:15Z

On 10/27, Peter Zijlstra wrote:
>
> On Thu, Oct 02, 2014 at 02:15:53PM +0200, Peter Zijlstra wrote:
> > On Thu, Oct 02, 2014 at 12:22:51PM +0200, Peter Zijlstra wrote:
>
> > > +#define __wait_event_freezable(wq, condition) \
> > > + (void)___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \
> > > + schedule(); try_to_freeze())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

see below.

> > > +
> > > +/**
> > > + * wait_event - sleep until a condition gets true or freeze (for kthreads)
> > > + * @wq: the waitqueue to wait on
> > > + * @condition: a C expression for the event to wait for
> > > + *
> > > + * The process is put to sleep (TASK_INTERRUPTIBLE -- so as not to contribute
> > > + * to system load) until the @condition evaluates to true. The
> > > + * @condition is checked each time the waitqueue @wq is woken up.
> > > + *
> > > + * wake_up() has to be called after changing any variable that could
> > > + * change the result of the wait condition.
> > > + */
> > > +#define wait_event_freezable(wq, condition) \
> > > +do { \
> > > + WARN_ON_ONCE(!(current->flags & PF_KTHREAD)); \
> > > + might_sleep(); \
> > > + if (condition) \
> > > + break; \
> > > + __wait_event_freezable(wq, condition); \
> > > +} while (0)
> > > +
> > > #define __wait_event_timeout(wq, condition, timeout) \
> > > ___wait_event(wq, ___wait_cond_timeout(condition), \
> > > TASK_UNINTERRUPTIBLE, 0, timeout, \
> >
> > Bah, that doesn't compile, because there already appears to be one,
> > hidden in freezer.h. Now I can't actually tell if it does the same thing
> > or not.
> >
> > Rafael?
>
> Ping?

I was going to say that wait_event_freezable() in kauditd_thread()
is not friendly wrt kthread_should_stop() and thus we we need
kthread_freezable_should_stop().

But in fact we never stop this kauditd_task, so I think we should
turn the main loop into "for (;;)" and change this code to use
wait_event_freezable() like your patch does.

Perhaps it also makes sense to redefine wait_event_freezable.*()
via ___wait_event(cmd => freezable_schedule), but I think this needs
another patch.

Oleg.