Re: [RFC PATCH 23/23] x86/process: Reset hardware history in context switch

From: Peter Zijlstra
Date: Tue Sep 27 2022 - 08:53:54 EST


On Fri, Sep 09, 2022 at 04:12:05PM -0700, Ricardo Neri wrote:
> Reset the classification history of the current task when switching to
> the next task. Hardware will start anew the classification of the next
> running task.

Please quantify the cost of this HRESET instruction.

> diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
> index 2f314b170c9f..74d8ad83e0b3 100644
> --- a/arch/x86/kernel/process_32.c
> +++ b/arch/x86/kernel/process_32.c
> @@ -52,6 +52,7 @@
> #include <asm/switch_to.h>
> #include <asm/vm86.h>
> #include <asm/resctrl.h>
> +#include <asm/hreset.h>
> #include <asm/proto.h>
>
> #include "process.h"
> @@ -214,6 +215,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
> /* Load the Intel cache allocation PQR MSR. */
> resctrl_sched_in();
>
> + reset_hardware_history();
> +
> return prev_p;
> }
>
> diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> index 1962008fe743..0b175f30f359 100644
> --- a/arch/x86/kernel/process_64.c
> +++ b/arch/x86/kernel/process_64.c
> @@ -53,6 +53,7 @@
> #include <asm/xen/hypervisor.h>
> #include <asm/vdso.h>
> #include <asm/resctrl.h>
> +#include <asm/hreset.h>
> #include <asm/unistd.h>
> #include <asm/fsgsbase.h>
> #ifdef CONFIG_IA32_EMULATION
> @@ -657,6 +658,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
> /* Load the Intel cache allocation PQR MSR. */
> resctrl_sched_in();
>
> + reset_hardware_history();
> +
> return prev_p;
> }
>
> --
> 2.25.1
>