From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756918AbbCCSZK (ORCPT ); Tue, 3 Mar 2015 13:25:10 -0500 Received: from smtprelay0097.hostedemail.com ([216.40.44.97]:35735 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754046AbbCCSZI (ORCPT ); Tue, 3 Mar 2015 13:25:08 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3872:4321:5007:6117:6119:6261:7903:10004:10400:10471:10481:10848:11026:11232:11473:11658:11914:12043:12114:12438:12517:12519:12555:12663:12740:13069:13255:13311:13357:19900: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: fall99_f713d43f3d5a X-Filterd-Recvd-Size: 2545 Message-ID: <1425407104.17273.27.camel@perches.com> Subject: Re: [PATCH net-next 01/14] etherdevice: Add eth__addr CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS code From: Joe Perches To: Eric Dumazet Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 03 Mar 2015 10:25:04 -0800 In-Reply-To: <1425388752.5130.164.camel@edumazet-glaptop2.roam.corp.google.com> References: <1425388752.5130.164.camel@edumazet-glaptop2.roam.corp.google.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 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 On Tue, 2015-03-03 at 05:19 -0800, Eric Dumazet wrote: > On Mon, 2015-03-02 at 19:54 -0800, Joe Perches wrote: > > Make the memset possibly more efficient with the appropriate > > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS #ifdef [] > > diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h [] > > @@ -192,7 +192,12 @@ static inline void eth_random_addr(u8 *addr) > > */ > > static inline void eth_broadcast_addr(u8 *addr) > > { > > +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) > > + *(u32 *)addr = 0xffffffff; > > + *(u16 *)(addr + 4) = 0xffff; > > +#else > > memset(addr, 0xff, ETH_ALEN); > > +#endif > > } > > > > I am pretty sure compiler already does an inline, and might chose to > emit equivalent instructions for : > *(u16 *) addr = 0xffff; > *(u32 *)(addr + 2) = 0xffffffff; > > if (addr % 4) is known to be 2 (cross-compiled on x86) At least for arm gcc 4.6.3, it emits different code for net/l2tp/l2tp_eth.o old: - 1cc0: e3a010ff mov r1, #255 ; 0xff - 1cc4: e3a02006 mov r2, #6 - 1cc8: e3c33001 bic r3, r3, #1 - 1ccc: e3833002 orr r3, r3, #2 - 1cd0: e5c53000 strb r3, [r5] - 1cd4: ebfffffe bl 0 - 1cc8: e3c33001 bic r3, r3, #1 new: + 1cc0: e3a02f8a mov r2, #552 ; 0x228 + 1cc4: e3c33001 bic r3, r3, #1 + 1cc8: e3833002 orr r3, r3, #2 + 1ccc: e5c53000 strb r3, [r5] + 1cd0: e3e03000 mvn r3, #0 + 1cd4: e5843224 str r3, [r4, #548] ; 0x224 + 1cd8: e18430b2 strh r3, [r4, r2]