[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8cf5b264-68be-42b8-b435-79b8d682fd7b@suse.com>
Date: Thu, 16 Jan 2025 17:08:55 +0200
From: Nikolay Borisov <nik.borisov@...e.com>
To: Ethan Zhao <haifeng.zhao@...ux.intel.com>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: tglx@...utronix.de, dave.hansen@...ux.intel.com, x86@...nel.org,
hpa@...or.com, xin@...or.com, andrew.cooper3@...rix.com, mingo@...hat.com,
bp@...en8.de, etzhao@...look.com
Subject: Re: [PATCH] x86/fred: Optimize the FRED entry by prioritizing
high-probability event dispatching
On 16.01.25 г. 8:51 ч., Ethan Zhao wrote:
> External interrupts (EVENT_TYPE_EXTINT) and system calls (EVENT_TYPE_OTHER)
> occur more frequently than other events in a typical system. Prioritizing
> these events saves CPU cycles and optimizes the efficiency of performance-
> critical paths.
>
<snip>
Can you also include some performance numbers?
> Signed-off-by: Ethan Zhao <haifeng.zhao@...ux.intel.com>
> ---
> base commit: 619f0b6fad524f08d493a98d55bac9ab8895e3a6
> ---
> arch/x86/entry/entry_fred.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c
> index f004a4dc74c2..591f47771ecf 100644
> --- a/arch/x86/entry/entry_fred.c
> +++ b/arch/x86/entry/entry_fred.c
> @@ -228,9 +228,18 @@ __visible noinstr void fred_entry_from_user(struct pt_regs *regs)
> /* Invalidate orig_ax so that syscall_get_nr() works correctly */
> regs->orig_ax = -1;
>
> - switch (regs->fred_ss.type) {
> - case EVENT_TYPE_EXTINT:
> + if (regs->fred_ss.type == EVENT_TYPE_EXTINT)
> return fred_extint(regs);
> + else if (regs->fred_ss.type == EVENT_TYPE_OTHER)
> + return fred_other(regs);
> +
> + /*
> + * Dispatch EVENT_TYPE_EXTINT and EVENT_TYPE_OTHER(syscall) type events
> + * first due to their high probability and let the compiler create binary search
> + * dispatching for the remaining events
> + */
nit: At least to me it makes sense to have the comment above the 'if' so
that the flow is linear.
> +
> + switch (regs->fred_ss.type) {
> case EVENT_TYPE_NMI:
> if (likely(regs->fred_ss.vector == X86_TRAP_NMI))
> return fred_exc_nmi(regs);
> @@ -245,8 +254,6 @@ __visible noinstr void fred_entry_from_user(struct pt_regs *regs)
> break;
> case EVENT_TYPE_SWEXC:
> return fred_swexc(regs, error_code);
> - case EVENT_TYPE_OTHER:
> - return fred_other(regs);
> default: break;
> }
>
> @@ -260,9 +267,15 @@ __visible noinstr void fred_entry_from_kernel(struct pt_regs *regs)
> /* Invalidate orig_ax so that syscall_get_nr() works correctly */
> regs->orig_ax = -1;
>
> - switch (regs->fred_ss.type) {
> - case EVENT_TYPE_EXTINT:
> + if (regs->fred_ss.type == EVENT_TYPE_EXTINT)
> return fred_extint(regs);
> +
> + /*
> + * Dispatch EVENT_TYPE_EXTINT type event first due to its high probability
> + * and let the compiler do binary search dispatching for the other events
> + */
> +
> + switch (regs->fred_ss.type) {
> case EVENT_TYPE_NMI:
> if (likely(regs->fred_ss.vector == X86_TRAP_NMI))
> return fred_exc_nmi(regs);
Powered by blists - more mailing lists