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, 8 Mar 2012 11:14:39 -0800
From:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:	Lai Jiangshan <laijs@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, dipankar@...ibm.com,
	akpm@...ux-foundation.org, mathieu.desnoyers@...ymtl.ca,
	josh@...htriplett.org, niv@...ibm.com, tglx@...utronix.de,
	peterz@...radead.org, rostedt@...dmis.org, Valdis.Kletnieks@...edu,
	dhowells@...hat.com, eric.dumazet@...il.com, darren@...art.com,
	fweisbec@...il.com, patches@...aro.org
Subject: Re: [PATCH 2/6] Don't touch the snap in srcu_readers_active()

On Tue, Mar 06, 2012 at 05:57:34PM +0800, Lai Jiangshan wrote:
> srcu_readers_active() is called without the mutex, but it touch the snap.
> also achieve better cache locality a little
> 
> Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>

Queued with updated commit-log message, thank you!

							Thanx, Paul

	Expand the calls to srcu_readers_active_idx() from
	srcu_readers_active() inline.  This change improves cache locality
	by interating over the CPUs once rather than twice.

> ---
>  kernel/srcu.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/srcu.c b/kernel/srcu.c
> index b6b9ea2..fbe2d5f 100644
> --- a/kernel/srcu.c
> +++ b/kernel/srcu.c
> @@ -181,7 +181,14 @@ static bool srcu_readers_active_idx_check(struct srcu_struct *sp, int idx)
>   */
>  static int srcu_readers_active(struct srcu_struct *sp)
>  {
> -	return srcu_readers_active_idx(sp, 0) + srcu_readers_active_idx(sp, 1);
> +	int cpu;
> +	unsigned long sum = 0;
> +
> +	for_each_possible_cpu(cpu) {
> +		sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[0]);
> +		sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[1]);
> +	}
> +	return sum & SRCU_REF_MASK;
>  }
> 
>  /**
> -- 
> 1.7.4.4
> 

--
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