Thank you very much Longman, my patch is as you said, only disable node_cpu on X86, enable node_cpu on arm64, powerpc, s390 architectures;
the code is in file arch/x86/kernel/paravirt-spinlocks.c:
DECLARE_STATIC_KEY_FALSE(preemted_key);
static_branch_enable(&preemted_key);
the default value of preemted_key is false and the if conditional statement is reversed,
the code is in file kernel/locking/osq_lock.c:
DEFINE_STATIC_KEY_FALSE(preemted_key);
static inline int node_cpu(struct optimistic_spin_node *node)
{
int cpu = 0;
if (!static_branch_unlikely(&preemted_key))
cpu = node->cpu - 1;
return cpu;
}
In this way, only one nop instruction is added to architectures arm64, powerpc and s390, including virtual machines, without any other changes.