linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	Thomas Graf <tgraf@suug.ch>
Subject: Re: [RFC] mac80211: use rhashtable for station table
Date: Mon, 23 Feb 2015 22:52:40 +0100	[thread overview]
Message-ID: <1424728360.1899.3.camel@sipsolutions.net> (raw)
In-Reply-To: <CAHNKnsR0j1u6Eu2e19pzcu2Rw7nZ6D6BKV-cRg9KTwoKO74fdQ@mail.gmail.com> (sfid-20150223_222714_678902_C1EA88E2)

On Tue, 2015-02-24 at 00:26 +0300, Sergey Ryazanov wrote:

> > 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.

Ah.

> 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);
> }

This would work, but without the LA bit obviously.

> 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);
> }

This won't exactly work as there's no known padding there so that k[1]
accesses invalid data, but I get the point. It should then be 

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

I don't think it would save bytes? The jhash function is common after
all. Ah, but it's an inline, so it would be generated here.

We also can't rely on 4-byte alignment though, so perhaps we should do
something like

u32 sta_info_hash(void *addr, u32 len, u32 seed)
{
	u16 *a = addr;

	return jhash_3words(a[0], a[1], a[2], seed);
}

instead? Not sure what effect that has on jhash though if we don't have
anything in the high 16 bits.

johannes


  reply	other threads:[~2015-02-23 21:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 21:47 [RFC] mac80211: use rhashtable for station table Johannes Berg
2015-02-13 22:13 ` Ben Greear
2015-02-23 16:32   ` Johannes Berg
2015-02-14  2:14 ` Sergey Ryazanov
2015-02-23 16:33   ` Johannes Berg
2015-02-23 21:26     ` Sergey Ryazanov
2015-02-23 21:52       ` Johannes Berg [this message]
2015-02-23 22:01         ` Johannes Berg
2015-02-23 22:07           ` Johannes Berg
2015-02-23 22:15             ` Sergey Ryazanov

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=1424728360.1899.3.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=ryazanov.s.a@gmail.com \
    --cc=tgraf@suug.ch \
    /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).