Skip to content

Commit b3dae10

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
sched/swait: Rename to exclusive
Since swait basically implemented exclusive waits only, make sure the API reflects that. $ git grep -l -e "\<swake_up\>" -e "\<swait_event[^ (]*" -e "\<prepare_to_swait\>" | while read file; do sed -i -e 's/\<swake_up\>/&_one/g' -e 's/\<swait_event[^ (]*/&_exclusive/g' -e 's/\<prepare_to_swait\>/&_exclusive/g' $file; done With a few manual touch-ups. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: bigeasy@linutronix.de Cc: oleg@redhat.com Cc: paulmck@linux.vnet.ibm.com Cc: pbonzini@redhat.com Link: https://lkml.kernel.org/r/20180612083909.261946548@infradead.org
1 parent 0abf17b commit b3dae10

16 files changed

Lines changed: 48 additions & 48 deletions

File tree

‎arch/mips/kvm/mips.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
515515
dvcpu->arch.wait = 0;
516516

517517
if (swq_has_sleeper(&dvcpu->wq))
518-
swake_up(&dvcpu->wq);
518+
swake_up_one(&dvcpu->wq);
519519

520520
return 0;
521521
}
@@ -1204,7 +1204,7 @@ static void kvm_mips_comparecount_func(unsigned long data)
12041204

12051205
vcpu->arch.wait = 0;
12061206
if (swq_has_sleeper(&vcpu->wq))
1207-
swake_up(&vcpu->wq);
1207+
swake_up_one(&vcpu->wq);
12081208
}
12091209

12101210
/* low level hrtimer wake routine */

‎arch/powerpc/kvm/book3s_hv.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu)
216216

217217
wqp = kvm_arch_vcpu_wq(vcpu);
218218
if (swq_has_sleeper(wqp)) {
219-
swake_up(wqp);
219+
swake_up_one(wqp);
220220
++vcpu->stat.halt_wakeup;
221221
}
222222

@@ -3188,7 +3188,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
31883188
}
31893189
}
31903190

3191-
prepare_to_swait(&vc->wq, &wait, TASK_INTERRUPTIBLE);
3191+
prepare_to_swait_exclusive(&vc->wq, &wait, TASK_INTERRUPTIBLE);
31923192

31933193
if (kvmppc_vcore_check_block(vc)) {
31943194
finish_swait(&vc->wq, &wait);
@@ -3311,7 +3311,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
33113311
kvmppc_start_thread(vcpu, vc);
33123312
trace_kvm_guest_enter(vcpu);
33133313
} else if (vc->vcore_state == VCORE_SLEEPING) {
3314-
swake_up(&vc->wq);
3314+
swake_up_one(&vc->wq);
33153315
}
33163316

33173317
}

‎arch/s390/kvm/interrupt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu)
11451145
* yield-candidate.
11461146
*/
11471147
vcpu->preempted = true;
1148-
swake_up(&vcpu->wq);
1148+
swake_up_one(&vcpu->wq);
11491149
vcpu->stat.halt_wakeup++;
11501150
}
11511151
/*

‎arch/x86/kernel/kvm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void kvm_async_pf_task_wait(u32 token, int interrupt_kernel)
154154

155155
for (;;) {
156156
if (!n.halted)
157-
prepare_to_swait(&n.wq, &wait, TASK_UNINTERRUPTIBLE);
157+
prepare_to_swait_exclusive(&n.wq, &wait, TASK_UNINTERRUPTIBLE);
158158
if (hlist_unhashed(&n.link))
159159
break;
160160

@@ -188,7 +188,7 @@ static void apf_task_wake_one(struct kvm_task_sleep_node *n)
188188
if (n->halted)
189189
smp_send_reschedule(n->cpu);
190190
else if (swq_has_sleeper(&n->wq))
191-
swake_up(&n->wq);
191+
swake_up_one(&n->wq);
192192
}
193193

194194
static void apf_task_wake_all(void)

‎arch/x86/kvm/lapic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ static void apic_timer_expired(struct kvm_lapic *apic)
13791379
* using swait_active() is safe.
13801380
*/
13811381
if (swait_active(q))
1382-
swake_up(q);
1382+
swake_up_one(q);
13831383

13841384
if (apic_lvtt_tscdeadline(apic))
13851385
ktimer->expired_tscdeadline = ktimer->tscdeadline;

‎include/linux/swait.h‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* wait-queues, but the semantics are actually completely different, and
1717
* every single user we have ever had has been buggy (or pointless).
1818
*
19-
* A "swake_up()" only wakes up _one_ waiter, which is not at all what
19+
* A "swake_up_one()" only wakes up _one_ waiter, which is not at all what
2020
* "wake_up()" does, and has led to problems. In other cases, it has
2121
* been fine, because there's only ever one waiter (kvm), but in that
2222
* case gthe whole "simple" wait-queue is just pointless to begin with,
@@ -115,7 +115,7 @@ extern void __init_swait_queue_head(struct swait_queue_head *q, const char *name
115115
* CPU0 - waker CPU1 - waiter
116116
*
117117
* for (;;) {
118-
* @cond = true; prepare_to_swait(&wq_head, &wait, state);
118+
* @cond = true; prepare_to_swait_exclusive(&wq_head, &wait, state);
119119
* smp_mb(); // smp_mb() from set_current_state()
120120
* if (swait_active(wq_head)) if (@cond)
121121
* wake_up(wq_head); break;
@@ -157,11 +157,11 @@ static inline bool swq_has_sleeper(struct swait_queue_head *wq)
157157
return swait_active(wq);
158158
}
159159

160-
extern void swake_up(struct swait_queue_head *q);
160+
extern void swake_up_one(struct swait_queue_head *q);
161161
extern void swake_up_all(struct swait_queue_head *q);
162162
extern void swake_up_locked(struct swait_queue_head *q);
163163

164-
extern void prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait, int state);
164+
extern void prepare_to_swait_exclusive(struct swait_queue_head *q, struct swait_queue *wait, int state);
165165
extern long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait, int state);
166166

167167
extern void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
@@ -196,7 +196,7 @@ __out: __ret; \
196196
(void)___swait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, \
197197
schedule())
198198

199-
#define swait_event(wq, condition) \
199+
#define swait_event_exclusive(wq, condition) \
200200
do { \
201201
if (condition) \
202202
break; \
@@ -208,7 +208,7 @@ do { \
208208
TASK_UNINTERRUPTIBLE, timeout, \
209209
__ret = schedule_timeout(__ret))
210210

211-
#define swait_event_timeout(wq, condition, timeout) \
211+
#define swait_event_timeout_exclusive(wq, condition, timeout) \
212212
({ \
213213
long __ret = timeout; \
214214
if (!___wait_cond_timeout(condition)) \
@@ -220,7 +220,7 @@ do { \
220220
___swait_event(wq, condition, TASK_INTERRUPTIBLE, 0, \
221221
schedule())
222222

223-
#define swait_event_interruptible(wq, condition) \
223+
#define swait_event_interruptible_exclusive(wq, condition) \
224224
({ \
225225
int __ret = 0; \
226226
if (!(condition)) \
@@ -233,7 +233,7 @@ do { \
233233
TASK_INTERRUPTIBLE, timeout, \
234234
__ret = schedule_timeout(__ret))
235235

236-
#define swait_event_interruptible_timeout(wq, condition, timeout) \
236+
#define swait_event_interruptible_timeout_exclusive(wq, condition, timeout)\
237237
({ \
238238
long __ret = timeout; \
239239
if (!___wait_cond_timeout(condition)) \
@@ -246,7 +246,7 @@ do { \
246246
(void)___swait_event(wq, condition, TASK_IDLE, 0, schedule())
247247

248248
/**
249-
* swait_event_idle - wait without system load contribution
249+
* swait_event_idle_exclusive - wait without system load contribution
250250
* @wq: the waitqueue to wait on
251251
* @condition: a C expression for the event to wait for
252252
*
@@ -257,7 +257,7 @@ do { \
257257
* condition and doesn't want to contribute to system load. Signals are
258258
* ignored.
259259
*/
260-
#define swait_event_idle(wq, condition) \
260+
#define swait_event_idle_exclusive(wq, condition) \
261261
do { \
262262
if (condition) \
263263
break; \
@@ -270,7 +270,7 @@ do { \
270270
__ret = schedule_timeout(__ret))
271271

272272
/**
273-
* swait_event_idle_timeout - wait up to timeout without load contribution
273+
* swait_event_idle_timeout_exclusive - wait up to timeout without load contribution
274274
* @wq: the waitqueue to wait on
275275
* @condition: a C expression for the event to wait for
276276
* @timeout: timeout at which we'll give up in jiffies
@@ -288,7 +288,7 @@ do { \
288288
* or the remaining jiffies (at least 1) if the @condition evaluated
289289
* to %true before the @timeout elapsed.
290290
*/
291-
#define swait_event_idle_timeout(wq, condition, timeout) \
291+
#define swait_event_idle_timeout_exclusive(wq, condition, timeout) \
292292
({ \
293293
long __ret = timeout; \
294294
if (!___wait_cond_timeout(condition)) \

‎kernel/power/suspend.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void s2idle_enter(void)
9292
/* Push all the CPUs into the idle loop. */
9393
wake_up_all_idle_cpus();
9494
/* Make the current CPU wait so it can enter the idle loop too. */
95-
swait_event(s2idle_wait_head,
95+
swait_event_exclusive(s2idle_wait_head,
9696
s2idle_state == S2IDLE_STATE_WAKE);
9797

9898
cpuidle_pause();
@@ -160,7 +160,7 @@ void s2idle_wake(void)
160160
raw_spin_lock_irqsave(&s2idle_lock, flags);
161161
if (s2idle_state > S2IDLE_STATE_NONE) {
162162
s2idle_state = S2IDLE_STATE_WAKE;
163-
swake_up(&s2idle_wait_head);
163+
swake_up_one(&s2idle_wait_head);
164164
}
165165
raw_spin_unlock_irqrestore(&s2idle_lock, flags);
166166
}

‎kernel/rcu/srcutiny.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
110110

111111
WRITE_ONCE(sp->srcu_lock_nesting[idx], newval);
112112
if (!newval && READ_ONCE(sp->srcu_gp_waiting))
113-
swake_up(&sp->srcu_wq);
113+
swake_up_one(&sp->srcu_wq);
114114
}
115115
EXPORT_SYMBOL_GPL(__srcu_read_unlock);
116116

@@ -140,7 +140,7 @@ void srcu_drive_gp(struct work_struct *wp)
140140
idx = sp->srcu_idx;
141141
WRITE_ONCE(sp->srcu_idx, !sp->srcu_idx);
142142
WRITE_ONCE(sp->srcu_gp_waiting, true); /* srcu_read_unlock() wakes! */
143-
swait_event(sp->srcu_wq, !READ_ONCE(sp->srcu_lock_nesting[idx]));
143+
swait_event_exclusive(sp->srcu_wq, !READ_ONCE(sp->srcu_lock_nesting[idx]));
144144
WRITE_ONCE(sp->srcu_gp_waiting, false); /* srcu_read_unlock() cheap. */
145145

146146
/* Invoke the callbacks we removed above. */

‎kernel/rcu/tree.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ static void rcu_gp_kthread_wake(struct rcu_state *rsp)
17271727
!READ_ONCE(rsp->gp_flags) ||
17281728
!rsp->gp_kthread)
17291729
return;
1730-
swake_up(&rsp->gp_wq);
1730+
swake_up_one(&rsp->gp_wq);
17311731
}
17321732

17331733
/*
@@ -2002,7 +2002,7 @@ static bool rcu_gp_init(struct rcu_state *rsp)
20022002
}
20032003

20042004
/*
2005-
* Helper function for swait_event_idle() wakeup at force-quiescent-state
2005+
* Helper function for swait_event_idle_exclusive() wakeup at force-quiescent-state
20062006
* time.
20072007
*/
20082008
static bool rcu_gp_fqs_check_wake(struct rcu_state *rsp, int *gfp)
@@ -2144,7 +2144,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
21442144
READ_ONCE(rsp->gpnum),
21452145
TPS("reqwait"));
21462146
rsp->gp_state = RCU_GP_WAIT_GPS;
2147-
swait_event_idle(rsp->gp_wq, READ_ONCE(rsp->gp_flags) &
2147+
swait_event_idle_exclusive(rsp->gp_wq, READ_ONCE(rsp->gp_flags) &
21482148
RCU_GP_FLAG_INIT);
21492149
rsp->gp_state = RCU_GP_DONE_GPS;
21502150
/* Locking provides needed memory barrier. */
@@ -2176,7 +2176,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
21762176
READ_ONCE(rsp->gpnum),
21772177
TPS("fqswait"));
21782178
rsp->gp_state = RCU_GP_WAIT_FQS;
2179-
ret = swait_event_idle_timeout(rsp->gp_wq,
2179+
ret = swait_event_idle_timeout_exclusive(rsp->gp_wq,
21802180
rcu_gp_fqs_check_wake(rsp, &gf), j);
21812181
rsp->gp_state = RCU_GP_DOING_FQS;
21822182
/* Locking provides needed memory barriers. */

‎kernel/rcu/tree_exp.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void __rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
212212
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
213213
if (wake) {
214214
smp_mb(); /* EGP done before wake_up(). */
215-
swake_up(&rsp->expedited_wq);
215+
swake_up_one(&rsp->expedited_wq);
216216
}
217217
break;
218218
}
@@ -518,7 +518,7 @@ static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
518518
jiffies_start = jiffies;
519519

520520
for (;;) {
521-
ret = swait_event_timeout(
521+
ret = swait_event_timeout_exclusive(
522522
rsp->expedited_wq,
523523
sync_rcu_preempt_exp_done_unlocked(rnp_root),
524524
jiffies_stall);

0 commit comments

Comments
 (0)