RE: [PATCH v2 net] net: solve a NAPI race
From: David Laight <hidden>
Date: 2017-03-02 10:25:06
From: David Laight <hidden>
Date: 2017-03-02 10:25:06
From: Eric Dumazet
Sent: 01 March 2017 17:33 On Wed, 2017-03-01 at 08:14 -0800, Alexander Duyck wrote:quoted
What build flags are you using? With -Os or -O2 I have seen it convert the /b * c into a single shift.Because b & c are unsigned in our case. I presume David tried signed integers, this is why gcc does that.
I was using integer constants but an unsigned variable. Changing the constants to unsigned makes no difference (they would get promoted anyway). After some experiments I can get gcc to generate a single shift if the variable being tested is 32bits, the constants are 64bits and a 64bit result is required. In every other case it does either and-shr-shl or shr-and-shl (all the shr are logical). David