net: Introduce helper functions to get the per cpu data
Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
06fb4e701b
commit
c4c6bc3146
@ -202,10 +202,20 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
|
|||||||
#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
|
#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
|
||||||
#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
|
#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
|
||||||
|
|
||||||
|
u64 snmp_get_cpu_field(void __percpu *mib, int cpu, int offct);
|
||||||
unsigned long snmp_fold_field(void __percpu *mib, int offt);
|
unsigned long snmp_fold_field(void __percpu *mib, int offt);
|
||||||
#if BITS_PER_LONG==32
|
#if BITS_PER_LONG==32
|
||||||
|
u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
|
||||||
|
size_t syncp_offset);
|
||||||
u64 snmp_fold_field64(void __percpu *mib, int offt, size_t sync_off);
|
u64 snmp_fold_field64(void __percpu *mib, int offt, size_t sync_off);
|
||||||
#else
|
#else
|
||||||
|
static inline u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
|
||||||
|
size_t syncp_offset)
|
||||||
|
{
|
||||||
|
return snmp_get_cpu_field(mib, cpu, offct);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_off)
|
static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_off)
|
||||||
{
|
{
|
||||||
return snmp_fold_field(mib, offt);
|
return snmp_fold_field(mib, offt);
|
||||||
|
@ -1452,25 +1452,28 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(inet_ctl_sock_create);
|
EXPORT_SYMBOL_GPL(inet_ctl_sock_create);
|
||||||
|
|
||||||
|
u64 snmp_get_cpu_field(void __percpu *mib, int cpu, int offt)
|
||||||
|
{
|
||||||
|
return *(((unsigned long *)per_cpu_ptr(mib, cpu)) + offt);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snmp_get_cpu_field);
|
||||||
|
|
||||||
unsigned long snmp_fold_field(void __percpu *mib, int offt)
|
unsigned long snmp_fold_field(void __percpu *mib, int offt)
|
||||||
{
|
{
|
||||||
unsigned long res = 0;
|
unsigned long res = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for_each_possible_cpu(i)
|
for_each_possible_cpu(i)
|
||||||
res += *(((unsigned long *) per_cpu_ptr(mib, i)) + offt);
|
res += snmp_get_cpu_field(mib, i, offt);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snmp_fold_field);
|
EXPORT_SYMBOL_GPL(snmp_fold_field);
|
||||||
|
|
||||||
#if BITS_PER_LONG==32
|
#if BITS_PER_LONG==32
|
||||||
|
|
||||||
u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset)
|
u64 snmp_get_cpu_field64(void __percpu *mib, int cpu, int offct,
|
||||||
|
size_t syncp_offset)
|
||||||
{
|
{
|
||||||
u64 res = 0;
|
|
||||||
int cpu;
|
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
|
||||||
void *bhptr;
|
void *bhptr;
|
||||||
struct u64_stats_sync *syncp;
|
struct u64_stats_sync *syncp;
|
||||||
u64 v;
|
u64 v;
|
||||||
@ -1483,7 +1486,17 @@ u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset)
|
|||||||
v = *(((u64 *)bhptr) + offt);
|
v = *(((u64 *)bhptr) + offt);
|
||||||
} while (u64_stats_fetch_retry_irq(syncp, start));
|
} while (u64_stats_fetch_retry_irq(syncp, start));
|
||||||
|
|
||||||
res += v;
|
return v;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(snmp_get_cpu_field64);
|
||||||
|
|
||||||
|
u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset)
|
||||||
|
{
|
||||||
|
u64 res = 0;
|
||||||
|
int cpu;
|
||||||
|
|
||||||
|
for_each_possible_cpu(cpu) {
|
||||||
|
res += snmp_get_cpu_field(mib, cpu, offct, syncp_offset);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user