Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752696AbbH1TVB (ORCPT ); Fri, 28 Aug 2015 15:21:01 -0400 Received: from smtprelay0065.hostedemail.com ([216.40.44.65]:49656 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752150AbbH1TVA (ORCPT ); Fri, 28 Aug 2015 15:21:00 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2692:2693:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6120:6261:6691:6742:7576:7901:7903:7904:9036:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12438:12517:12519:12555:12740:13019:13161:13229:13255:13618:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: rate54_5f6a0629bed16 X-Filterd-Recvd-Size: 3637 Message-ID: <1440789654.11525.137.camel@perches.com> Subject: Re: [PATCH RFC V2 2/2] net: Optimize snmp stat aggregation by walking all the percpu data at once From: Joe Perches To: David Miller Cc: raghavendra.kt@linux.vnet.ibm.com, edumazet@google.com, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net, jiri@resnulli.us, hannes@stressinduktion.org, tom@herbertland.com, azhou@nicira.com, ebiederm@xmission.com, ipm@chirality.org.uk, nicolas.dichtel@6wind.com, serge.hallyn@canonical.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, anton@au1.ibm.com, nacc@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com Date: Fri, 28 Aug 2015 12:20:54 -0700 In-Reply-To: <20150828.112413.424099339331017970.davem@davemloft.net> References: <1440610653-14210-3-git-send-email-raghavendra.kt@linux.vnet.ibm.com> <20150827.113823.214019265460582055.davem@davemloft.net> <55E00238.10909@linux.vnet.ibm.com> <20150828.112413.424099339331017970.davem@davemloft.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2383 Lines: 71 On Fri, 2015-08-28 at 11:24 -0700, David Miller wrote: > From: Raghavendra K T > Date: Fri, 28 Aug 2015 12:09:52 +0530 > > > On 08/28/2015 12:08 AM, David Miller wrote: > >> From: Raghavendra K T > >> Date: Wed, 26 Aug 2015 23:07:33 +0530 > >> > >>> @@ -4641,10 +4647,12 @@ static inline void __snmp6_fill_stats64(u64 > >>> *stats, void __percpu *mib, > >>> static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int > >>> attrtype, > >>> int bytes) > >>> { > >>> + u64 buff[IPSTATS_MIB_MAX] = {0,}; > >>> + > ... > > hope you wanted to know the overhead than to change the current > > patch. please let me know.. > > I want you to change that variable initializer to an explicit memset(). > > The compiler is emitting a memset() or similar _anyways_. > > Not because it will have any impact at all upon performance, but because > of how it looks to people trying to read and understand the code. I don't read it as particularly different. There are > 100 uses of the not quite a memset initialization style using "= { <0,> }" in net/ $ git grep -E "=\s*\{\s*0?\s*,?\s*\}" net | wc -l 138 There is a difference though if a struct is copied to user-space as a {} initialization only guarantees that struct members are initialized to 0 where memset also zeros any alignment padding. Maybe a checkpatch rule like this? --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e14dcdb..f79e5c9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3237,6 +3237,13 @@ sub process { next; } +# check for non-global initializations that could be memset + if ($realfile =~ m@^(drivers/net/|net/)@ && + $sline =~ /^.\s+$Declare\s*$Ident\s*=\s*\{\s*0?\s*,?\s*\}/) { + CHK("BRACE_INITIALIZATION", + "Prefer an explicit memset to a declaration initialization\n" . $herecurr); + } + # check for initialisation to aggregates open brace on the next line if ($line =~ /^.\s*{/ && $prevline =~ /(?:^|[^=])=\s*$/) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/