netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: sakiwit@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH] ipv4: remove parentheses in return statement
Date: Fri, 03 Aug 2012 02:22:40 -0700 (PDT)	[thread overview]
Message-ID: <20120803.022240.1997423719431165575.davem@davemloft.net> (raw)
In-Reply-To: <1343985584.9299.873.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 03 Aug 2012 11:19:44 +0200

> On Fri, 2012-08-03 at 01:43 -0600, Jean Sacren wrote:
> 
>> @@ -106,8 +106,8 @@ static inline unsigned int inet_addr_hash(struct net *net, __be32 addr)
>>  {
>>  	u32 val = (__force u32) addr ^ hash_ptr(net, 8);
>>  
>> -	return ((val ^ (val >> 8) ^ (val >> 16) ^ (val >> 24)) &
>> -		(IN4_ADDR_HSIZE - 1));
>> +	return (val ^ (val >> 8) ^ (val >> 16) ^ (val >> 24)) &
>> +	       (IN4_ADDR_HSIZE - 1);
>>  }
> 
> BTW This should use a faster implementation, I'll send a patch when
> net-next is opened.

There seems to be a few spots where we want the pointer "as a 32-bit
integer" for hashing.  We were discussing arp_hashfn() and ndisc_hashfn()
the other day.

It should basically do something like:

	(u32) ((u64)ptr >> 32 | ((u32) ptr))

on 64-bit and simply (u32)(ptr) on 32-bit.

  reply	other threads:[~2012-08-03  9:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03  7:43 [PATCH] ipv4: remove parentheses in return statement Jean Sacren
2012-08-03  8:52 ` David Miller
2012-08-03 20:23   ` Jean Sacren
2012-08-03 21:31     ` David Miller
2012-08-03  9:19 ` Eric Dumazet
2012-08-03  9:22   ` David Miller [this message]
2012-08-03  9:53     ` Eric Dumazet
2012-08-03 23:53       ` David Miller

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=20120803.022240.1997423719431165575.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sakiwit@gmail.com \
    /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).