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 17:53:21 +0100 [thread overview]
Message-ID: <1300380801.6315.306.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1103171016270.12540@router.home>
Le jeudi 17 mars 2011 à 10:18 -0500, Christoph Lameter a écrit :
> On Thu, 17 Mar 2011, David Miller wrote:
>
> >
> > I had been meaning to bring this up from another perspective.
> >
> > In networking, we often only ever access objects in base or
> > BH context. Therefore in BH context cases we can do just
> > normal counter bumps without any of the special atomic or
> > IRQ disabling code at all.
>
> We have the __ functions for that purpose. __this_cpu_inc f.e. falls back
> to a simply ++ operation if the arch cannot provide something better.
> irqsafe_xx are only used if the context does not provide any protection
> and if there is the potential of the counter being incremented from an
> interrupt context.
>
What David and I have in mind is to use one array per mib instead of
two. This is an old idea.
https://patchwork.kernel.org/patch/15883/
When we know we run from BH context, we can use __this_cpu_inc(), but if
we dont know or run from user/process context, we would need irqsafe_inc
variant.
For x86 this maps to same single instruction, but for other arches, this
might be too expensive.
BTW, I think following patch is possible to save some text and useless
tests (on 64bit platform at least)
size vmlinux.old vmlinux
Thanks
[PATCH] snmp: SNMP_UPD_PO_STATS_BH() always called from softirq
We dont need to test if we run from softirq context.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
---
include/net/snmp.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/snmp.h b/include/net/snmp.h
index 762e2ab..be2424d 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -149,8 +149,8 @@ struct linux_xfrm_mib {
} while (0)
#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
do { \
- __typeof__(*mib[0]) *ptr = \
- __this_cpu_ptr((mib)[!in_softirq()]); \
+ __typeof__(*mib[0]) *ptr = __this_cpu_ptr((mib)[0]); \
+ \
ptr->mibs[basefield##PKTS]++; \
ptr->mibs[basefield##OCTETS] += addend;\
} while (0)
next prev parent reply other threads:[~2011-03-17 16:54 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 [this message]
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
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=1300380801.6315.306.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