Prev: mqueue: fix kernel BUG caused by double free() on mq_open()
Next: [PATCH resend] x86, amd: Check X86_FEATURE_OSVW bit before accessing OSVW MSRs
From: David Howells on 12 May 2010 07:50 Michel Lespinasse <walken(a)google.com> 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(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Michel Lespinasse on 12 May 2010 21:20
On Wed, May 12, 2010 at 4:45 AM, David Howells <dhowells(a)redhat.com> wrote: > 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--) { Sounds good. I'll have it in next version. (Arguably 'woken' might be confusing too given that we only wake the threads later on. But I don't care much either way). -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |