From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756332AbbCCNTQ (ORCPT ); Tue, 3 Mar 2015 08:19:16 -0500 Received: from mail-ie0-f174.google.com ([209.85.223.174]:34279 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbbCCNTP (ORCPT ); Tue, 3 Mar 2015 08:19:15 -0500 Message-ID: <1425388752.5130.164.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [PATCH net-next 01/14] etherdevice: Add eth__addr CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS code From: Eric Dumazet To: Joe Perches Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 03 Mar 2015 05:19:12 -0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 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 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 > > Signed-off-by: Joe Perches > --- > include/linux/etherdevice.h | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h > index 606563e..22ad94a 100644 > --- 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