From: Eric Dumazet <eric.dumazet@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: percpu: Implement this_cpu_add,sub,dec,inc_return
Date: Sat, 20 Nov 2010 10:50:29 +0100 [thread overview]
Message-ID: <1290246629.2756.68.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1011191158240.4423@router.home>
Le vendredi 19 novembre 2010 A 11:59 -0600, Christoph Lameter a A(C)crit :
> On Fri, 19 Nov 2010, Christoph Lameter wrote:
>
> > Ok so rename the macros to this_cpu_return_inc/dec/add/sub?
>
> Actually this is fetchadd. So call I will call this this_cpu_fetch_add/inc/dec/sub.
>
It doesnt really matter, because the final "res += added_value" can be
optimized out by compiler if needed, since its C code.
For example in net/core/neighbour.c, function neigh_alloc() we do
entries = atomic_inc_return(&tbl->entries) - 1;
if (entries >= tbl->gc_thresh3 ||
This generates this optimal code :
mov $0x1,%eax
lock xadd %eax,0x1d0(%rdi)
cmp 0xdc(%rdi),%eax
Yes, if we had atomic_fetch_inc() this could be written :
entries = atomic_fetch_inc(&tbl->entries);
if (entries >= tbl->gc_thresh3 ||
Not sure its clearer in this form.
Is it worth adding another seldom used API ?
Everybody understand the xxxx_inc_return() idiom
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2010-11-20 9:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 17:27 vmstat: Optimize zone counter modifications through the use of this cpu operations Christoph Lameter
2010-11-10 15:40 ` percpu: Implement this_cpu_add,sub,dec,inc_return Christoph Lameter
2010-11-17 18:28 ` Eric Dumazet
2010-11-19 15:42 ` Christoph Lameter
2010-11-19 15:51 ` Eric Dumazet
2010-11-19 15:59 ` Christoph Lameter
2010-11-19 16:12 ` Eric Dumazet
2010-11-19 17:09 ` Christoph Lameter
2010-11-19 17:59 ` Christoph Lameter
2010-11-20 9:50 ` Eric Dumazet [this message]
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=1290246629.2756.68.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=linux-mm@kvack.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