Skip to contentSkip to conversation

SNMP_ADD_STATS

RFC Arnaldo Carvalho de Melo 4 participants 4 messages Jun 12, 2002 – Jun 13, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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

#2 lore raw
In reply to Arnaldo Carvalho de Melo

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.

#3 lore raw
In reply to Arnaldo Carvalho de Melo
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