From: Christoph Hellwig <hch@infradead.org>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@osdl.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pids: simplify do_each_task_pid/while_each_task_pid
Date: Thu, 13 Apr 2006 14:38:14 +0100 [thread overview]
Message-ID: <20060413133814.GA29914@infradead.org> (raw)
In-Reply-To: <20060413163727.GA1365@oleg>
On Thu, Apr 13, 2006 at 08:37:27PM +0400, Oleg Nesterov wrote:
> Simpllify do_each_task_pid/while_each_task_pid macros.
> This also makes the code a bit smaller.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>
> --- MM/include/linux/pid.h~ 2006-03-23 22:48:10.000000000 +0300
> +++ MM/include/linux/pid.h 2006-04-13 20:28:53.000000000 +0400
> @@ -99,21 +99,16 @@ extern void FASTCALL(free_pid(struct pid
> pids[(type)].node)
>
>
> -/* We could use hlist_for_each_entry_rcu here but it takes more arguments
> - * than the do_each_task_pid/while_each_task_pid. So we roll our own
> - * to preserve the existing interface.
> - */
> -#define do_each_task_pid(who, type, task) \
> - if ((task = find_task_by_pid_type(type, who))) { \
> - prefetch(pid_next(task, type)); \
> - do {
> -
> -#define while_each_task_pid(who, type, task) \
> - } while (pid_next(task, type) && ({ \
> - task = pid_next_task(task, type); \
> - rcu_dereference(task); \
> - prefetch(pid_next(task, type)); \
> - 1; }) ); \
> - }
> +#define do_each_task_pid(who, type, task) \
> + do { \
> + struct hlist_node *pos___; \
> + struct pid *pid___ = find_pid(who); \
> + if (pid___ != NULL) \
> + hlist_for_each_entry_rcu((task), pos___, \
> + &pid___->tasks[type], pids[type].node) {
> +
> +#define while_each_task_pid(who, type, task) \
> + } \
> + } while (0)
This is prtty ugly. Can't we just have a
#define for_each_task_pid(task, pid, type, pos) \
hlist_for_each_entry_rcu((task), (pos), \
(&(pid))->tasks[type], pids[type].node) {
and move the find_pid to the caller? That would make the code a whole lot
more readable.
next prev parent reply other threads:[~2006-04-13 13:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-13 16:37 [PATCH] pids: simplify do_each_task_pid/while_each_task_pid Oleg Nesterov
2006-04-13 13:38 ` Christoph Hellwig [this message]
2006-04-13 17:54 ` Oleg Nesterov
2006-04-13 14:27 ` Arjan van de Ven
2006-04-13 15:07 ` Christoph Hellwig
2006-04-13 20:21 ` Oleg Nesterov
2006-04-13 16:32 ` Christoph Hellwig
2006-04-13 17:50 ` Eric W. Biederman
2006-04-13 21:56 ` 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=20060413133814.GA29914@infradead.org \
--to=hch@infradead.org \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/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