Thread (4 messages) flat view 4 messages, 2 authors, 2019-08-19

Re: [PATCH] powerpc: optimise WARN_ON()

From: Segher Boessenkool <hidden>
Date: 2019-08-18 12:02:10
Also in: lkml

On Sat, Aug 17, 2019 at 09:04:42AM +0000, Christophe Leroy wrote:
Unlike BUG_ON(x), WARN_ON(x) uses !!(x) as the trigger
of the t(d/w)nei instruction instead of using directly the
value of x.

This leads to GCC adding unnecessary pair of addic/subfe.
And it has to, it is passed as an "r" to an asm, GCC has to put the "!!"
value into a register.
By using (x) instead of !!(x) like BUG_ON() does, the additional
instructions go away:
But is it correct?  What happens if you pass an int to WARN_ON, on a
64-bit kernel?

(You might want to have 64-bit generate either tw or td.  But, with
your __builtin_trap patch, all that will be automatic).


Segher
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help