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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cbbdf9e2cf6a64e749ec889cc946e2a10c793ba2.camel@linux.intel.com>
Date:   Mon, 01 Apr 2019 11:20:26 -0700
From:   Alexander Duyck <alexander.h.duyck@...ux.intel.com>
To:     Dmitry Safonov <dima@...sta.com>, linux-kernel@...r.kernel.org
Cc:     Alexey Kuznetsov <kuznet@....inr.ac.ru>,
        David Ahern <dsahern@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        Ido Schimmel <idosch@...lanox.com>, netdev@...r.kernel.org
Subject: Re: [RFC 3/4] net/fib: Check budget before should_{inflate,halve}()

On Tue, 2019-03-26 at 15:30 +0000, Dmitry Safonov wrote:
> Those functions are compute-costly, if we're out of budget - better
> omit additional computations.
> 
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
>  net/ipv4/fib_trie.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index d90cf9dfd443..2ce2739e7693 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
> @@ -868,7 +868,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn,
>  	/* Double as long as the resulting node has a number of
>  	 * nonempty nodes that are above the threshold.
>  	 */
> -	while (should_inflate(tp, tn) && *budget) {
> +	while (*budget && should_inflate(tp, tn)) {
>  		tp = inflate(t, tn, budget);
>  		if (!tp) {
>  #ifdef CONFIG_IP_FIB_TRIE_STATS
> @@ -894,7 +894,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn,
>  	/* Halve as long as the number of empty children in this
>  	 * node is above threshold.
>  	 */
> -	while (should_halve(tp, tn) && *budget) {
> +	while (*budget && should_halve(tp, tn)) {
>  		tp = halve(t, tn, budget);
>  		if (!tp) {
>  #ifdef CONFIG_IP_FIB_TRIE_STATS

Based on my comments in the other patches I would say this is a bad
idea.

Really the budget should allow at least 1 pass through the trie to
attempt to either inflate or deflate the node and all children. This
logic is optimizing for the case where *budget is 0 and that should not
occur that often.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ