mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
this_cpu: Use this_cpu operations for SNMP statistics
SNMP statistic macros can be signficantly simplified. This will also reduce code size if the arch supports these operations in hardware. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Christoph Lameter <cl@linux-foundation.org> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
30ed1a79f5
commit
4eb41d10c7
1 changed files with 18 additions and 32 deletions
|
@ -136,45 +136,31 @@ struct linux_xfrm_mib {
|
||||||
#define SNMP_STAT_BHPTR(name) (name[0])
|
#define SNMP_STAT_BHPTR(name) (name[0])
|
||||||
#define SNMP_STAT_USRPTR(name) (name[1])
|
#define SNMP_STAT_USRPTR(name) (name[1])
|
||||||
|
|
||||||
#define SNMP_INC_STATS_BH(mib, field) \
|
#define SNMP_INC_STATS_BH(mib, field) \
|
||||||
(per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++)
|
__this_cpu_inc(mib[0]->mibs[field])
|
||||||
#define SNMP_INC_STATS_USER(mib, field) \
|
#define SNMP_INC_STATS_USER(mib, field) \
|
||||||
do { \
|
this_cpu_inc(mib[1]->mibs[field])
|
||||||
per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \
|
#define SNMP_INC_STATS(mib, field) \
|
||||||
put_cpu(); \
|
this_cpu_inc(mib[!in_softirq()]->mibs[field])
|
||||||
} while (0)
|
#define SNMP_DEC_STATS(mib, field) \
|
||||||
#define SNMP_INC_STATS(mib, field) \
|
this_cpu_dec(mib[!in_softirq()]->mibs[field])
|
||||||
do { \
|
#define SNMP_ADD_STATS_BH(mib, field, addend) \
|
||||||
per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \
|
__this_cpu_add(mib[0]->mibs[field], addend)
|
||||||
put_cpu(); \
|
#define SNMP_ADD_STATS_USER(mib, field, addend) \
|
||||||
} while (0)
|
this_cpu_add(mib[1]->mibs[field], addend)
|
||||||
#define SNMP_DEC_STATS(mib, field) \
|
|
||||||
do { \
|
|
||||||
per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]--; \
|
|
||||||
put_cpu(); \
|
|
||||||
} while (0)
|
|
||||||
#define SNMP_ADD_STATS(mib, field, addend) \
|
|
||||||
do { \
|
|
||||||
per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field] += addend; \
|
|
||||||
put_cpu(); \
|
|
||||||
} while (0)
|
|
||||||
#define SNMP_ADD_STATS_BH(mib, field, addend) \
|
|
||||||
(per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
|
|
||||||
#define SNMP_ADD_STATS_USER(mib, field, addend) \
|
|
||||||
do { \
|
|
||||||
per_cpu_ptr(mib[1], get_cpu())->mibs[field] += addend; \
|
|
||||||
put_cpu(); \
|
|
||||||
} while (0)
|
|
||||||
#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
|
#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
|
||||||
do { \
|
do { \
|
||||||
__typeof__(mib[0]) ptr = per_cpu_ptr(mib[!in_softirq()], get_cpu());\
|
__typeof__(mib[0]) ptr; \
|
||||||
|
preempt_disable(); \
|
||||||
|
ptr = this_cpu_ptr((mib)[!in_softirq()]); \
|
||||||
ptr->mibs[basefield##PKTS]++; \
|
ptr->mibs[basefield##PKTS]++; \
|
||||||
ptr->mibs[basefield##OCTETS] += addend;\
|
ptr->mibs[basefield##OCTETS] += addend;\
|
||||||
put_cpu(); \
|
preempt_enable(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
|
#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
|
||||||
do { \
|
do { \
|
||||||
__typeof__(mib[0]) ptr = per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id());\
|
__typeof__(mib[0]) ptr = \
|
||||||
|
__this_cpu_ptr((mib)[!in_softirq()]); \
|
||||||
ptr->mibs[basefield##PKTS]++; \
|
ptr->mibs[basefield##PKTS]++; \
|
||||||
ptr->mibs[basefield##OCTETS] += addend;\
|
ptr->mibs[basefield##OCTETS] += addend;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
Loading…
Reference in a new issue