Re: [PATCH] mips: bug: add unlikely() to BUG_ON()

From: Igor Stoppa
Date: Mon Sep 10 2018 - 05:45:10 EST


Hi Paul,

On 08/09/18 01:02, Paul Burton wrote:

I'm not sure this will actually do anything.

__BUG_ON() doesn't use the value of its condition argument for regular
control flow unless it's compile-time constant anyway, in which case
unlikely() should be redundant because the compiler knows the value
already.

If the condition isn't compile-time constant then we just emit a tne
(trap-if-not-equal) instruction using inline asm. That will generate an
exception if the value is non-zero at runtime. I don't see how adding
unlikely() is going to help the compiler do anything differently with
that.

Thank you for the explanation. Please discard this patch.

--
igor