From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Howells <dhowells@redhat.com>,
David Smith <dsmith@redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>,
Larry Woodman <lwoodman@redhat.com>,
Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: hlist_for_each_entry && pos (Was: task_work_queue)
Date: Thu, 12 Apr 2012 06:28:50 +0200 [thread overview]
Message-ID: <20120412042850.GA22354@redhat.com> (raw)
In-Reply-To: <CA+55aFyGsA5YPqrymJ8wwoS86SEeJh+X-dvfBTfo3gOTm73JNA@mail.gmail.com>
On 04/11, Linus Torvalds wrote:
>
> On Wed, Apr 11, 2012 at 9:00 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > This reminds me.
> >
> > hlist_for_each_entry_*() do not need "pos", it can be
> >
> > #define hlist_for_each_entry(pos, head, member) \
> > for (pos = (void*)(head)->first; � \
> > pos && ({ pos = hlist_entry((void*)pos, typeof(*pos), member); 1; }); \
> > pos = (void*)(pos)->member.next)
>
> Ugh. I'm not sure that is any better, with the extra casts to hide the
> fact that you use the wrong type pointers for it.
>
> Are there any code generation improvements?
Not sure, I'll check...
> Because quite frankly, if there aren't, I think the code churn just
> isn't worth it - especially with how ugly the macro is.
Ah, personally I think that "how ugly the macro" doesn't matter.
What does matter (imho again), it simplifies the usage.
> This is one of those things where the C99 features would actually be
> nice: one of the few features from C++ that I actually liked is the
> ability to declare the induction variable. So
>
> #define hlist_for_each_entry(pos, head, member) \
> for (void *__pos = (head)->first; \
Agreed. But,
error: 'for' loop initial declaration used outside C99 mode
we should change CFLAGS, I guess. BTW, personally I'd like very much
to use "for (type var; ...")" if this was allowed.
> That said, "pretty macro" isn't very high
> on the list of things to worry about. Not nearly as high as the pain
> changing the interface would cause for things that *should* be trivial
> (like backporting patches etc).
Yes, agreed, that was the question.
> So I'd really want to see some more tangible advantage.
OK, I'll check the code generation just in case.
Oleg.
next prev parent reply other threads:[~2012-04-12 4:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-12 2:47 [PATCH v2 0/2] task_work_queue() && keyctl_session_to_parent() Oleg Nesterov
2012-04-12 2:48 ` [PATCH v2 1/2] task_work_queue: add generic process-context callbacks Oleg Nesterov
2012-04-12 4:00 ` hlist_for_each_entry && pos (Was: task_work_queue) Oleg Nesterov
2012-04-12 4:12 ` Linus Torvalds
2012-04-12 4:28 ` Oleg Nesterov [this message]
2012-04-12 4:39 ` Linus Torvalds
2012-04-12 5:02 ` Al Viro
2012-04-16 22:35 ` Paul E. McKenney
2012-04-17 20:43 ` Oleg Nesterov
2012-04-12 9:35 ` TIF_NOTIFY_RESUME [was Re: [PATCH v2 1/2] task_work_queue: add generic process-context callbacks] David Howells
2012-04-12 17:41 ` Oleg Nesterov
2012-04-12 2:48 ` [PATCH v2 2/2] cred: change keyctl_session_to_parent() to use task_work_queue() Oleg Nesterov
2012-04-12 9:29 ` David Howells
2012-04-12 17:34 ` 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=20120412042850.GA22354@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dsmith@redhat.com \
--cc=fche@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lwoodman@redhat.com \
--cc=peterz@infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox