Skip to content

Commit 2628cbd

Browse files
qzhuo2fbq
authored andcommitted
locking/pvqspinlock: Convert fields of 'enum vcpu_state' to uppercase
Convert the fields of 'enum vcpu_state' to uppercase for better readability. No functional changes intended. Acked-by: Waiman Long <[email protected]> Signed-off-by: Qiuxu Zhuo <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 560af5d commit 2628cbd

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

kernel/locking/qspinlock_paravirt.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
#define PV_PREV_CHECK_MASK 0xff
3939

4040
/*
41-
* Queue node uses: vcpu_running & vcpu_halted.
42-
* Queue head uses: vcpu_running & vcpu_hashed.
41+
* Queue node uses: VCPU_RUNNING & VCPU_HALTED.
42+
* Queue head uses: VCPU_RUNNING & VCPU_HASHED.
4343
*/
4444
enum vcpu_state {
45-
vcpu_running = 0,
46-
vcpu_halted, /* Used only in pv_wait_node */
47-
vcpu_hashed, /* = pv_hash'ed + vcpu_halted */
45+
VCPU_RUNNING = 0,
46+
VCPU_HALTED, /* Used only in pv_wait_node */
47+
VCPU_HASHED, /* = pv_hash'ed + VCPU_HALTED */
4848
};
4949

5050
struct pv_node {
@@ -266,7 +266,7 @@ pv_wait_early(struct pv_node *prev, int loop)
266266
if ((loop & PV_PREV_CHECK_MASK) != 0)
267267
return false;
268268

269-
return READ_ONCE(prev->state) != vcpu_running;
269+
return READ_ONCE(prev->state) != VCPU_RUNNING;
270270
}
271271

272272
/*
@@ -279,7 +279,7 @@ static void pv_init_node(struct mcs_spinlock *node)
279279
BUILD_BUG_ON(sizeof(struct pv_node) > sizeof(struct qnode));
280280

281281
pn->cpu = smp_processor_id();
282-
pn->state = vcpu_running;
282+
pn->state = VCPU_RUNNING;
283283
}
284284

285285
/*
@@ -308,26 +308,26 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)
308308
/*
309309
* Order pn->state vs pn->locked thusly:
310310
*
311-
* [S] pn->state = vcpu_halted [S] next->locked = 1
311+
* [S] pn->state = VCPU_HALTED [S] next->locked = 1
312312
* MB MB
313-
* [L] pn->locked [RmW] pn->state = vcpu_hashed
313+
* [L] pn->locked [RmW] pn->state = VCPU_HASHED
314314
*
315315
* Matches the cmpxchg() from pv_kick_node().
316316
*/
317-
smp_store_mb(pn->state, vcpu_halted);
317+
smp_store_mb(pn->state, VCPU_HALTED);
318318

319319
if (!READ_ONCE(node->locked)) {
320320
lockevent_inc(pv_wait_node);
321321
lockevent_cond_inc(pv_wait_early, wait_early);
322-
pv_wait(&pn->state, vcpu_halted);
322+
pv_wait(&pn->state, VCPU_HALTED);
323323
}
324324

325325
/*
326-
* If pv_kick_node() changed us to vcpu_hashed, retain that
326+
* If pv_kick_node() changed us to VCPU_HASHED, retain that
327327
* value so that pv_wait_head_or_lock() knows to not also try
328328
* to hash this lock.
329329
*/
330-
cmpxchg(&pn->state, vcpu_halted, vcpu_running);
330+
cmpxchg(&pn->state, VCPU_HALTED, VCPU_RUNNING);
331331

332332
/*
333333
* If the locked flag is still not set after wakeup, it is a
@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)
357357
static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node)
358358
{
359359
struct pv_node *pn = (struct pv_node *)node;
360-
u8 old = vcpu_halted;
360+
u8 old = VCPU_HALTED;
361361
/*
362362
* If the vCPU is indeed halted, advance its state to match that of
363363
* pv_wait_node(). If OTOH this fails, the vCPU was running and will
@@ -374,7 +374,7 @@ static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node)
374374
* subsequent writes.
375375
*/
376376
smp_mb__before_atomic();
377-
if (!try_cmpxchg_relaxed(&pn->state, &old, vcpu_hashed))
377+
if (!try_cmpxchg_relaxed(&pn->state, &old, VCPU_HASHED))
378378
return;
379379

380380
/*
@@ -407,7 +407,7 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
407407
* If pv_kick_node() already advanced our state, we don't need to
408408
* insert ourselves into the hash table anymore.
409409
*/
410-
if (READ_ONCE(pn->state) == vcpu_hashed)
410+
if (READ_ONCE(pn->state) == VCPU_HASHED)
411411
lp = (struct qspinlock **)1;
412412

413413
/*
@@ -420,7 +420,7 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
420420
* Set correct vCPU state to be used by queue node wait-early
421421
* mechanism.
422422
*/
423-
WRITE_ONCE(pn->state, vcpu_running);
423+
WRITE_ONCE(pn->state, VCPU_RUNNING);
424424

425425
/*
426426
* Set the pending bit in the active lock spinning loop to
@@ -460,7 +460,7 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
460460
goto gotlock;
461461
}
462462
}
463-
WRITE_ONCE(pn->state, vcpu_hashed);
463+
WRITE_ONCE(pn->state, VCPU_HASHED);
464464
lockevent_inc(pv_wait_head);
465465
lockevent_cond_inc(pv_wait_again, waitcnt);
466466
pv_wait(&lock->locked, _Q_SLOW_VAL);

0 commit comments

Comments
 (0)