Hello, Oleg.
On Wed, Jun 05, 2013 at 09:07:23PM +0200, Oleg Nesterov wrote:
> And in fact, perhaps we can implement wait_event_common() and avoid the
> code duplications?
>
> #define __wait_no_timeout(timeout) \
> (__builtin_constant_p(timeout) && (timeout) ==
> MAX_SCHEDULE_TIMEOUT)
>
> /* uglified signal_pending_state() */
> #define __wait_signal_pending(state)
> \
> ((state == TASK_INTERRUPTIBLE) ? signal_pending(current) :
> \
> (state == TASK_KILLABLE) ? fatal_signal_pending(current) :
> \
> 0)
>
> #define __wait_event_common(wq, condition, state, tout)
> \
> ({
> \
> DEFINE_WAIT(__wait);
> \
> long __ret = 0, __tout = tout;
> \
>
> \
> for (;;) {
> \
> prepare_to_wait(&wq, &__wait, state);
> \
> if (condition) {
> \
> __ret = __wait_no_timeout(tout) ?: __tout ?: 1;
> \
> break;
> \
> }
> \
>
> \
> if (__wait_signal_pending(state)) {
> \
> __ret = -ERESTARTSYS;
> \
> break;
> \
> }
> \
>
> \
> if (__wait_no_timeout(tout))
> \
> schedule();
> \
> else if (__tout)
> \
> __tout = schedule_timeout(__tout);
> \
> else
> \
> break;
> \
> }
> \
> finish_wait(&wq, &__wait);
> \
> __ret;
> \
> })
Heh, yeah, this looks good to me and a lot better than trying to do
the same thing over and over again and ending up with subtle
differences.
> Hmm. I compiled the kernel with the patch below,
>
> $ size vmlinux
> text data bss dec hex filename
> - 4978601 2935080 10104832 18018513 112f0d1 vmlinux
> + 4977769 2930984 10104832 18013585 112dd91 vmlinux
Nice. Provided you went over assembly outputs of at least some
combinations, please feel free to add
Reviewed-by: Tejun Heo <[email protected]>
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/