Date: Tue, 9 Jul 2013 09:59:46 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253086 - in head/sys: netinet netinet6 Message-ID: <201307090959.r699xkYb041017@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Tue Jul 9 09:59:46 2013 New Revision: 253086 URL: http://svnweb.freebsd.org/changeset/base/253086 Log: Migrate structs in6_ifstat and icmp6_ifstat to PCPU counters. Modified: head/sys/netinet/icmp6.h head/sys/netinet6/in6.c head/sys/netinet6/in6_var.h Modified: head/sys/netinet/icmp6.h ============================================================================== --- head/sys/netinet/icmp6.h Tue Jul 9 09:54:54 2013 (r253085) +++ head/sys/netinet/icmp6.h Tue Jul 9 09:59:46 2013 (r253086) @@ -692,7 +692,9 @@ void icmp6_mtudisc_update(struct ip6ctlp #define icmp6_ifstat_inc(ifp, tag) \ do { \ if (ifp) \ - ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \ + counter_u64_add(((struct in6_ifextra *) \ + ((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat[\ + offsetof(struct icmp6_ifstat, tag) / sizeof(uint64_t)], 1);\ } while (/*CONSTCOND*/ 0) #define icmp6_ifoutstat_inc(ifp, type, code) \ Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Tue Jul 9 09:54:54 2013 (r253085) +++ head/sys/netinet6/in6.c Tue Jul 9 09:59:46 2013 (r253086) @@ -570,10 +570,10 @@ in6_control(struct socket *so, u_long cm error = EINVAL; goto out; } - bzero(&ifr->ifr_ifru.ifru_stat, - sizeof(ifr->ifr_ifru.ifru_stat)); - ifr->ifr_ifru.ifru_stat = - *((struct in6_ifextra *)ifp->if_afdata[AF_INET6])->in6_ifstat; + COUNTER_ARRAY_COPY(((struct in6_ifextra *) + ifp->if_afdata[AF_INET6])->in6_ifstat, + &ifr->ifr_ifru.ifru_stat, + sizeof(struct in6_ifstat) / sizeof(uint64_t)); break; case SIOCGIFSTAT_ICMP6: @@ -581,10 +581,10 @@ in6_control(struct socket *so, u_long cm error = EINVAL; goto out; } - bzero(&ifr->ifr_ifru.ifru_icmp6stat, - sizeof(ifr->ifr_ifru.ifru_icmp6stat)); - ifr->ifr_ifru.ifru_icmp6stat = - *((struct in6_ifextra *)ifp->if_afdata[AF_INET6])->icmp6_ifstat; + COUNTER_ARRAY_COPY(((struct in6_ifextra *) + ifp->if_afdata[AF_INET6])->icmp6_ifstat, + &ifr->ifr_ifru.ifru_icmp6stat, + sizeof(struct icmp6_ifstat) / sizeof(uint64_t)); break; case SIOCGIFALIFETIME_IN6: @@ -2749,14 +2749,15 @@ in6_domifattach(struct ifnet *ifp) ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK); bzero(ext, sizeof(*ext)); - ext->in6_ifstat = (struct in6_ifstat *)malloc(sizeof(struct in6_ifstat), - M_IFADDR, M_WAITOK); - bzero(ext->in6_ifstat, sizeof(*ext->in6_ifstat)); - - ext->icmp6_ifstat = - (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat), - M_IFADDR, M_WAITOK); - bzero(ext->icmp6_ifstat, sizeof(*ext->icmp6_ifstat)); + ext->in6_ifstat = malloc(sizeof(struct in6_ifstat), M_IFADDR, + M_WAITOK); + COUNTER_ARRAY_ALLOC(ext->in6_ifstat, + sizeof(struct in6_ifstat) / sizeof(uint64_t), M_WAITOK); + + ext->icmp6_ifstat = malloc(sizeof(struct icmp6_ifstat), M_IFADDR, + M_WAITOK); + COUNTER_ARRAY_ALLOC(ext->icmp6_ifstat, + sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_WAITOK); ext->nd_ifinfo = nd6_ifattach(ifp); ext->scope6_id = scope6_ifattach(ifp); @@ -2781,7 +2782,11 @@ in6_domifdetach(struct ifnet *ifp, void scope6_ifdetach(ext->scope6_id); nd6_ifdetach(ext->nd_ifinfo); lltable_free(ext->lltable); + COUNTER_ARRAY_FREE(ext->in6_ifstat, + sizeof(struct in6_ifstat) / sizeof(uint64_t)); free(ext->in6_ifstat, M_IFADDR); + COUNTER_ARRAY_FREE(ext->icmp6_ifstat, + sizeof(struct icmp6_ifstat) / sizeof(uint64_t)); free(ext->icmp6_ifstat, M_IFADDR); free(ext, M_IFADDR); } Modified: head/sys/netinet6/in6_var.h ============================================================================== --- head/sys/netinet6/in6_var.h Tue Jul 9 09:54:54 2013 (r253085) +++ head/sys/netinet6/in6_var.h Tue Jul 9 09:59:46 2013 (r253086) @@ -98,14 +98,28 @@ struct scope6_id; struct lltable; struct mld_ifinfo; +#ifdef _KERNEL +#include <sys/counter.h> + +struct in6_ifextra { + counter_u64_t *in6_ifstat; + counter_u64_t *icmp6_ifstat; + struct nd_ifinfo *nd_ifinfo; + struct scope6_id *scope6_id; + struct lltable *lltable; + struct mld_ifinfo *mld_ifinfo; +}; +#else + struct in6_ifextra { - struct in6_ifstat *in6_ifstat; - struct icmp6_ifstat *icmp6_ifstat; + void *in6_ifstat; + void *icmp6_ifstat; struct nd_ifinfo *nd_ifinfo; struct scope6_id *scope6_id; struct lltable *lltable; struct mld_ifinfo *mld_ifinfo; }; +#endif /* !_KERNEL */ #define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable) @@ -537,7 +551,9 @@ extern struct rwlock in6_ifaddr_lock; #define in6_ifstat_inc(ifp, tag) \ do { \ if (ifp) \ - ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->in6_ifstat->tag++; \ + counter_u64_add(((struct in6_ifextra *) \ + ((ifp)->if_afdata[AF_INET6]))->in6_ifstat[ \ + offsetof(struct in6_ifstat, tag) / sizeof(uint64_t)], 1);\ } while (/*CONSTCOND*/ 0) extern u_char inet6ctlerrmap[];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307090959.r699xkYb041017>