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] [day] [month] [year] [list]
Message-Id: <200702071127.42298.ak@suse.de>
Date:	Wed, 7 Feb 2007 11:27:42 +0100
From:	Andi Kleen <ak@...e.de>
To:	Eric Dumazet <dada1@...mosbay.com>
Cc:	David Miller <davem@...emloft.net>, mchan@...adcom.com,
	netdev@...r.kernel.org
Subject: Re: [PATCH] tg3 : avoid an expensive divide


> Well, this could explain but unfortunatly I dont have this option set :
> 
> # grep OPTIMIZE .config
> # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
> 
> # gcc -v
> Using built-in specs.
> Target: x86_64-unknown-linux-gnu
> Configured with: ../gcc-4.1.1/configure --enable-languages=c,c++

Ah. Looking more closely the problem is different (sorry for the wrong
explanation earlier, it fit too well and it really happened elsewhere)

The code is 

#define TG3_RX_RCB_RING_SIZE(tp)        \
        ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ?  512 : 1024)

...
sw_idx %= TG3_RX_RCB_RING_SIZE(tp);


The problem is that gcc doesn't rewrite the x % (cond ? const1 : const2) expression
to the more optimizable cond ? (x % const1 : x % const2). For the first it sees
a full variable division, for which div* is the best code to generate.

Your patch is probably correct or alternatively rewrite the expression 
to the optimizable form by hand.

Arguably gcc should do this by itself. Perhaps file a gcc bug about this missing optimization. 

-Andi

-
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