Re: [PATCH V6 3/8] x86/entry: Move PUSH_AND_CLEAR_REGS out of error_entry()

From: Borislav Petkov
Date: Thu Apr 28 2022 - 06:26:50 EST


On Thu, Apr 28, 2022 at 08:33:36AM +0800, Lai Jiangshan wrote:
> The branch in sync_regs() can be optimized out for the non-XENPV case
> since XENPV doesn't call sync_regs() after patch5 which makes XENPV
> not call error_entry().

I find it confusing why you're even mentioning optimizing a simple test.

That thing is basically a *whopping* two fastpath instructions:

# arch/x86/kernel/traps.c:853: if (regs != eregs)
cmpq %rdi, %rax # eregs, <retval>
je .L255 #,

Is this such a hot path that it shows in some profiles and removing that
test there is so important?

> The aim of this patch and most of the patchset is to make
> error_entry() be able to be converted to C. And XENPV cases can
> also be optimized in the patchset although it is not the major main.

So say just that.

> Since this patch adds extra overhead (CALL and RET), the changelog
> has to explain why it is worth it not just for converting ASM to C.

What is the practical relevance of this very minor overhead? Does it
show even in a microbenchmark?

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette