Re: [PATCH 04/12] rwsem: consistently use adjustment variable

From: David Howells
Date: Wed May 12 2010 - 07:46:12 EST


Michel Lespinasse <walken@xxxxxxxxxx> wrote:

> Cleanup: previous change introduced an adjustment variable used in
> waking writers; the code to wake readers can be made nicer by making
> use of that same variable.
>
> Reducing variable count should hopefully help both humans and compilers
> looking at this function :)

Actually, no. The compiler doesn't care. With optimisation, the variable
'woken' would cease to exist after being copied to loop and added into
adjustment. What it would probably do is just relabel 'woken' internally as
'loop'.

>From a human point of view, I would say keep woken, but use it to initialise
adjustment:

adjustment = woken * RWSEM_ACTIVE_READ_BIAS;

and use it to initialise 'loop':

for (loop = woken; loop > 0; loop--) {

or just ditch 'loop' and use 'woken' directly, since the number of processes
to be woken goes down as the loop iterates.

Whatever, the compiler won't care, since loop and woken will just be names for
the same value.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/