2015-02-23 19:33 GMT+03:00 Johannes Berg <[email protected]>:
> On Sat, 2015-02-14 at 05:14 +0300, Sergey Ryazanov wrote:
>
>> A nice change! Couple of years ago I did some tests with real sets of
>> MACs and jhash gives a better distribution than usage of a last octet.
>>
>> BTW, why do you use full address and generic jhash? Hashing of two
>> least significant words could be faster. Isn't it?
>
> Well - not sure what you're trying to say? First you're saying jhash()
> was clearly better and then you're saying I shouldn't use it? ;-)
>
In first case, I mean the jhash _algorithm_, which has a better
distribution, in second case I mean the _generic_ jhash() _function_
and express my doubts about its performance. See below.

> Anyway - just using the last two bytes (or even 16-bit words) won't
> cover the case where the locally administered bit is set in an otherwise
> unchanged address, which is getting more common for P2P.
>
> I also don't really see any major drawbacks to hashing it all?
>
I agree that hashing all octets is not a drawback. But the jhash()
function is tailored to the input data of variable length, while we
have a vector of fixed length and appropriate functions. Could we do
the hashing in following way:

u32 sta_info_hash(void *addr, u32 len, u32 seed)
{
  u32 *k = addr + 2;
  return jhash_1word(*k, seed);
}

structu rhashtable_pararms param = {
  ...
  .hashfn = sta_info_hash,
  ...
}

or even (to account LA bit):

u32 sta_info_hash(void *addr, u32 len, u32 seed)
{
  u32 *k = addr;
  return jhash_2words(k[0], k[1], seed);
}

structu rhashtable_pararms param = {
  ...
  .key_len = 8,
  .hashfn = sta_info_hash,
  ...
}

This could save a couple of CPU circles and a couple of bytes in the
output image :)

-- 
Sergey
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to