Re: [PATCH 2/2] x86/mce: Add quirk for instruction recovery on SandyBridge processors

From: Borislav Petkov
Date: Sat Jul 21 2012 - 08:45:51 EST

On Fri, Jul 20, 2012 at 09:33:23AM -0700, Tony Luck wrote:
> > Maybe define a default empty quirk_no_way_out() on the remaining
> > families/vendors so that the compiler can optimize it away and we save
> > ourselves the if-test?
> Perhaps I misunderstood your suggestion. I don't see how the compiler will
> manage to optimize it all away. I just tried defining
> static void quirk_no_way_out_nop(int bank, struct mce *m, struct pt_regs *regs)
> {
> }
> and providing that as an initial value for the quirk_no_way_out
> function pointer.
> Then I deleted the "if (quirk_no_way_out)".
> Looking at the assembly code produced, I now just have an unconditional call:
> callq *0x9fe992(%rip) # ffffffff81a18668 <quirk_no_way_out>
> I'd think that a call through a function pointer to an empty function is
> more expensive that testing whether that function pointer was NULL.


Right, so I was thinking about something along the lines of what tglx
did for the CMCI poll timer: and
I've been playing with this for a bit now and am seeing the same thing
as you: obviously the compiler cannot optimize away an unconditional
function call to an empty function *through* a function pointer
(tried gcc 4.6 and 4.7). Maybe because it is a function pointer we're

If you make the function pointer const like this:

static void default_quirk_no_way_out(int bank, struct mce *m,
struct pt_regs *regs) { }

static void (* const quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs) =

The "call... " is not issued but you cannot assign to it later in

Other things which could probably be used are alternatives or jump
labels but one if-test is simply not worth the complexity.

Oh well, enough games.



Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at