Re: [tip:perfcounters/core] perf_counter: x86: Fix call-chain supportto use NMI-safe methods

From: Linus Torvalds
Date: Mon Jun 15 2009 - 14:53:02 EST




On Mon, 15 Jun 2009, Ingo Molnar wrote:
>
> [ If on the other hand it's a speedup of a few cycles then we have
> the problem of me suddenly liking this patch a whole lot more ;-) ]

I missed the patch.

It's quite possible that replacing "iret" with a regular "ret" (for the
kernel->kernel transition) is a real speedup. That said, there's a few
things to think about:

- CPU return stack caches/predictors. I suspect that "iret" and
exceptions don't generally touch them (but who knows - maybe they do),
while a regular "ret" definitely does. I dunno about "retf".

This can cause very subtle performance slowdowns, where the slowdown
happens somewhere else. And it could be _very_ uarch-dependent (ie only
happen on some architectures, while having no performance downside on
others)

- kernel->kernel exceptions _should_ be rare, with the exception of
actual real external interrupts. So the path to optimize should always
be the user-space exception path. That one will need 'iret', but I'd
also not want to see more testing in that hot-path. I suspect we
already always test for user-mode anyway (due to signal handling etc
work), but if it adds new tests to that path, any kernel->kernel
speedup is likely totally pointless.

That said, it would be nice to avoid 'iret' if only because of its subtle
interactions with the while NMI flag.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/