[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200727133020.GN119549@hirez.programming.kicks-ass.net>
Date: Mon, 27 Jul 2020 15:30:20 +0200
From: peterz@...radead.org
To: hpa@...or.com
Cc: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...e.de>,
Andy Lutomirski <luto@...nel.org>, x86@...nel.org,
Dave Hansen <dave.hansen@...el.com>,
Tony Luck <tony.luck@...el.com>,
Cathy Zhang <cathy.zhang@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Kyung Min Park <kyung.min.park@...el.com>,
"Ravi V. Shankar" <ravi.v.shankar@...el.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
linux-kernel@...r.kernel.org,
Ricardo Neri <ricardo.neri@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
linux-edac@...r.kernel.org, frederic@...nel.org
Subject: Re: [PATCH 4/4] x86/cpu: Use SERIALIZE in sync_core() when available
On Mon, Jul 27, 2020 at 03:05:36PM +0200, peterz@...radead.org wrote:
> Yeah, I'm not sure.. the 'funny' thing is that typically call
> sync_core() from an IPI anyway. And the synchronous broadcast IPI is by
> far the most expensive part of that.
>
> Something like this...
>
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 20e07feb4064..528e049ee1d9 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -989,12 +989,13 @@ void *text_poke_kgdb(void *addr, const void *opcode, size_t len)
>
> static void do_sync_core(void *info)
> {
> - sync_core();
> + /* IRET implies sync_core() */
> }
>
> void text_poke_sync(void)
> {
> on_each_cpu(do_sync_core, NULL, 1);
> + sync_core();
> }
>
> struct text_poke_loc {
So 'people' have wanted to optimize this for NOHZ_FULL and I suppose
virt as well.
IFF VMENTER is serializing, I suppose we can simply do something like:
bool text_poke_cond(int cpu, void *info)
{
/*
* If we observe the vCPU is preempted, it will do VMENTER
* no point in sending an IPI to SERIALIZE.
*/
return !vcpu_is_preempted(cpu);
}
void text_poke_sync(void)
{
smp_call_function_many_cond(cpu_possible_mask,
do_sync_core, NULL, 1, text_poke_cond);
sync_core();
}
The 'same' for NOHZ_FULL, except we need to cmpxchg a value such that
if the cmpxchg() succeeds we know the CPU is in userspace and will
SERIALIZE on the next entry. Much like kvm_flush_tlb_others().
Anyway, that's all hand-wavey.. I'll let someone that cares about those
things write actual patches :-)
Powered by blists - more mailing lists