From: Andrew Morton <akpm@linux-foundation.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-next@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: Regression with wait_event_timeout in next-20140226
Date: Wed, 9 Apr 2014 12:05:14 -0700 [thread overview]
Message-ID: <20140409120514.da292ccfd5530a995090228d@linux-foundation.org> (raw)
In-Reply-To: <20140409111638.GS11096@twins.programming.kicks-ass.net>
On Wed, 9 Apr 2014 13:16:38 +0200 Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, Feb 26, 2014 at 02:25:34PM -0800, Andrew Morton wrote:
> > Is there anything we can do to make all this clearer? Simply using a
> > distinctive variable name ("__wait_var__"?) in place of __ret (and
> > documenting it) would help a lot.
> >
> > Some __ret's are long and some are int. Maybe that's a glitch, maybe
> > it's because some __ret's are used for inter-macro communications and
> > some are not, which just makes things worse.
> >
> > I started to do a patch, got all confused and gave up. We've made
> > quite a tangly mess in there, alas.
>
> Something like so?
>
> ---
> Subject: wait: Explain the shadowing and type inconsistencies
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Wed Apr 9 12:50:34 CEST 2014
>
> Stick in a comment before someone else tries to fix the sparse warning
> this generates.
>
> Requested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Peter Zijlstra <peterz@infradead.org>
> Link: http://lkml.kernel.org/n/tip-o2ro6f3vkxklni0bc8f7m68s@git.kernel.org
> ---
> include/linux/wait.h | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -191,11 +191,23 @@ wait_queue_head_t *bit_waitqueue(void *,
> (!__builtin_constant_p(state) || \
> state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \
>
> +/*
> + * The below macro ___wait_event() has an explicit shadow of the __ret
> + * variable when used from the wait_event_*() macros.
> + *
> + * This is so that both can use the ___wait_cond_timeout() construct
> + * to wrap the condition.
> + *
> + * The type inconsistency of the wait_event_*() __ret variable is also
> + * on purpose; we use long where we can return timeout values and int
> + * otherwise.
> + */
> +
> #define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
> ({ \
> __label__ __out; \
> wait_queue_t __wait; \
> - long __ret = ret; \
> + long __ret = ret; /* explicit shadow */ \
> \
> INIT_LIST_HEAD(&__wait.task_list); \
> if (exclusive) \
Looks nice to me, thanks.
next prev parent reply other threads:[~2014-04-09 19:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 16:35 Regression with wait_event_timeout in next-20140226 Gregory CLEMENT
2014-02-26 16:50 ` Peter Zijlstra
2014-02-26 22:25 ` Andrew Morton
2014-02-26 22:35 ` Peter Zijlstra
2014-04-09 11:16 ` Peter Zijlstra
2014-04-09 19:05 ` Andrew Morton [this message]
2014-02-27 3:12 ` Stephen Rothwell
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=20140409120514.da292ccfd5530a995090228d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=gregory.clement@free-electrons.com \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).