From owner-svn-src-head@FreeBSD.ORG Tue Jul 9 09:59:47 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 725A2BF6; Tue, 9 Jul 2013 09:59:47 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 552DF1675; Tue, 9 Jul 2013 09:59:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r699xlc1041020; Tue, 9 Jul 2013 09:59:47 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r699xkYb041017; Tue, 9 Jul 2013 09:59:46 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201307090959.r699xkYb041017@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 9 Jul 2013 09:59:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253086 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2013 09:59:47 -0000 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 + +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[];