// SPDX-License-Identifier: GPL-2.0 /* * Split spinlock implementation out into its own file, so it can be * compiled in a FTRACE-compatible way.
*/ #include <linux/kernel.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <linux/atomic.h>
staticvoid xen_qlock_kick(int cpu)
{ int irq = per_cpu(lock_kicker_irq, cpu);
/* Don't kick if the target's kicker interrupt is not initialized. */ if (irq == -1) return;
xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR);
}
/* * Halt the current CPU & release it back to the host
*/ staticvoid xen_qlock_wait(u8 *byte, u8 val)
{ int irq = __this_cpu_read(lock_kicker_irq);
atomic_t *nest_cnt = this_cpu_ptr(&xen_qlock_wait_nest);
/* If kicker interrupts not initialized yet, just spin */ if (irq == -1 || in_nmi()) return;
/* Detect reentry. */
atomic_inc(nest_cnt);
/* If irq pending already and no nested call clear it. */ if (atomic_read(nest_cnt) == 1 && xen_test_irq_pending(irq)) {
xen_clear_irq_pending(irq);
} elseif (READ_ONCE(*byte) == val) { /* Block until irq becomes pending (or a spurious wakeup) */
xen_poll_irq(irq);
}
kfree(per_cpu(irq_name, cpu));
per_cpu(irq_name, cpu) = NULL; /* * When booting the kernel with 'mitigations=auto,nosmt', the secondary * CPUs are not activated, and lock_kicker_irq is not initialized.
*/
irq = per_cpu(lock_kicker_irq, cpu); if (irq == -1) return;
/* * Our init of PV spinlocks is split in two init functions due to us * using paravirt patching and jump labels patching and having to do * all of this before SMP code is invoked. * * The paravirt patching needs to be done _before_ the alternative asm code * is started, otherwise we would not patch the core kernel code.
*/ void __init xen_init_spinlocks(void)
{ /* Don't need to use pvqspinlock code if there is only 1 vCPU. */ if (num_possible_cpus() == 1)
nopvspin = true;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.