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 14:22:22 +0100 [thread overview]
Message-ID: <49A3F48E.5030008@gmail.com> (raw)
In-Reply-To: <20081215170937.GA24080@redhat.com>
On 15.12.2008 18:09, Oleg Nesterov wrote:
> On 12/15, Oleg Nesterov wrote:
>> On 12/14, Eric W. Biederman wrote:
>>> Although seeing the unexpected corner case it gets us into I think it would
>>> be good to reconsider this test.
>
> So. I can't decide whether this patch is cleanup or the further
> uglification, but if anyone likes it I will be happy to send it.
FWIW I don't like the patch :), but noone else appears to dislike it.
Ideas, comments?
Otherwise I'll add at least a big warning about using break/cont
statements inside the loop.
> Then we can kill do_each_pid_task/while_each_pid_task completely.
>
> Oleg.
>
> --- linux-2.6.27/include/linux/pid.h~PID_FOR_EACH 2008-10-10 00:13:53.000000000 +0200
> +++ linux-2.6.27/include/linux/pid.h 2008-12-15 17:51:50.000000000 +0100
> @@ -144,21 +144,25 @@ static inline pid_t pid_nr(struct pid *p
> pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
> pid_t pid_vnr(struct pid *pid);
>
> +/*
> + * Both old and new leaders may be attached to the same pid in the
> + * middle of de_thread(), that is why we do the special check for
> + * PIDTYPE_PID below.
> + */
> +#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)
> +
> #define do_each_pid_task(pid, type, task) \
> do { \
> - struct hlist_node *pos___; \
> - if (pid != NULL) \
> - hlist_for_each_entry_rcu((task), pos___, \
> - &pid->tasks[type], pids[type].node) {
> + pid_for_each_task(pid, type, task)
>
> - /*
> - * Both old and new leaders may be attached to
> - * the same pid in the middle of de_thread().
> - */
> #define while_each_pid_task(pid, type, task) \
> - if (type == PIDTYPE_PID) \
> - break; \
> - } \
> } while (0)
>
> #define do_each_pid_thread(pid, type, task) \
>
next prev parent reply other threads:[~2009-02-24 13:22 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 [this message]
2009-02-24 15:49 ` Oleg Nesterov
2009-02-24 16:21 ` Jiri Slaby
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=49A3F48E.5030008@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