From: Eric Dumazet <eric.dumazet@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org
Subject: Re: Poll about irqsafe_cpu_add and others
Date: Thu, 17 Mar 2011 19:55:39 +0100 [thread overview]
Message-ID: <1300388139.6315.418.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1103171338350.18529@router.home>
Le jeudi 17 mars 2011 à 13:42 -0500, Christoph Lameter a écrit :
> On Thu, 17 Mar 2011, Eric Dumazet wrote:
>
> > By the way, I noticed :
> >
> > DECLARE_PER_CPU(u64, xt_u64);
> > __this_cpu_add(xt_u64, 2) translates to following x86_32 code :
> >
> > mov $xt_u64,%eax
> > add %fs:0x0,%eax
> > addl $0x2,(%eax)
> > adcl $0x0,0x4(%eax)
> >
> >
> > I wonder why we dont use :
> >
> > addl $0x2,%fs:xt_u64
> > addcl $0x0,%fs:xt_u64+4
>
> The compiler is fed the following
>
> *__this_cpu_ptr(xt_u64) += 2
>
> __this_cpu_ptr makes it:
>
> *(xt_u64 + __my_cpu_offset) += 2
>
> So the compiler calculates the address first and then increments it.
>
> The compiler could optimize this I think. Wonder why that does not happen.
Compiler is really forced to compute addr, thats why.
Hmm, we should not fallback to generic ops I think, but tweak
percpu_add_op() {
...
case 8:
#if CONFIG_X86_64_SMP
if (pao_ID__ == 1) \
asm("incq "__percpu_arg(0) : "+m" (var)); \
else if (pao_ID__ == -1) \
asm("decq "__percpu_arg(0) : "+m" (var)); \
else \
asm("addq %1, "__percpu_arg(0) \
: "+m" (var) \
: "re" ((pao_T__)(val))); \
break; \
#else
asm("addl %1, "__percpu_arg(0) \
: "+m" (var) \
: "ri" ((u32)(val))); \
asm("adcl %1, "__percpu_arg(0) \
: "+m" ((char *)var+4) \
: "ri" ((u32)(val>>32)); \
break; \
#endif
....
}
next prev parent reply other threads:[~2011-03-17 18:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 14:23 Poll about irqsafe_cpu_add and others Eric Dumazet
2011-03-17 14:23 ` Eric Dumazet
2011-03-17 14:40 ` Christoph Lameter
2011-03-17 15:14 ` David Miller
2011-03-17 15:14 ` David Miller
2011-03-17 15:18 ` Christoph Lameter
2011-03-17 15:18 ` Christoph Lameter
2011-03-17 16:53 ` Eric Dumazet
2011-03-17 17:46 ` Christoph Lameter
2011-03-17 18:29 ` Eric Dumazet
2011-03-17 18:29 ` Eric Dumazet
2011-03-17 18:42 ` Christoph Lameter
2011-03-17 18:42 ` Christoph Lameter
2011-03-17 18:55 ` Eric Dumazet [this message]
2011-03-17 19:21 ` Christoph Lameter
2011-03-18 6:56 ` Benjamin Herrenschmidt
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=1300388139.6315.418.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=cl@linux.com \
--cc=davem@davemloft.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.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