lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 10 Apr 2014 19:29:38 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Frederic Weisbecker <fweisbec@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 1/5] sched: Convert thread_group_cputime() to use
	for_each_thread()

On 04/10, Peter Zijlstra wrote:
>
> On Wed, Apr 09, 2014 at 09:49:57PM +0200, Peter Zijlstra wrote:
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2377,6 +2377,9 @@ extern bool current_is_single_threaded(void);
>  /*
>   * Careful: do_each_thread/while_each_thread is a double loop so
>   *          'break' will not work as expected - use goto instead.
> + *
> + * Deprecated; use for_each_thread() instead; this has serious issues with
> + * g != current and RCU.
>   */

Yes, thanks.

>  #define do_each_thread(g, t) \
>  	for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
> @@ -2384,11 +2387,8 @@ extern bool current_is_single_threaded(void);
>  #define while_each_thread(g, t) \
>  	while ((t = next_thread(t)) != g)
>  
> -#define __for_each_thread(signal, t)	\
> -	list_for_each_entry_rcu(t, &(signal)->thread_head, thread_node)
> -
>  #define for_each_thread(p, t)		\
> -	__for_each_thread((p)->signal, t)
> +	list_for_each_entry_rcu(t, &(p)->signal->thread_head, thread_node)

Why? __for_each_thread(signal) can generate a better code, if we do care.

In fact, ignoring the bad "signal" name, __for_each_thread(signal, t)
even looks better. "signal" represents the whole thread group.

But I won't argue. Besides, this reminds me about CONST_CAST() and making
task_struct->signal "const". This can improve the code generation too.

> +static inline __deprecated
> +struct task_struct *next_thread(const struct task_struct *p)
>  {

Not sure... But probably fine too.

I already killed some users of next_thread(). This reminds me about
next_tid(), probably it should be converted too.

As for, say, __exit_signal() it really needs next_thread(). We can fix
it instead of deprecating, or we can add another one with another name.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists