From: Eric Dumazet <dada1@cosmosbay.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] snmp: add missing counters for RFC 4293
Date: Thu, 23 Apr 2009 19:13:44 +0200 [thread overview]
Message-ID: <49F0A1C8.5080601@cosmosbay.com> (raw)
In-Reply-To: <20090423165620.GB30405@hmsreliant.think-freely.org>
Neil Horman a écrit :
> On Thu, Apr 23, 2009 at 06:37:07PM +0200, Eric Dumazet wrote:
>> Neil Horman a écrit :
>>> On Wed, Apr 22, 2009 at 07:39:55PM +0200, Eric Dumazet wrote:
>>>> <previous contents snipped>
>>>>
>>>
>>> ok, new patch, functionally equivalent, with the following enhancements:
>>>
>>> 1) Replaces INRECEIVES/OUTREQUESTS with INPKTS/OUTPKTS. I did this
>>> so that I could use the dual count update in (2) for INPKTS/INOCTETS
>>> and OUTPKTS/OUTOCTETS
>>> 2) Added dual stat update routines for IP/IP6, named *_UPD_PO_STATS[_BH]
>>> which updates a pair of stats, a P(acket) count, and an (O)ctet count
>>> 3) Added BCASTPKS/BCASTOCTETS for completeness
>>>
>>>
>>>
>>> The IP MIB (RFC 4293) defines stats for InOctets, OutOctets, InMcastOctets and
>>> OutMcastOctets:
>>> http://tools.ietf.org/html/rfc4293
>>> But it seems we don't track those in any way that easy to separate from other
>>> protocols. This patch adds those missing counters to the stats file. Tested
>>> successfully by me
>>>
>>> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
>>>
>>
>>
>>> +#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
>>> + do { \
>>> + int __cpu = get_cpu(); \
>>> + per_cpu_ptr(mib[!in_softirq()], __cpu)->mibs[basefield##PKTS]++; \
>>> + per_cpu_ptr(mib[!in_softirq()], __cpu)->mibs[basefield##OCTETS] += addend;\
>>> + put_cpu(); \
>>> + } while (0)
>> Following should be faster, because per_cpu_ptr() and !in_softirq() factorization.
>>
>>> +#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
>>> + do { \
>>> + __typeof__(mib[0]) ptr = per_cpu_ptr(mib[!in_softirq()], get_cpu()); \
>>> + ptr->mibs[basefield##PKTS]++; \
>>> + ptr->mibs[basefield##OCTETS] += addend;\
>>> + put_cpu(); \
>>> + } while (0)
>> BTW, we miss HC (64bits) values on 32bit arches, and some RFC (not 4293, but in 4113) mention they
>> should be provided if counters can be updated more than 1 million times per second.
>>
>> And for Octets counters, this is definitly the case with 100 Mbit networks... Oh well
> Yeah, I was wondering about this. Think it would be worthwhile to export all of
> these counters as 64 bit, rather than 32 bit? Userspace can then have the HC
> counters, and downcast to the standard 32 bit flavors. I'd like this patch to
> stand as it is, but I think that might be a good subsequent change to make
Well, maintaining 64bits counters on 32bit is going to be hard, since
we dont want a reader to get mangled values while folding SNMP values
Either we use same tricks than netfilter (so that updates can use regular ptr->field += bytes)
and look the mess...
Either we use expensive locking...
At least, your SNMP_UPD_PO_STATS macros can be changed later if we really want
HC values.
next prev parent reply other threads:[~2009-04-23 17:13 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 19:39 [PATCH] snmp: add missing counters for RFC 4293 Neil Horman
2009-04-21 19:58 ` Eric Dumazet
2009-04-21 20:09 ` Neil Horman
2009-04-21 20:45 ` Eric Dumazet
2009-04-21 23:03 ` Neil Horman
2009-04-22 1:12 ` Neil Horman
2009-04-22 5:15 ` Eric Dumazet
2009-04-22 9:08 ` David Miller
2009-04-22 9:35 ` Eric Dumazet
2009-04-22 9:50 ` David Miller
2009-04-22 10:53 ` Neil Horman
2009-04-22 16:50 ` Neil Horman
2009-04-22 17:39 ` Eric Dumazet
2009-04-22 18:44 ` Neil Horman
2009-04-23 15:28 ` Neil Horman
2009-04-23 16:37 ` Eric Dumazet
2009-04-23 16:56 ` Neil Horman
2009-04-23 17:13 ` Eric Dumazet [this message]
2009-04-23 17:25 ` Neil Horman
2009-04-23 17:32 ` Eric Dumazet
2009-04-23 18:28 ` Neil Horman
2009-04-24 14:10 ` Eric Dumazet
2009-04-24 17:06 ` Neil Horman
2009-04-24 18:37 ` Neil Horman
2009-04-27 9:45 ` David Miller
2009-04-22 5:17 ` Eric Dumazet
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=49F0A1C8.5080601@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
/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;
as well as URLs for NNTP newsgroup(s).