From: Jiri Slaby <jirislaby@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
kenchen@google.com,
Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: broken do_each_pid_{thread,task}
Date: Tue, 24 Feb 2009 17:21:36 +0100 [thread overview]
Message-ID: <49A41E90.8090304@gmail.com> (raw)
In-Reply-To: <20090224154936.GA13837@redhat.com>
On 24.2.2009 16:49, Oleg Nesterov wrote:
> But why do you dislike it? Yes, the implementation of pid_for_each_task()
> is not simple. Partly because hlist_for_each_entry_rcu() is ugly and
> imho should be fixed (see btw http://marc.info/?t=120879441200004).
>
> But with this patch the callers become simpler, we can just do
>
> pid_for_each_task(pid, type, task)
> do_something(task);
>
> instead of
>
> do_each_pid_task(pid, type, task) {
> do_something(task);
> } while_each_pid_task(pid, type, task);
>
> and we can use break/continue safely.
I like what it does, not much how. Anyway I was thinking about
hlist_for_each_entry_rcu_param or alike (which would take additional
parameters for 3 `for' expressions to add to standard hlist for each
ones), but I think it would be less readable than this:
>>> +#define pid_for_each_task(pid, type, p) \
>>> + for (p = (pid) ? (void*)(pid)->tasks[type].first : NULL; \
>>> + rcu_dereference(p)&& ({ \
>>> + prefetch(((struct hlist_node*)p)->next); \
>>> + p = hlist_entry((void*)p, typeof(*p), pids[type].node); \
>>> + 1; }); \
>>> + p = ((type) != PIDTYPE_PID) ? \
>>> + (void*)(p)->pids[type].node.next : NULL)
>>> +
>
> Really, is this too bad?
Well, it still can be worse :).
Ok, could you repost with commit log and proper CCs or merge anywhere to
pull from?
next prev parent reply other threads:[~2009-02-24 16:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-14 21:59 broken do_each_pid_{thread,task} Jiri Slaby
2008-12-15 1:02 ` Eric W. Biederman
2008-12-15 10:47 ` Oleg Nesterov
2008-12-15 17:09 ` Oleg Nesterov
2009-02-24 13:22 ` Jiri Slaby
2009-02-24 15:49 ` Oleg Nesterov
2009-02-24 16:21 ` Jiri Slaby [this message]
2009-02-24 21:49 ` [RFC, PATCH] introduce pid_for_each_task() to replace do_each_pid_task() Oleg Nesterov
2008-12-15 10:24 ` broken do_each_pid_{thread,task} Oleg Nesterov
2008-12-15 10:50 ` Jiri Slaby
2008-12-15 11:02 ` Oleg Nesterov
2008-12-15 11:33 ` Jiri Slaby
2008-12-15 11:51 ` Oleg Nesterov
2009-10-12 10:55 ` Jiri Slaby
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=49A41E90.8090304@gmail.com \
--to=jirislaby@gmail.com \
--cc=ebiederm@xmission.com \
--cc=kenchen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/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