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
| ||
|
Date: Sun, 27 Oct 2013 12:35:21 -0700 From: Linus Torvalds <torvalds@...ux-foundation.org> To: Maarten Lankhorst <maarten.lankhorst@...onical.com> Cc: Ingo Molnar <mingo@...nel.org>, Linux Kernel Mailing List <linux-kernel@...r.kernel.org>, Peter Zijlstra <a.p.zijlstra@...llo.nl>, Thomas Gleixner <tglx@...utronix.de>, Andrew Morton <akpm@...ux-foundation.org> Subject: Re: [GIT PULL] locking fix On Sun, Oct 27, 2013 at 12:23 PM, Linus Torvalds <torvalds@...ux-foundation.org> wrote: > > The *ONLY* thing it is testing for is "how much can the compiler > optimize this", and as such the *ONLY* thing it tests for is compiler > differences. Side note: testing "can the compiler optimize this expression at compile time" is actually sometimes an interesting question, so it can be a valid thing to test. But people should understand that the question is literally about THAT (ie visibility into compiler optimization) rather than about the value itself. So generally, the only thing that a __builtin_constant_p() test can be used for is in *conjunction* with having an actual test for an actual value, and then having special-case logic that pertains to that value. So for example, *this* is a valid test: if (__builtin_constant_p(ww_ctx) && ww_ctx == NULL) { ... special compile-time shortcut for the NULL value .. } else { ... generic code that *also* handles the NULL value .. } and it's useful for triggering a compile-time optimized code-sequence that is only true for NULL. But because __builtin_constant_p() is about "how well can the compiler optimize this", that "else" statement had better be able to handle the generic case too. And yes, there are a few places where we do expect a certain minimal set of optimizations. So in some cases we *might* have the rule that the only valid use of NULL in a case like the above is when the pointer passed in is passed in as a constant. And then we might say "we rely on the compiler always returning true for __builtin_constant_p(NULL)", and then we might say "so the "generic" version of the code is guaranteed to never see NULL". But notice how *different* that __builtin_constant_p(ww_ctx) && ww_ctx == NULL test is from __builtin_constant_p(ww_ctx == NULL) and really, the two tests are *fundamentally* really really different. The first one can make sense. While the second one is pure and utter garbage. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists