lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHXqBFLk5ze9y7htyO+9z7=qcznNjXeuJK5Rs1t2ym=vLqDy5Q@mail.gmail.com>
Date:	Mon, 11 Jul 2011 13:58:41 +0200
From:	Michał Mirosław <mirqus@...il.com>
To:	David Miller <davem@...emloft.net>
Cc:	roland@...estorage.com, johnwheffner@...il.com, mj@....cz,
	netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] neigh: Store hash shift instead of mask.

2011/7/11 David Miller <davem@...emloft.net>:
> And mask the hash function result by simply shifting
> down the "->hash_shift" most significant bits.
>
> Currently which bits we use is arbitrary since jhash
> produces entropy evenly across the whole hash function
> result.
>
> But soon we'll be using universal hashing functions,
> and in those cases more entropy exists in the higher
> bits than the lower bits, because they use multiplies.

You could use some evil shift tricks to cut some instructions if you like. ;-)
Examples below.

[...]
> -       for (i = 0; i <= nht->hash_mask; i++) {
> +       for (i = 0; i < (1 << nht->hash_shift); i++) {

for (i = 0; !(i >> nth->hash_shift); i++)

[...]
> -       size_t size = entries * sizeof(struct neighbour *);
> +       size_t size = (1 << shift) * sizeof(struct neighbour *);

size_t size = sizeof(struct neighbour *) << shift;

Or, since later get_order(size) is used:

unsinged int size_shift = shift + order_base_2(sizeof(struct neighbour *));

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ