From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Dave Jones <davej@redhat.com>,
David Howells <dhowells@redhat.com>,
Imre Deak <imre.deak@intel.com>, Jens Axboe <axboe@kernel.dk>,
Linus Torvalds <torvalds@linux-foundation.org>,
Lukas Czerner <lczerner@redhat.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] introduce wait_event_common()
Date: Thu, 6 Jun 2013 22:02:57 +0200 [thread overview]
Message-ID: <20130606200257.GA23628@redhat.com> (raw)
Hello.
To remind, I think that 4c663cfc "wait: fix false timeouts when using
wait_event_timeout()" is not enough, wait(wq, true, 0) still returns
zero.
But to me the main problem is that wait_event* macros duplicate the
same code again and again. Imho it would be nice to create a single
helper. To simplify the review, this is the code after 1/2:
#define __wait_no_timeout(tout) \
(__builtin_constant_p(tout) && (tout) == MAX_SCHEDULE_TIMEOUT)
/* uglified signal_pending_state() optimized for constant 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; \
})
#define wait_event_common(wq, condition, state, tout) \
({ \
long __ret; \
if (condition) \
__ret = __wait_no_timeout(tout) ?: (tout) ?: 1; \
else \
__ret = __wait_event_common(wq, condition, state, tout);\
__ret; \
})
2/2 doesn't look like a cleanup. But personally I think that it makes
sense to shrink .text,
- 4977769 2930984 10104832 18013585 112dd91 vmlinux
+ 4976847 2930984 10104832 18012663 112d9f7 vmlinux
on my build.
Please comment.
Oleg.
next reply other threads:[~2013-06-06 20:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 20:02 Oleg Nesterov [this message]
2013-06-06 20:03 ` [PATCH 1/2] wait: introduce wait_event_common(wq, condition, state, timeout) Oleg Nesterov
2013-06-18 22:06 ` Andrew Morton
2013-06-19 16:14 ` Oleg Nesterov
2013-06-06 20:03 ` [PATCH 2/2] wait: introduce prepare_to_wait_event() Oleg Nesterov
2013-06-06 21:36 ` Tejun Heo
2013-06-07 13:07 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130606200257.GA23628@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=daniel.vetter@ffwll.ch \
--cc=davej@redhat.com \
--cc=dhowells@redhat.com \
--cc=imre.deak@intel.com \
--cc=lczerner@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.