Change Networking mibs to use kmalloc_percpu -- 1/3
Subsystems (6)
PATCH 1/1 Change Networking mibs to use kmalloc_percpu -- 1/3
Here's a patchset to enable networking mibs to use kmalloc_percpu instead of the traditional padded NR_CPUS arrays.
Advantages:
1. Removes NR_CPUS bloat due to static definition
2. Can support node local allocation
3. Will work with modules
The changes have been split for ipv4, ipv6 and sctp. We can later do away with the __pad and associated logic duing proc reporting (in the mibs) if this patchset is acceptable.
This patch is 1 of 3
D: Name: ipv4mibs-2.5.50-1.patch
D: Author: Ravikiran Thirumalai
D: Description: Changes ipv4 stats to use kmalloc_percpu from the traditional
D: padded NR_CPUS arrays
include/net/icmp.h | 15 ++++++- include/net/ip.h | 6 +- include/net/snmp.h | 39 +++++++++++++------ include/net/tcp.h | 6 +- include/net/udp.h | 2 net/ipv4/af_inet.c | 61 +++++++++++++++++++++++++++++ net/ipv4/icmp.c | 96 ++++++++++++++++++++++------------------------- net/ipv4/ip_input.c | 2 net/ipv4/proc.c | 37 +++++++++--------- net/ipv4/tcp.c | 13 +++--- net/ipv4/tcp_input.c | 4 - net/ipv4/tcp_minisocks.c | 4 - net/ipv4/tcp_timer.c | 3 - net/ipv4/udp.c | 2 14 files changed, 190 insertions(+), 100 deletions(-)
include/net/icmp.h +14 -1
@@ -23,6 +23,7 @@#include <net/sock.h> #include <net/protocol.h> +#include <net/snmp.h> #include <linux/ip.h> struct icmp_err {
@@ -31,10 +32,22 @@ };extern struct icmp_err icmp_err_convert[]; -extern struct icmp_mib icmp_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics);#define ICMP_INC_STATS (field) SNMP_INC_STATS(icmp_statistics, field)#define ICMP_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmp_statistics, field)#define ICMP_INC_STATS_USER (field) SNMP_INC_STATS_USER(icmp_statistics, field) +#define ICMP_INC_STATS_FIELD (offt) \ + (*((unsigned long *) ((void *) \ + per_cpu_ptr(icmp_statistics[!in_softirq()],\ + smp_processor_id())) + offt))++; +#define ICMP_INC_STATS_BH_FIELD (offt) \ + (*((unsigned long *) ((void *) \ + per_cpu_ptr(icmp_statistics[0], \ + smp_processor_id())) + offt))++; +#define ICMP_INC_STATS_USER_FIELD (offt) \ + (*((unsigned long *) ((void *) \ + per_cpu_ptr(icmp_statistics[1], \ + smp_processor_id())) + offt))++;extern void icmp_send (struct sk_buff *skb_in,int type,int code,u32 info);extern int icmp_rcv (struct sk_buff *skb);
include/net/ip.h +4 -2
@@ -149,14 +149,16 @@ };extern struct ipv4_config ipv4_config; -extern struct ip_mib ip_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct ip_mib, ip_statistics);#define IP_INC_STATS (field) SNMP_INC_STATS(ip_statistics, field)#define IP_INC_STATS_BH (field) SNMP_INC_STATS_BH(ip_statistics, field)#define IP_INC_STATS_USER (field) SNMP_INC_STATS_USER(ip_statistics, field) -extern struct linux_mib net_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct linux_mib, net_statistics);#define NET_INC_STATS (field) SNMP_INC_STATS(net_statistics, field)#define NET_INC_STATS_BH (field) SNMP_INC_STATS_BH(net_statistics, field)#define NET_INC_STATS_USER (field) SNMP_INC_STATS_USER(net_statistics, field) +#define NET_ADD_STATS_BH (field, adnd) SNMP_ADD_STATS_BH(net_statistics, field, adnd) +#define NET_ADD_STATS_USER (field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd)extern int sysctl_local_port_range[2 ];extern int sysctl_ip_default_ttl;
include/net/snmp.h +28 -11
@@ -62,7 +62,7 @@unsigned long IpFragFails;unsigned long IpFragCreates;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct ipv6_mib {
@@ -89,7 +89,7 @@unsigned long Ip6InMcastPkts;unsigned long Ip6OutMcastPkts;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct icmp_mib {
@@ -121,7 +121,7 @@unsigned long IcmpOutAddrMaskReps;unsigned long dummy;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct icmpv6_mib {
@@ -159,7 +159,7 @@unsigned long Icmp6OutGroupMembResponses;unsigned long Icmp6OutGroupMembReductions;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct tcp_mib {
@@ -178,7 +178,7 @@unsigned long TcpInErrs;unsigned long TcpOutRsts;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct udp_mib {
@@ -187,7 +187,7 @@unsigned long UdpInErrors;unsigned long UdpOutDatagrams;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};/* draft-ietf-sigtran-sctp-mib-07.txt */ struct sctp_mib
@@ -216,7 +216,7 @@unsigned long SctpValCookieLife;unsigned long SctpMaxInitRetr;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};struct linux_mib {
@@ -286,7 +286,7 @@unsigned long TCPAbortFailed;unsigned long TCPMemoryPressures;unsigned long __pad[0 ]; -}____cacheline_aligned ; +};/*
@@ -294,8 +294,25 @@* addl $1,memory is atomic against interrupts (but atomic_inc would be overkill because of the lock * cycles). Wants new nonlocked_atomic_inc() primitives -AK */ -#define SNMP_INC_STATS (mib, field) ((mib)[2*smp_processor_id()+!in_softirq()].field++) -#define SNMP_INC_STATS_BH (mib, field) ((mib)[2*smp_processor_id()].field++) -#define SNMP_INC_STATS_USER (mib, field) ((mib)[2*smp_processor_id()+1].field++) +#define DEFINE_SNMP_STAT (type, name) \ + __typeof__(type) *name[2] +#define DECLARE_SNMP_STAT (type, name) \ + extern __typeof__(type) *name[2] + +#define SNMP_STAT_USRPTR (name) (name[0]) +#define SNMP_STAT_BHPTR (name) (name[1]) + +#define SNMP_INC_STATS_BH (mib, field) \ + (per_cpu_ptr(mib[0], smp_processor_id())->field++) +#define SNMP_INC_STATS_USER (mib, field) \ + (per_cpu_ptr(mib[1], smp_processor_id())->field++) +#define SNMP_INC_STATS (mib, field) \ + (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field++) +#define SNMP_DEC_STATS (mib, field) \ + (per_cpu_ptr(mib[!in_softirq()], smp_processor_id())->field--) +#define SNMP_ADD_STATS_BH (mib, field, addend) \ + (per_cpu_ptr(mib[0], smp_processor_id())->field += addend) +#define SNMP_ADD_STATS_USER (mib, field, addend) \ + (per_cpu_ptr(mib[1], smp_processor_id())->field += addend)#endif
include/net/tcp.h +4 -2
@@ -28,6 +28,7 @@#include <linux/tcp.h> #include <linux/slab.h> #include <linux/cache.h> +#include <linux/percpu.h> #include <net/checksum.h> #include <net/sock.h> #if defined(CONFIG_IPV6 ) || defined (CONFIG_IPV6_MODULE )
@@ -630,10 +631,11 @@extern struct proto tcp_prot; -extern struct tcp_mib tcp_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct tcp_mib, tcp_statistics);#define TCP_INC_STATS (field) SNMP_INC_STATS(tcp_statistics, field)#define TCP_INC_STATS_BH (field) SNMP_INC_STATS_BH(tcp_statistics, field)#define TCP_INC_STATS_USER (field) SNMP_INC_STATS_USER(tcp_statistics, field) +#define TCP_DEC_STATS (field) SNMP_DEC_STATS(tcp_statistics, field)extern void tcp_put_port (struct sock *sk);extern void __tcp_put_port (struct sock *sk);
@@ -1399,7 +1401,7 @@/* fall through */ default :if (oldstate==TCP_ESTABLISHED ) - tcp_statistics[smp_processor_id ()*2 +!in_softirq ()].TcpCurrEstab--; +TCP_DEC_STATS (TcpCurrEstab); }/* Change state AFTER socket is unhashed to avoid closed
include/net/udp.h +1 -1
@@ -71,7 +71,7 @@extern int udp_ioctl (struct sock *sk,int cmd,unsigned long arg);extern int udp_disconnect (struct sock *sk,int flags); -extern struct udp_mib udp_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);#define UDP_INC_STATS (field) SNMP_INC_STATS(udp_statistics, field)#define UDP_INC_STATS_BH (field) SNMP_INC_STATS_BH(udp_statistics, field)#define UDP_INC_STATS_USER (field) SNMP_INC_STATS_USER(udp_statistics, field)
net/ipv4/af_inet.c +60 -1
80 lines not on this page · raw message
net/ipv4/icmp.c +45 -51
205 lines not on this page · raw message
net/ipv4/ip_input.c +1 -1
@@ -149,7 +149,7 @@* SNMP management statistics */ -struct ip_mib ip_statistics[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct ip_mib, ip_statistics);/* * Process Router Attention IP option
net/ipv4/proc.c +19 -18
@@ -86,16 +86,21 @@ .release = single_release, }; -static unsigned long fold_field (unsigned long *begin,int sz,int nr) +static unsigned long +fold_field (void *mib[],int nr) {unsigned long res =0 ;int i; - sz /=sizeof (unsigned long ); -for (i =0 ; i <NR_CPUS ; i++) { - res += begin[2 * i * sz + nr]; - res += begin[(2 * i +1 ) * sz + nr]; +if (!cpu_possible (i)) +continue ; + res += + *((unsigned long *) (((void *)per_cpu_ptr (mib[0 ], i)) + +sizeof (unsigned long ) * nr)); + res += + *((unsigned long *) (((void *)per_cpu_ptr (mib[0 ], i)) + +sizeof (unsigned long ) * nr)); }return res; }
@@ -118,8 +123,7 @@for (i =0 ; i < offsetof(struct ip_mib , __pad) /sizeof (unsigned long ); i++)seq_printf (seq," %lu" , -fold_field ((unsigned long *)ip_statistics, -sizeof (struct ip_mib ), i)); +fold_field ((void **) ip_statistics, i));seq_printf (seq,"\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds " "InParmProbs InSrcQuenchs InRedirects InEchos "
@@ -132,8 +136,7 @@for (i =0 ; i < offsetof(struct icmp_mib , dummy) /sizeof (unsigned long ); i++)seq_printf (seq," %lu" , -fold_field ((unsigned long *)icmp_statistics, -sizeof (struct icmp_mib ), i)); +fold_field ((void **) icmp_statistics, i));seq_printf (seq,"\nTcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens " "PassiveOpens AttemptFails EstabResets CurrEstab "
@@ -142,17 +145,15 @@for (i =0 ; i < offsetof(struct tcp_mib , __pad) /sizeof (unsigned long ); i++)seq_printf (seq," %lu" , -fold_field ((unsigned long *)tcp_statistics, -sizeof (struct tcp_mib ), i)); +fold_field ((void **) tcp_statistics, i));seq_printf (seq,"\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n" "Udp:" );for (i =0 ; i < offsetof(struct udp_mib , __pad) /sizeof (unsigned long ); i++) -seq_printf (seq," %lu" , -fold_field ((unsigned long *)udp_statistics, -sizeof (struct udp_mib ), i)); +seq_printf (seq," %lu" , +fold_field ((void **) udp_statistics, i));seq_putc (seq,'\n' );return 0 ;
@@ -206,10 +207,10 @@" TCPAbortFailed TCPMemoryPressures\n" "TcpExt:");for (i =0 ; - i < offsetof(struct linux_mib , __pad) /sizeof (unsigned long ); i++) -seq_printf (seq," %lu" , -fold_field ((unsigned long *)net_statistics, -sizeof (struct linux_mib ), i)); + i < offsetof(struct linux_mib , __pad) /sizeof (unsigned long ); + i++) +seq_printf (seq," %lu" , +fold_field ((void **) net_statistics, i));seq_putc (seq,'\n' );return 0 ; }
net/ipv4/tcp.c +7 -6
@@ -258,13 +258,15 @@#include <net/icmp.h> #include <net/tcp.h> #include <net/xfrm.h> +#include <net/ip.h> +#include <asm/uaccess.h> #include <asm/ioctls.h> int sysctl_tcp_fin_timeout =TCP_FIN_TIMEOUT ; -struct tcp_mib tcp_statistics[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);kmem_cache_t *tcp_openreq_cachep;kmem_cache_t *tcp_bucket_cachep;
@@ -1395,8 +1397,7 @@struct sk_buff *skb;struct tcp_opt *tp =tcp_sk (sk); - net_statistics[smp_processor_id () *2 +1 ].TCPPrequeued += -skb_queue_len (&tp->ucopy.prequeue); +NET_ADD_STATS_USER (TCPPrequeued,skb_queue_len (&tp->ucopy.prequeue));/* RX process wants to run with disabled BHs, though it is not * necessary */
@@ -1676,7 +1677,7 @@/* __ Restore normal policy in scheduler __ */ if ((chunk = len - tp->ucopy.len) !=0 ) { - net_statistics[smp_processor_id () *2 +1 ].TCPDirectCopyFromBacklog += chunk; +NET_ADD_STATS_USER (TCPDirectCopyFromBacklog, chunk); len -= chunk; copied += chunk; }
@@ -1687,7 +1688,7 @@tcp_prequeue_process (sk);if ((chunk = len - tp->ucopy.len) !=0 ) { - net_statistics[smp_processor_id () *2 +1 ].TCPDirectCopyFromPrequeue += chunk; +NET_ADD_STATS_USER (TCPDirectCopyFromPrequeue, chunk); len -= chunk; copied += chunk; }
@@ -1770,7 +1771,7 @@tcp_prequeue_process (sk);if (copied >0 && (chunk = len - tp->ucopy.len) !=0 ) { - net_statistics[smp_processor_id () *2 +1 ].TCPDirectCopyFromPrequeue += chunk; +NET_ADD_STATS_USER (TCPDirectCopyFromPrequeue, chunk); len -= chunk; copied += chunk; }
net/ipv4/tcp_input.c +2 -2
@@ -3043,8 +3043,8 @@/* First, purge the out_of_order queue. */ if (skb_queue_len (&tp->out_of_order_queue)) { - net_statistics[smp_processor_id () *2 ].OfoPruned += -skb_queue_len (&tp->out_of_order_queue); +NET_ADD_STATS_BH (OfoPruned, +skb_queue_len (&tp->out_of_order_queue));__skb_queue_purge (&tp->out_of_order_queue);/* Reset SACK state. A conforming SACK implementation will
net/ipv4/tcp_minisocks.c +2 -2
@@ -464,7 +464,7 @@if ((tcp_tw_count -= killed) !=0 )mod_timer (&tcp_tw_timer, jiffies+TCP_TWKILL_PERIOD ); - net_statistics[smp_processor_id ()*2 ].TimeWaited += killed; +NET_ADD_STATS_BH (TimeWaited, killed); out:spin_unlock (&tw_death_lock); }
@@ -628,7 +628,7 @@ out:if ((tcp_tw_count -= killed) ==0 )del_timer (&tcp_tw_timer); - net_statistics[smp_processor_id ()*2 ].TimeWaitKilled += killed; +NET_ADD_STATS_BH (TimeWaitKilled, killed);spin_unlock (&tw_death_lock); }
net/ipv4/tcp_timer.c +2 -1
@@ -237,7 +237,8 @@if (skb_queue_len (&tp->ucopy.prequeue)) {struct sk_buff *skb; - net_statistics[smp_processor_id ()*2 ].TCPSchedulerFailed +=skb_queue_len (&tp->ucopy.prequeue); +NET_ADD_STATS_BH (TCPSchedulerFailed, +skb_queue_len (&tp->ucopy.prequeue));while ((skb =__skb_dequeue (&tp->ucopy.prequeue)) !=NULL ) sk->backlog_rcv (sk, skb);
net/ipv4/udp.c +1 -1
@@ -110,7 +110,7 @@* Snmp MIB for the UDP layer */ -struct udp_mib udp_statistics[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct udp_mib, udp_statistics);struct sock *udp_hash[UDP_HTABLE_SIZE ];rwlock_t udp_hash_lock =RW_LOCK_UNLOCKED ;
Re: [patch] Change Networking mibs to use kmalloc_percpu -- 2/3
This patch is 2 of 3
D: Name: ipv6mibs-2.5.50-1.patch
D: Author: Ravikiran Thirumalai
D: Description: Changes ipv6 stats to use kmalloc_percpu from the traditional
D: padded NR_CPUS arrays
include/net/ipv6.h | 11 ++++-- net/ipv6/af_inet6.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/icmp.c | 8 ++-- net/ipv6/ipv6_sockglue.c | 2 - net/ipv6/proc.c | 38 ++++++++++++--------- net/ipv6/udp.c | 2 - 6 files changed, 119 insertions(+), 25 deletions(-)
include/net/ipv6.h +8 -3
@@ -19,6 +19,7 @@#include <asm/hardirq.h> #include <net/ndisc.h> #include <net/flow.h> +#include <net/snmp.h> #define SIN6_LEN_RFC2133 24
@@ -105,15 +106,19 @@/* sysctls */ extern int sysctl_ipv6_bindv6only; -extern struct ipv6_mib ipv6_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct ipv6_mib, ipv6_statistics);#define IP6_INC_STATS (field) SNMP_INC_STATS(ipv6_statistics, field)#define IP6_INC_STATS_BH (field) SNMP_INC_STATS_BH(ipv6_statistics, field)#define IP6_INC_STATS_USER (field) SNMP_INC_STATS_USER(ipv6_statistics, field) -extern struct icmpv6_mib icmpv6_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);#define ICMP6_INC_STATS (field) SNMP_INC_STATS(icmpv6_statistics, field)#define ICMP6_INC_STATS_BH (field) SNMP_INC_STATS_BH(icmpv6_statistics, field)#define ICMP6_INC_STATS_USER (field) SNMP_INC_STATS_USER(icmpv6_statistics, field) -extern struct udp_mib udp_stats_in6[NR_CPUS *2 ]; +#define ICMP6_STATS_PTR_BH (field) \ + (& \ + ((per_cpu_ptr(icmpv6_statistics[0], smp_processor_id()))-> \ + field)) +DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);#define UDP6_INC_STATS (field) SNMP_INC_STATS(udp_stats_in6, field)#define UDP6_INC_STATS_BH (field) SNMP_INC_STATS_BH(udp_stats_in6, field)#define UDP6_INC_STATS_USER (field) SNMP_INC_STATS_USER(udp_stats_in6, field)
net/ipv6/af_inet6.c +83 -0
107 lines not on this page · raw message
net/ipv6/icmp.c +4 -4
@@ -65,7 +65,7 @@#include <asm/uaccess.h> #include <asm/system.h> -struct icmpv6_mib icmpv6_statistics[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);/* * ICMP socket for flow control.
@@ -377,7 +377,7 @@ip6_build_xmit (sk, icmpv6_getfrag, &msg, &fl, len,NULL ,-1 ,MSG_DONTWAIT );if (type >=ICMPV6_DEST_UNREACH && type <=ICMPV6_PARAMPROB ) - (&(icmpv6_statistics[smp_processor_id ()*2 ].Icmp6OutDestUnreachs))[type-1 ]++; +ICMP6_STATS_PTR_BH (Icmp6OutDestUnreachs) [type-1 ]++;ICMP6_INC_STATS_BH (Icmp6OutMsgs); out:icmpv6_xmit_unlock ();
@@ -539,9 +539,9 @@ type = hdr->icmp6_type;if (type >=ICMPV6_DEST_UNREACH && type <=ICMPV6_PARAMPROB ) - (&icmpv6_statistics[smp_processor_id ()*2 ].Icmp6InDestUnreachs)[type-ICMPV6_DEST_UNREACH ]++; +ICMP6_STATS_PTR_BH (Icmp6InDestUnreachs)[type-ICMPV6_DEST_UNREACH ]++;else if (type >=ICMPV6_ECHO_REQUEST && type <=NDISC_REDIRECT ) - (&icmpv6_statistics[smp_processor_id ()*2 ].Icmp6InEchos)[type-ICMPV6_ECHO_REQUEST ]++; +ICMP6_STATS_PTR_BH (Icmp6InEchos)[type-ICMPV6_ECHO_REQUEST ]++;switch (type) {case ICMPV6_ECHO_REQUEST :
net/ipv6/ipv6_sockglue.c +1 -1
@@ -51,7 +51,7 @@#include <asm/uaccess.h> -struct ipv6_mib ipv6_statistics[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct ipv6_mib, ipv6_statistics);static struct packet_type ipv6_packet_type = {
net/ipv6/proc.c +22 -16
@@ -59,11 +59,11 @@static struct snmp6_item {char *name; -unsigned long *ptr; -int mibsize; +void **mib; +int offset; } snmp6_list[] = {/* ipv6 mib according to draft-ietf-ipngwg-ipv6-mib-04 */ -#define SNMP6_GEN(x) { #x , &ipv6_statistics[0].x, sizeof(struct ipv6_mib)/sizeof(unsigned long) } +#define SNMP6_GEN(x) { #x , (void **)ipv6_statistics, offsetof(struct ipv6_mib, x) }SNMP6_GEN (Ip6InReceives),SNMP6_GEN (Ip6InHdrErrors), SNMP6_GEN(Ip6InTooBigErrors),
@@ -97,7 +97,7 @@OutRouterAdvertisements too. OutGroupMembQueries too. */ -#define SNMP6_GEN (x) { #x , &icmpv6_statistics[0].x, sizeof(struct icmpv6_mib)/sizeof(unsigned long) } +#define SNMP6_GEN (x) { #x , (void **)icmpv6_statistics, offsetof(struct icmpv6_mib, x) }SNMP6_GEN (Icmp6InMsgs),SNMP6_GEN (Icmp6InErrors), SNMP6_GEN(Icmp6InDestUnreachs),
@@ -127,7 +127,7 @@ SNMP6_GEN(Icmp6OutGroupMembResponses), SNMP6_GEN(Icmp6OutGroupMembReductions),#undef SNMP6_GEN -#define SNMP6_GEN (x) { "Udp6" #x , &udp_stats_in6[0].Udp##x, sizeof(struct udp_mib)/sizeof(unsigned long) } +#define SNMP6_GEN (x) { "Udp6" #x , (void **)udp_stats_in6, offsetof(struct udp_mib, Udp##x) }SNMP6_GEN (InDatagrams),SNMP6_GEN (NoPorts), SNMP6_GEN(InErrors),
@@ -135,17 +135,23 @@#undef SNMP6_GEN }; -static unsigned long fold_field (unsigned long *ptr,int size) +static unsigned long +fold_field (void *mib[],int offt) { -unsigned long res =0 ; -int i; - -for (i=0 ; i<NR_CPUS ; i++) { - res += ptr[2 *i*size]; - res += ptr[(2 *i+1 )*size]; - } - -return res; +unsigned long res =0 ; +int i; + +for (i =0 ; i <NR_CPUS ; i++) { +if (!cpu_possible (i)) +continue ; + res += + *((unsigned long *) (((void *)per_cpu_ptr (mib[0 ], i)) + + offt)); + res += + *((unsigned long *) (((void *)per_cpu_ptr (mib[1 ], i)) + + offt)); + } +return res; }int afinet6_get_snmp (char *buffer,char **start,off_t offset,int length)
@@ -155,7 +161,7 @@for (i=0 ; i<sizeof (snmp6_list)/sizeof (snmp6_list[0 ]); i++) len +=sprintf (buffer+len,"%-32s\t%ld\n" , snmp6_list[i].name, -fold_field (snmp6_list[i].ptr, snmp6_list[i].mibsize)); +fold_field (snmp6_list[i].mib, snmp6_list[i].offset)); len -= offset;
net/ipv6/udp.c +1 -1
@@ -51,7 +51,7 @@#include <net/checksum.h> -struct udp_mib udp_stats_in6[NR_CPUS *2 ]; +DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);/* XXX This is identical to tcp_ipv6.c:ipv6_rcv_saddr_equal, put * XXX it somewhere common. -DaveM
Re: [patch] Change Networking mibs to use kmalloc_percpu -- 3/3
In reply to Ravikiran G ThirumalaiThis patch is 3 of 3
D: Name: sctpmibs-2.5.50-1.patch
D: Author: Ravikiran Thirumalai
D: Description: Changes sctp stats to use kmalloc_percpu from the traditional
D: padded NR_CPUS arrays
include/net/sctp/sctp.h | 2 +- net/sctp/protocol.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-)
include/net/sctp/sctp.h +1 -1
@@ -203,7 +203,7 @@#define SCTP_SOCK_SLEEP_POST (sk) SOCK_SLEEP_POST(sk)/* SCTP SNMP MIB stats handlers */ -extern struct sctp_mib sctp_statistics[NR_CPUS *2 ]; +DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics);#define SCTP_INC_STATS (field) SNMP_INC_STATS(sctp_statistics, field)#define SCTP_INC_STATS_BH (field) SNMP_INC_STATS_BH(sctp_statistics, field)#define SCTP_INC_STATS_USER (field) SNMP_INC_STATS_USER(sctp_statistics, field)
net/sctp/protocol.c +43 -1
74 lines not on this page · raw message
From: Ravikiran G Thirumalai <[email protected]>
Date: Wed, 4 Dec 2002 18:05:10 +0530
Here's a patchset to enable networking mibs to use kmalloc_percpu instead of the traditional padded NR_CPUS arrays.
Advantages:
1. Removes NR_CPUS bloat due to static definition
2. Can support node local allocation
3. Will work with modules
I totally support this work. Once the kmalloc percpu bits hit Linus's tree, just retransmit these diffs to me privately and I'll put them into my net-2.5 tree.
Thanks.
Em Wed, Dec 04, 2002 at 09:01:52AM -0800, David S. Miller escreveu:
Quoted 6 lines
From: Ravikiran G Thirumalai <[email protected]>
Date: Wed, 4 Dec 2002 18:05:10 +0530Here's a patchset to enable networking mibs to use
kmalloc_percpuinstead of the traditional paddedNR_CPUSarrays.
Quoted 8 lines
Advantages:
1. RemovesNR_CPUSbloat due to static definition
2. Can support node local allocation
3. Will work with modulesI totally support this work. Once the kmalloc percpu bits hit Linus's tree, just retransmit these diffs to me privately and I'll put them into my net-2.5 tree.
Cool stuff! I was planning to macroise this so that things like this would be possible without source impact but now its just there, keep it up :-)
- Arnaldo