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]
Date:	Thu, 8 Nov 2007 12:37:52 +0100
From:	Jarek Poplawski <jarkao2@...pl>
To:	Radu Rendec <radu.rendec@...s.ro>
Cc:	netdev@...r.kernel.org, hadi@...erus.ca, davem@...emloft.net
Subject: Re: [PATCH] [PKT_SCHED] CLS_U32: Use ffs() instead of C code on hash mask to get first set bit.

On Thu, Nov 08, 2007 at 01:07:47PM +0200, Radu Rendec wrote:
> Computing the rank of the first set bit in the hash mask (for using later
> in u32_hash_fold()) was done with plain C code. Using ffs() instead makes
> the code more readable and improves performance (since ffs() is better
> optimized in assembler).
> 
> Using the conditional operator on hash mask before applying ntohl() also
> saves one ntohl() call if mask is 0.
> 
> Signed-off-by: Radu Rendec <radu.rendec@...s.ro>

Signed-off-by: Jarek Poplawski <jarkao2@...pl>

> ---
>  net/sched/cls_u32.c |   12 +-----------
>  1 files changed, 1 insertions(+), 11 deletions(-)
> 
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 5317102..c390082 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
> @@ -613,17 +613,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
>  	memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
>  	n->ht_up = ht;
>  	n->handle = handle;
> -{
> -	u8 i = 0;
> -	u32 mask = ntohl(s->hmask);
> -	if (mask) {
> -		while (!(mask & 1)) {
> -			i++;
> -			mask>>=1;
> -		}
> -	}
> -	n->fshift = i;
> -}
> +	n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
>  
>  #ifdef CONFIG_CLS_U32_MARK
>  	if (tb[TCA_U32_MARK-1]) {
> -- 
> 1.5.3.2
> 
-
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