.. | .. |
---|
3 | 3 | * Split spinlock implementation out into its own file, so it can be |
---|
4 | 4 | * compiled in a FTRACE-compatible way. |
---|
5 | 5 | */ |
---|
6 | | -#include <linux/kernel_stat.h> |
---|
| 6 | +#include <linux/kernel.h> |
---|
7 | 7 | #include <linux/spinlock.h> |
---|
8 | | -#include <linux/debugfs.h> |
---|
9 | | -#include <linux/log2.h> |
---|
10 | | -#include <linux/gfp.h> |
---|
11 | 8 | #include <linux/slab.h> |
---|
12 | 9 | #include <linux/atomic.h> |
---|
13 | 10 | |
---|
14 | 11 | #include <asm/paravirt.h> |
---|
15 | 12 | #include <asm/qspinlock.h> |
---|
16 | 13 | |
---|
17 | | -#include <xen/interface/xen.h> |
---|
18 | 14 | #include <xen/events.h> |
---|
19 | 15 | |
---|
20 | 16 | #include "xen-ops.h" |
---|
21 | | -#include "debugfs.h" |
---|
22 | 17 | |
---|
23 | 18 | static DEFINE_PER_CPU(int, lock_kicker_irq) = -1; |
---|
24 | 19 | static DEFINE_PER_CPU(char *, irq_name); |
---|
.. | .. |
---|
73 | 68 | int irq; |
---|
74 | 69 | char *name; |
---|
75 | 70 | |
---|
76 | | - if (!xen_pvspin) { |
---|
77 | | - if (cpu == 0) |
---|
78 | | - static_branch_disable(&virt_spin_lock_key); |
---|
| 71 | + if (!xen_pvspin) |
---|
79 | 72 | return; |
---|
80 | | - } |
---|
81 | 73 | |
---|
82 | 74 | WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n", |
---|
83 | 75 | cpu, per_cpu(lock_kicker_irq, cpu)); |
---|
84 | 76 | |
---|
85 | 77 | name = kasprintf(GFP_KERNEL, "spinlock%d", cpu); |
---|
| 78 | + per_cpu(irq_name, cpu) = name; |
---|
86 | 79 | irq = bind_ipi_to_irqhandler(XEN_SPIN_UNLOCK_VECTOR, |
---|
87 | 80 | cpu, |
---|
88 | 81 | dummy_handler, |
---|
.. | .. |
---|
93 | 86 | if (irq >= 0) { |
---|
94 | 87 | disable_irq(irq); /* make sure it's never delivered */ |
---|
95 | 88 | per_cpu(lock_kicker_irq, cpu) = irq; |
---|
96 | | - per_cpu(irq_name, cpu) = name; |
---|
97 | 89 | } |
---|
98 | 90 | |
---|
99 | 91 | printk("cpu %d spinlock event irq %d\n", cpu, irq); |
---|
.. | .. |
---|
106 | 98 | if (!xen_pvspin) |
---|
107 | 99 | return; |
---|
108 | 100 | |
---|
| 101 | + kfree(per_cpu(irq_name, cpu)); |
---|
| 102 | + per_cpu(irq_name, cpu) = NULL; |
---|
109 | 103 | /* |
---|
110 | 104 | * When booting the kernel with 'mitigations=auto,nosmt', the secondary |
---|
111 | 105 | * CPUs are not activated, and lock_kicker_irq is not initialized. |
---|
.. | .. |
---|
116 | 110 | |
---|
117 | 111 | unbind_from_irqhandler(irq, NULL); |
---|
118 | 112 | per_cpu(lock_kicker_irq, cpu) = -1; |
---|
119 | | - kfree(per_cpu(irq_name, cpu)); |
---|
120 | | - per_cpu(irq_name, cpu) = NULL; |
---|
121 | 113 | } |
---|
122 | 114 | |
---|
123 | 115 | PV_CALLEE_SAVE_REGS_THUNK(xen_vcpu_stolen); |
---|
.. | .. |
---|
132 | 124 | */ |
---|
133 | 125 | void __init xen_init_spinlocks(void) |
---|
134 | 126 | { |
---|
135 | | - |
---|
136 | 127 | /* Don't need to use pvqspinlock code if there is only 1 vCPU. */ |
---|
137 | | - if (num_possible_cpus() == 1) |
---|
| 128 | + if (num_possible_cpus() == 1 || nopvspin) |
---|
138 | 129 | xen_pvspin = false; |
---|
139 | 130 | |
---|
140 | 131 | if (!xen_pvspin) { |
---|
141 | 132 | printk(KERN_DEBUG "xen: PV spinlocks disabled\n"); |
---|
| 133 | + static_branch_disable(&virt_spin_lock_key); |
---|
142 | 134 | return; |
---|
143 | 135 | } |
---|
144 | 136 | printk(KERN_DEBUG "xen: PV spinlocks enabled\n"); |
---|
145 | 137 | |
---|
146 | 138 | __pv_init_lock_hash(); |
---|
147 | | - pv_lock_ops.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath; |
---|
148 | | - pv_lock_ops.queued_spin_unlock = PV_CALLEE_SAVE(__pv_queued_spin_unlock); |
---|
149 | | - pv_lock_ops.wait = xen_qlock_wait; |
---|
150 | | - pv_lock_ops.kick = xen_qlock_kick; |
---|
151 | | - pv_lock_ops.vcpu_is_preempted = PV_CALLEE_SAVE(xen_vcpu_stolen); |
---|
| 139 | + pv_ops.lock.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath; |
---|
| 140 | + pv_ops.lock.queued_spin_unlock = |
---|
| 141 | + PV_CALLEE_SAVE(__pv_queued_spin_unlock); |
---|
| 142 | + pv_ops.lock.wait = xen_qlock_wait; |
---|
| 143 | + pv_ops.lock.kick = xen_qlock_kick; |
---|
| 144 | + pv_ops.lock.vcpu_is_preempted = PV_CALLEE_SAVE(xen_vcpu_stolen); |
---|
152 | 145 | } |
---|
153 | 146 | |
---|
154 | 147 | static __init int xen_parse_nopvspin(char *arg) |
---|
155 | 148 | { |
---|
| 149 | + pr_notice("\"xen_nopvspin\" is deprecated, please use \"nopvspin\" instead\n"); |
---|
156 | 150 | xen_pvspin = false; |
---|
157 | 151 | return 0; |
---|
158 | 152 | } |
---|