From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Christoph Lameter <cl@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org, Mel Gorman <mel@csn.ul.ie>,
Pekka Enberg <penberg@cs.helsinki.fi>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [this_cpu_xx V7 0/8] Per cpu atomics in core allocators and cleanup
Date: Thu, 17 Dec 2009 15:25:58 -0500 [thread overview]
Message-ID: <20091217202558.GA21713@Krystal> (raw)
In-Reply-To: <alpine.DEB.2.00.0912171327220.3638@router.home>
* Christoph Lameter (cl@linux-foundation.org) wrote:
> > However, I would need:
> >
> > this_cpu_cmpxchg(scalar, oldv, newv)
> > (maps to x86 cmpxchg)
> >
> > this_cpu_add_return(scalar, value)
> > (maps to x86 xadd)
> >
> > too. Is that a planned addition ?
>
> It was not necessary. Its easy to add though.
>
> > (while we are at it, we might as will add the xchg instruction,
> > althrough it has an implied LOCK prefix on x86).
>
> Well yeah thats a thorny one. One could use the cmpxchg instead?
Yes, although maybe it would make sense to encapsulate it in a xchg
primitive anyway, in case some architecture has a better xchg than x86.
For instance, powerpc, with its linked load/store conditional, can skip
a comparison for xchg that's otherwise required for cmpxchg.
Some quick test on my Intel Xeon E5405:
local cmpxchg: 14 cycles
xchg: 18 cycles
So yes, indeed, the non-LOCK prefixed local cmpxchg seems a bit faster
than the xchg, given the latter has an implied LOCK prefix.
Code used for local cmpxchg:
old = var;
do {
ret = cmpxchg_local(&var, old, 4);
if (likely(ret == old))
break;
old = ret;
} while (1);
Thanks,
Mathieu
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2009-12-17 20:26 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 22:03 [this_cpu_xx V7 0/8] Per cpu atomics in core allocators and cleanup Christoph Lameter
2009-12-14 22:03 ` [this_cpu_xx V7 1/8] this_cpu_ops: page allocator conversion Christoph Lameter
2009-12-15 3:53 ` Tejun Heo
2009-12-15 15:04 ` Christoph Lameter
2009-12-16 0:53 ` Tejun Heo
2009-12-16 14:55 ` Christoph Lameter
2009-12-17 0:23 ` Tejun Heo
2009-12-14 22:03 ` [this_cpu_xx V7 2/8] this_cpu ops: Remove pageset_notifier Christoph Lameter
2009-12-14 22:03 ` [this_cpu_xx V7 3/8] Use this_cpu operations in slub Christoph Lameter
2009-12-14 22:03 ` [this_cpu_xx V7 4/8] SLUB: Get rid of dynamic DMA kmalloc cache allocation Christoph Lameter
2009-12-14 22:03 ` [this_cpu_xx V7 5/8] this_cpu: Remove slub kmem_cache fields Christoph Lameter
2009-12-14 22:03 ` [this_cpu_xx V7 6/8] Make slub statistics use this_cpu_inc Christoph Lameter
2009-12-15 6:24 ` Eric Dumazet
2009-12-15 14:46 ` Christoph Lameter
2009-12-15 14:59 ` Eric Dumazet
2009-12-14 22:03 ` [this_cpu_xx V7 7/8] Module handling: Use this_cpu_xx to dynamically allocate counters Christoph Lameter
2009-12-15 4:03 ` Tejun Heo
2009-12-15 22:41 ` Rusty Russell
2009-12-16 16:10 ` Christoph Lameter
2009-12-17 0:25 ` Tejun Heo
2009-12-17 5:42 ` Rusty Russell
2009-12-14 22:03 ` [this_cpu_xx V7 8/8] Remove cpu_local_xx macros Christoph Lameter
2009-12-15 4:04 ` Tejun Heo
2009-12-15 6:37 ` [this_cpu_xx V7 0/8] Per cpu atomics in core allocators and cleanup Pekka Enberg
2009-12-15 6:47 ` Tejun Heo
2009-12-15 14:50 ` Christoph Lameter
2009-12-15 17:06 ` Mel Gorman
2009-12-16 14:44 ` Christoph Lameter
2009-12-16 21:36 ` Christoph Lameter
2009-12-15 17:43 ` Mathieu Desnoyers
2009-12-16 0:58 ` Tejun Heo
2009-12-16 1:40 ` Mathieu Desnoyers
2009-12-16 1:46 ` Tejun Heo
2009-12-17 13:39 ` Mathieu Desnoyers
2009-12-17 19:28 ` Christoph Lameter
2009-12-17 20:25 ` Mathieu Desnoyers [this message]
2009-12-17 20:43 ` Christoph Lameter
2009-12-18 0:13 ` Mathieu Desnoyers
2009-12-18 0:27 ` Christoph Lameter
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=20091217202558.GA21713@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mel@csn.ul.ie \
--cc=penberg@cs.helsinki.fi \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
/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