Re: [PATCH 37/49] x86/alternatives: Move text_poke_array completion from smp_text_poke_batch_finish() and smp_text_poke_batch_flush() to smp_text_poke_batch_process()

From: Nikolay Borisov
Date: Thu Apr 03 2025 - 11:39:37 EST




On 3.04.25 г. 18:29 ч., Ingo Molnar wrote:

* Nikolay Borisov <nik.borisov@xxxxxxxx> wrote:

I meant doing this:

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 5b1a6252a4b9..b6a781b9de26 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -2587,12 +2587,16 @@ noinstr int smp_text_poke_int3_trap_handler(struct
pt_regs *regs)
* replacing opcode
* - SMP sync all CPUs
*/
-static void smp_text_poke_batch_process(void)
+void smp_text_poke_batch_finish(void)
{
unsigned char int3 = INT3_INSN_OPCODE;
unsigned int i;
int do_sync;

+
+ if (!text_poke_array.nr_entries)
+ return;

- smp_text_poke_batch_process();
+ smp_text_poke_batch_finish();

I suppose we could do this - it adds one more check to
smp_text_poke_batch_add() though.

poke_batch_finish you meant?


AFAICS this doesn't change the semantics. I.e smp_text_poke_batch_add
will call poke_batch_finish iff the address to be added violates the
sorted order of text_poke_array. The net effect is we have 1 less
function name to care about.

Yeah, it doesn't change semantics, but it's a very small
deoptimization.
> > Mind sending a patch? It does simplify the facility some more and that
single branch will wash away against costs like the CR3 flushes done

Given that poke_batch_finish does a cond_resched and sync_each_cpu which is an IPI can it even be considered a performance critical path ?

...

Thanks,

Ingo