All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jiri Slaby <jirislaby@gmail.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 16:49:36 +0100	[thread overview]
Message-ID: <20090224154936.GA13837@redhat.com> (raw)
In-Reply-To: <49A3F48E.5030008@gmail.com>

On 02/24, Jiri Slaby wrote:
>
> 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 :)

Well, I agree, it is not very nice ;)

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.

> Otherwise I'll add at least a big warning about using break/cont
> statements inside the loop.

Agreed, this would be nice.

>> +#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?

Oleg.


  reply	other threads:[~2009-02-24 15:52 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 [this message]
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=20090224154936.GA13837@redhat.com \
    --to=oleg@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=jirislaby@gmail.com \
    --cc=kenchen@google.com \
    --cc=linux-kernel@vger.kernel.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.