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]
Message-ID: <alpine.DEB.2.00.1010071440220.28032@router.home>
Date:	Thu, 7 Oct 2010 14:42:02 -0500 (CDT)
From:	Christoph Lameter <cl@...ux.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] percpu_counter: change inaccurate comment

On Thu, 7 Oct 2010, Eric Dumazet wrote:

> percpu_counter used to be huge objects, they are not anymore,
> thanks to fine alloc_percpu() granularity.
>
> We now consume 4 bytes per possible cpu.

Ahh I did not notice that they switched.... Then we may also want the
following patch to improve performance. It would even be better if we
could do a this_cpu_add(fbc->counters, amount) there but the 64 bit size
fo count looks suspiciously like you are expecting overflows beyond ints
max size.


Subject: percpu_counter: Use this_cpu_ptr instead of per_cpu_ptr

this_cpu_ptr avoids an array lookup and can use the percpu
offset of the local cpu directly.

Signed-off-by: Christoph Lameter <cl@...ux.com>

---
 lib/percpu_counter.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/lib/percpu_counter.c
===================================================================
--- linux-2.6.orig/lib/percpu_counter.c	2010-10-07 14:36:39.000000000 -0500
+++ linux-2.6/lib/percpu_counter.c	2010-10-07 14:38:43.000000000 -0500
@@ -30,9 +30,9 @@ void __percpu_counter_add(struct percpu_
 {
 	s64 count;
 	s32 *pcount;
-	int cpu = get_cpu();

-	pcount = per_cpu_ptr(fbc->counters, cpu);
+	preempt_disable();
+	pcount = this_cpu_ptr(fbc->counters);
 	count = *pcount + amount;
 	if (count >= batch || count <= -batch) {
 		spin_lock(&fbc->lock);
@@ -42,7 +42,7 @@ void __percpu_counter_add(struct percpu_
 	} else {
 		*pcount = count;
 	}
-	put_cpu();
+	preempt_enable();
 }
 EXPORT_SYMBOL(__percpu_counter_add);

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