SNMP_ADD_STATS
Subsystems (2)
Hi,
I've been cleaning up the network stacks and one thing that made me
have a use for the barf bags I have handy is this type of construct:
ip_statistics[smp_processor_id()*2 + !in_softirq()].IpFragCreates += nfrags;
I've noticed that there is:
#define SNMP_INC_STATS(mib, field) ((mib)[2*smp_processor_id()+!in_softirq()].field++)
and
#define IP_INC_STATS(field) SNMP_INC_STATS(ip_statistics, field)
So I propose that we have
#define SNMP_ADD_STATS(mib, field, incr) ((mib)[2*smp_processor_id()+!in_softirq()].field += incr)
and
#define IP_ADD_STATS(field,incr) SNMP_ADD_STATS(ip_statistics, field, incr)
Any objections?
- Arnaldo
Hello!
Quoted 1 line
Any objections?
No objections, of course. In any case, access to per-cpu stats is to be macroized to work with preemption.
Alexey
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Wed, 12 Jun 2002 15:23:48 -0300
So I propose that we have
#define SNMP_ADD_STATS(mib, field, incr) ((mib)[2*smp_processor_id()+!in_softirq()].field += incr)
and
#define IP_ADD_STATS(field,incr) SNMP_ADD_STATS(ip_statistics, field, incr)
Any objections?
No problem.
Quoted 3 lines
#define
IP_ADD_STATS(field,incr)SNMP_ADD_STATS(ip_statistics, field, incr)Any objections?
Better use per_cpu data in 2.5 (<asm/percpu.h>) for the MIBs.
That's much more efficient on some architectures, uses less memory on all and is also cleaner.
-Andi