netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] etherdevice: Optimize compare_ether_addr/ether_addr_equal
Date: Sat, 31 Aug 2013 23:41:49 +0400	[thread overview]
Message-ID: <522246FD.3080403@cogentembedded.com> (raw)
In-Reply-To: <1377939256.2054.11.camel@joe-AO722>

Hello.

On 08/31/2013 12:54 PM, Joe Perches wrote:

> When CONFIG_HAS_EFFICIENT_UNALIGNED_ACCESS is set,
> optimize compare_ether_addr a little by removing an
> xor and or by using a u32 and u16 comparison
> instead of 3 separate u16 comparisons.

> Make the ether_addr_equal_64bits code a bit simpler
> by adding a test for CONFIG_64BIT and calling
> ether_addr_equal otherwise.

> This also slightly improves ether_addr_equal_64bits
> by removing the zap_last_2bytes shifts in the !64bit
> case.

> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>   include/linux/etherdevice.h | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)

> diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
> index c623861..2514d17 100644
> --- a/include/linux/etherdevice.h
> +++ b/include/linux/etherdevice.h
> @@ -208,11 +208,19 @@ static inline void eth_hw_addr_random(struct net_device *dev)
>    */
>   static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2)
>   {
> +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
> +	u32 fold = ((*(const u32 *)addr1) ^ (*(const u32 *)addr2));

    Could you keep the same style as before and insert empty line after 
declaration?

> +	fold |= ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4)));
> +
> +	BUILD_BUG_ON(ETH_ALEN != 6);
> +	return fold != 0;
> +#else
>   	const u16 *a = (const u16 *) addr1;
>   	const u16 *b = (const u16 *) addr2;
>
>   	BUILD_BUG_ON(ETH_ALEN != 6);
>   	return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
> +#endif
>   }
>
>   /**

WBR, Sergei

  parent reply	other threads:[~2013-08-31 19:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-31  8:54 [PATCH net-next] etherdevice: Optimize compare_ether_addr/ether_addr_equal Joe Perches
2013-08-31 16:43 ` Stephen Hemminger
2013-08-31 20:58   ` Joe Perches
2013-08-31 19:41 ` Sergei Shtylyov [this message]
2013-08-31 22:27 ` David Miller
2013-09-02 16:52   ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=522246FD.3080403@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=joe@perches.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).