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:	Mon, 18 Apr 2011 12:34:33 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Namhyung Kim <namhyung@...il.com>
Cc:	Minchan Kim <minchan.kim@...il.com>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, Tejun Heo <tj@...nel.org>,
	Christoph Lameter <cl@...ux.com>
Subject: Re: [PATCH v2] mempolicy: reduce references to the current

On Fri, 15 Apr 2011 15:08:08 +0900
Namhyung Kim <namhyung@...il.com> wrote:

> Remove duplicated reference to the 'current' task using a local
> variable. Since refering the current can be a burden, it'd better
> cache the reference, IMHO. At least this saves some bytes on x86_64.
> 
>   $ size mempolicy-{old,new}.o
>      text    data    bss     dec     hex filename
>     25203    2448   9176   36827    8fdb mempolicy-old.o
>     25136    2448   9184   36768    8fa0 mempolicy-new.o
> 
> Signed-off-by: Namhyung Kim <namhyung@...il.com>
> ---
>  mm/mempolicy.c |   58 +++++++++++++++++++++++++++++--------------------------
>  1 files changed, 31 insertions(+), 27 deletions(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 959a8b8c7350..5a30065590aa 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -304,6 +304,7 @@ static void mpol_rebind_nodemask(struct mempolicy *pol, const nodemask_t *nodes,
>  				 enum mpol_rebind_step step)
>  {
>  	nodemask_t tmp;
> +	struct task_struct *tsk = current;
>  
>  	if (pol->flags & MPOL_F_STATIC_NODES)
>  		nodes_and(tmp, pol->w.user_nodemask, *nodes);
> @@ -335,12 +336,12 @@ static void mpol_rebind_nodemask(struct mempolicy *pol, const nodemask_t *nodes,
>  	else
>  		BUG();
>  
> -	if (!node_isset(current->il_next, tmp)) {
> -		current->il_next = next_node(current->il_next, tmp);
> -		if (current->il_next >= MAX_NUMNODES)
> -			current->il_next = first_node(tmp);
> -		if (current->il_next >= MAX_NUMNODES)
> -			current->il_next = numa_node_id();
> +	if (!node_isset(tsk->il_next, tmp)) {
> +		tsk->il_next = next_node(tsk->il_next, tmp);
> +		if (tsk->il_next >= MAX_NUMNODES)
> +			tsk->il_next = first_node(tmp);
> +		if (tsk->il_next >= MAX_NUMNODES)
> +			tsk->il_next = numa_node_id();
>  	}
>  }

Odd.  The new(ish) percpu_read_stable() stuff produces very efficient
code for `current' and usually means that caching `current' in a local
is unneeded, often an overall loss.

So... what is going wrong in mempolicy.c?
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ