qspinlock.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Queued spinlock
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
  15. * (C) Copyright 2013-2014 Red Hat, Inc.
  16. * (C) Copyright 2015 Intel Corp.
  17. * (C) Copyright 2015 Hewlett-Packard Enterprise Development LP
  18. *
  19. * Authors: Waiman Long <waiman.long@hpe.com>
  20. * Peter Zijlstra <peterz@infradead.org>
  21. */
  22. #ifndef _GEN_PV_LOCK_SLOWPATH
  23. #include <linux/smp.h>
  24. #include <linux/bug.h>
  25. #include <linux/cpumask.h>
  26. #include <linux/percpu.h>
  27. #include <linux/hardirq.h>
  28. #include <linux/mutex.h>
  29. #include <asm/byteorder.h>
  30. #include <asm/qspinlock.h>
  31. /*
  32. * The basic principle of a queue-based spinlock can best be understood
  33. * by studying a classic queue-based spinlock implementation called the
  34. * MCS lock. The paper below provides a good description for this kind
  35. * of lock.
  36. *
  37. * http://www.cise.ufl.edu/tr/DOC/REP-1992-71.pdf
  38. *
  39. * This queued spinlock implementation is based on the MCS lock, however to make
  40. * it fit the 4 bytes we assume spinlock_t to be, and preserve its existing
  41. * API, we must modify it somehow.
  42. *
  43. * In particular; where the traditional MCS lock consists of a tail pointer
  44. * (8 bytes) and needs the next pointer (another 8 bytes) of its own node to
  45. * unlock the next pending (next->locked), we compress both these: {tail,
  46. * next->locked} into a single u32 value.
  47. *
  48. * Since a spinlock disables recursion of its own context and there is a limit
  49. * to the contexts that can nest; namely: task, softirq, hardirq, nmi. As there
  50. * are at most 4 nesting levels, it can be encoded by a 2-bit number. Now
  51. * we can encode the tail by combining the 2-bit nesting level with the cpu
  52. * number. With one byte for the lock value and 3 bytes for the tail, only a
  53. * 32-bit word is now needed. Even though we only need 1 bit for the lock,
  54. * we extend it to a full byte to achieve better performance for architectures
  55. * that support atomic byte write.
  56. *
  57. * We also change the first spinner to spin on the lock bit instead of its
  58. * node; whereby avoiding the need to carry a node from lock to unlock, and
  59. * preserving existing lock API. This also makes the unlock code simpler and
  60. * faster.
  61. *
  62. * N.B. The current implementation only supports architectures that allow
  63. * atomic operations on smaller 8-bit and 16-bit data types.
  64. *
  65. */
  66. #include "mcs_spinlock.h"
  67. #ifdef CONFIG_PARAVIRT_SPINLOCKS
  68. #define MAX_NODES 8
  69. #else
  70. #define MAX_NODES 4
  71. #endif
  72. /*
  73. * The pending bit spinning loop count.
  74. * This heuristic is used to limit the number of lockword accesses
  75. * made by atomic_cond_read_relaxed when waiting for the lock to
  76. * transition out of the "== _Q_PENDING_VAL" state. We don't spin
  77. * indefinitely because there's no guarantee that we'll make forward
  78. * progress.
  79. */
  80. #ifndef _Q_PENDING_LOOPS
  81. #define _Q_PENDING_LOOPS 1
  82. #endif
  83. /*
  84. * Per-CPU queue node structures; we can never have more than 4 nested
  85. * contexts: task, softirq, hardirq, nmi.
  86. *
  87. * Exactly fits one 64-byte cacheline on a 64-bit architecture.
  88. *
  89. * PV doubles the storage and uses the second cacheline for PV state.
  90. */
  91. static DEFINE_PER_CPU_ALIGNED(struct mcs_spinlock, mcs_nodes[MAX_NODES]);
  92. /*
  93. * We must be able to distinguish between no-tail and the tail at 0:0,
  94. * therefore increment the cpu number by one.
  95. */
  96. static inline __pure u32 encode_tail(int cpu, int idx)
  97. {
  98. u32 tail;
  99. #ifdef CONFIG_DEBUG_SPINLOCK
  100. BUG_ON(idx > 3);
  101. #endif
  102. tail = (cpu + 1) << _Q_TAIL_CPU_OFFSET;
  103. tail |= idx << _Q_TAIL_IDX_OFFSET; /* assume < 4 */
  104. return tail;
  105. }
  106. static inline __pure struct mcs_spinlock *decode_tail(u32 tail)
  107. {
  108. int cpu = (tail >> _Q_TAIL_CPU_OFFSET) - 1;
  109. int idx = (tail & _Q_TAIL_IDX_MASK) >> _Q_TAIL_IDX_OFFSET;
  110. return per_cpu_ptr(&mcs_nodes[idx], cpu);
  111. }
  112. #define _Q_LOCKED_PENDING_MASK (_Q_LOCKED_MASK | _Q_PENDING_MASK)
  113. #if _Q_PENDING_BITS == 8
  114. /**
  115. * clear_pending - clear the pending bit.
  116. * @lock: Pointer to queued spinlock structure
  117. *
  118. * *,1,* -> *,0,*
  119. */
  120. static __always_inline void clear_pending(struct qspinlock *lock)
  121. {
  122. WRITE_ONCE(lock->pending, 0);
  123. }
  124. /**
  125. * clear_pending_set_locked - take ownership and clear the pending bit.
  126. * @lock: Pointer to queued spinlock structure
  127. *
  128. * *,1,0 -> *,0,1
  129. *
  130. * Lock stealing is not allowed if this function is used.
  131. */
  132. static __always_inline void clear_pending_set_locked(struct qspinlock *lock)
  133. {
  134. WRITE_ONCE(lock->locked_pending, _Q_LOCKED_VAL);
  135. }
  136. /*
  137. * xchg_tail - Put in the new queue tail code word & retrieve previous one
  138. * @lock : Pointer to queued spinlock structure
  139. * @tail : The new queue tail code word
  140. * Return: The previous queue tail code word
  141. *
  142. * xchg(lock, tail), which heads an address dependency
  143. *
  144. * p,*,* -> n,*,* ; prev = xchg(lock, node)
  145. */
  146. static __always_inline u32 xchg_tail(struct qspinlock *lock, u32 tail)
  147. {
  148. /*
  149. * Use release semantics to make sure that the MCS node is properly
  150. * initialized before changing the tail code.
  151. */
  152. return (u32)xchg_release(&lock->tail,
  153. tail >> _Q_TAIL_OFFSET) << _Q_TAIL_OFFSET;
  154. }
  155. #else /* _Q_PENDING_BITS == 8 */
  156. /**
  157. * clear_pending - clear the pending bit.
  158. * @lock: Pointer to queued spinlock structure
  159. *
  160. * *,1,* -> *,0,*
  161. */
  162. static __always_inline void clear_pending(struct qspinlock *lock)
  163. {
  164. atomic_andnot(_Q_PENDING_VAL, &lock->val);
  165. }
  166. /**
  167. * clear_pending_set_locked - take ownership and clear the pending bit.
  168. * @lock: Pointer to queued spinlock structure
  169. *
  170. * *,1,0 -> *,0,1
  171. */
  172. static __always_inline void clear_pending_set_locked(struct qspinlock *lock)
  173. {
  174. atomic_add(-_Q_PENDING_VAL + _Q_LOCKED_VAL, &lock->val);
  175. }
  176. /**
  177. * xchg_tail - Put in the new queue tail code word & retrieve previous one
  178. * @lock : Pointer to queued spinlock structure
  179. * @tail : The new queue tail code word
  180. * Return: The previous queue tail code word
  181. *
  182. * xchg(lock, tail)
  183. *
  184. * p,*,* -> n,*,* ; prev = xchg(lock, node)
  185. */
  186. static __always_inline u32 xchg_tail(struct qspinlock *lock, u32 tail)
  187. {
  188. u32 old, new, val = atomic_read(&lock->val);
  189. for (;;) {
  190. new = (val & _Q_LOCKED_PENDING_MASK) | tail;
  191. /*
  192. * Use release semantics to make sure that the MCS node is
  193. * properly initialized before changing the tail code.
  194. */
  195. old = atomic_cmpxchg_release(&lock->val, val, new);
  196. if (old == val)
  197. break;
  198. val = old;
  199. }
  200. return old;
  201. }
  202. #endif /* _Q_PENDING_BITS == 8 */
  203. /**
  204. * queued_fetch_set_pending_acquire - fetch the whole lock value and set pending
  205. * @lock : Pointer to queued spinlock structure
  206. * Return: The previous lock value
  207. *
  208. * *,*,* -> *,1,*
  209. */
  210. #ifndef queued_fetch_set_pending_acquire
  211. static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
  212. {
  213. return atomic_fetch_or_acquire(_Q_PENDING_VAL, &lock->val);
  214. }
  215. #endif
  216. /**
  217. * set_locked - Set the lock bit and own the lock
  218. * @lock: Pointer to queued spinlock structure
  219. *
  220. * *,*,0 -> *,0,1
  221. */
  222. static __always_inline void set_locked(struct qspinlock *lock)
  223. {
  224. WRITE_ONCE(lock->locked, _Q_LOCKED_VAL);
  225. }
  226. /*
  227. * Generate the native code for queued_spin_unlock_slowpath(); provide NOPs for
  228. * all the PV callbacks.
  229. */
  230. static __always_inline void __pv_init_node(struct mcs_spinlock *node) { }
  231. static __always_inline void __pv_wait_node(struct mcs_spinlock *node,
  232. struct mcs_spinlock *prev) { }
  233. static __always_inline void __pv_kick_node(struct qspinlock *lock,
  234. struct mcs_spinlock *node) { }
  235. static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock,
  236. struct mcs_spinlock *node)
  237. { return 0; }
  238. #define pv_enabled() false
  239. #define pv_init_node __pv_init_node
  240. #define pv_wait_node __pv_wait_node
  241. #define pv_kick_node __pv_kick_node
  242. #define pv_wait_head_or_lock __pv_wait_head_or_lock
  243. #ifdef CONFIG_PARAVIRT_SPINLOCKS
  244. #define queued_spin_lock_slowpath native_queued_spin_lock_slowpath
  245. #endif
  246. /*
  247. * Various notes on spin_is_locked() and spin_unlock_wait(), which are
  248. * 'interesting' functions:
  249. *
  250. * PROBLEM: some architectures have an interesting issue with atomic ACQUIRE
  251. * operations in that the ACQUIRE applies to the LOAD _not_ the STORE (ARM64,
  252. * PPC). Also qspinlock has a similar issue per construction, the setting of
  253. * the locked byte can be unordered acquiring the lock proper.
  254. *
  255. * This gets to be 'interesting' in the following cases, where the /should/s
  256. * end up false because of this issue.
  257. *
  258. *
  259. * CASE 1:
  260. *
  261. * So the spin_is_locked() correctness issue comes from something like:
  262. *
  263. * CPU0 CPU1
  264. *
  265. * global_lock(); local_lock(i)
  266. * spin_lock(&G) spin_lock(&L[i])
  267. * for (i) if (!spin_is_locked(&G)) {
  268. * spin_unlock_wait(&L[i]); smp_acquire__after_ctrl_dep();
  269. * return;
  270. * }
  271. * // deal with fail
  272. *
  273. * Where it is important CPU1 sees G locked or CPU0 sees L[i] locked such
  274. * that there is exclusion between the two critical sections.
  275. *
  276. * The load from spin_is_locked(&G) /should/ be constrained by the ACQUIRE from
  277. * spin_lock(&L[i]), and similarly the load(s) from spin_unlock_wait(&L[i])
  278. * /should/ be constrained by the ACQUIRE from spin_lock(&G).
  279. *
  280. * Similarly, later stuff is constrained by the ACQUIRE from CTRL+RMB.
  281. *
  282. *
  283. * CASE 2:
  284. *
  285. * For spin_unlock_wait() there is a second correctness issue, namely:
  286. *
  287. * CPU0 CPU1
  288. *
  289. * flag = set;
  290. * smp_mb(); spin_lock(&l)
  291. * spin_unlock_wait(&l); if (!flag)
  292. * // add to lockless list
  293. * spin_unlock(&l);
  294. * // iterate lockless list
  295. *
  296. * Which wants to ensure that CPU1 will stop adding bits to the list and CPU0
  297. * will observe the last entry on the list (if spin_unlock_wait() had ACQUIRE
  298. * semantics etc..)
  299. *
  300. * Where flag /should/ be ordered against the locked store of l.
  301. */
  302. /*
  303. * queued_spin_lock_slowpath() can (load-)ACQUIRE the lock before
  304. * issuing an _unordered_ store to set _Q_LOCKED_VAL.
  305. *
  306. * This means that the store can be delayed, but no later than the
  307. * store-release from the unlock. This means that simply observing
  308. * _Q_LOCKED_VAL is not sufficient to determine if the lock is acquired.
  309. *
  310. * There are two paths that can issue the unordered store:
  311. *
  312. * (1) clear_pending_set_locked(): *,1,0 -> *,0,1
  313. *
  314. * (2) set_locked(): t,0,0 -> t,0,1 ; t != 0
  315. * atomic_cmpxchg_relaxed(): t,0,0 -> 0,0,1
  316. *
  317. * However, in both cases we have other !0 state we've set before to queue
  318. * ourseves:
  319. *
  320. * For (1) we have the atomic_cmpxchg_acquire() that set _Q_PENDING_VAL, our
  321. * load is constrained by that ACQUIRE to not pass before that, and thus must
  322. * observe the store.
  323. *
  324. * For (2) we have a more intersting scenario. We enqueue ourselves using
  325. * xchg_tail(), which ends up being a RELEASE. This in itself is not
  326. * sufficient, however that is followed by an smp_cond_acquire() on the same
  327. * word, giving a RELEASE->ACQUIRE ordering. This again constrains our load and
  328. * guarantees we must observe that store.
  329. *
  330. * Therefore both cases have other !0 state that is observable before the
  331. * unordered locked byte store comes through. This means we can use that to
  332. * wait for the lock store, and then wait for an unlock.
  333. */
  334. #ifndef queued_spin_unlock_wait
  335. void queued_spin_unlock_wait(struct qspinlock *lock)
  336. {
  337. u32 val;
  338. for (;;) {
  339. val = atomic_read(&lock->val);
  340. if (!val) /* not locked, we're done */
  341. goto done;
  342. if (val & _Q_LOCKED_MASK) /* locked, go wait for unlock */
  343. break;
  344. /* not locked, but pending, wait until we observe the lock */
  345. cpu_relax();
  346. }
  347. /* any unlock is good */
  348. while (atomic_read(&lock->val) & _Q_LOCKED_MASK)
  349. cpu_relax();
  350. done:
  351. smp_acquire__after_ctrl_dep();
  352. }
  353. EXPORT_SYMBOL(queued_spin_unlock_wait);
  354. #endif
  355. #endif /* _GEN_PV_LOCK_SLOWPATH */
  356. /**
  357. * queued_spin_lock_slowpath - acquire the queued spinlock
  358. * @lock: Pointer to queued spinlock structure
  359. * @val: Current value of the queued spinlock 32-bit word
  360. *
  361. * (queue tail, pending bit, lock value)
  362. *
  363. * fast : slow : unlock
  364. * : :
  365. * uncontended (0,0,0) -:--> (0,0,1) ------------------------------:--> (*,*,0)
  366. * : | ^--------.------. / :
  367. * : v \ \ | :
  368. * pending : (0,1,1) +--> (0,1,0) \ | :
  369. * : | ^--' | | :
  370. * : v | | :
  371. * uncontended : (n,x,y) +--> (n,0,0) --' | :
  372. * queue : | ^--' | :
  373. * : v | :
  374. * contended : (*,x,y) +--> (*,0,0) ---> (*,0,1) -' :
  375. * queue : ^--' :
  376. */
  377. void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
  378. {
  379. struct mcs_spinlock *prev, *next, *node;
  380. u32 old, tail;
  381. int idx;
  382. BUILD_BUG_ON(CONFIG_NR_CPUS >= (1U << _Q_TAIL_CPU_BITS));
  383. if (pv_enabled())
  384. goto queue;
  385. if (virt_spin_lock(lock))
  386. return;
  387. /*
  388. * Wait for in-progress pending->locked hand-overs with a bounded
  389. * number of spins so that we guarantee forward progress.
  390. *
  391. * 0,1,0 -> 0,0,1
  392. */
  393. if (val == _Q_PENDING_VAL) {
  394. int cnt = _Q_PENDING_LOOPS;
  395. val = smp_cond_load_acquire(&lock->val.counter,
  396. (VAL != _Q_PENDING_VAL) || !cnt--);
  397. }
  398. /*
  399. * If we observe any contention; queue.
  400. */
  401. if (val & ~_Q_LOCKED_MASK)
  402. goto queue;
  403. /*
  404. * trylock || pending
  405. *
  406. * 0,0,0 -> 0,0,1 ; trylock
  407. * 0,0,1 -> 0,1,1 ; pending
  408. */
  409. val = queued_fetch_set_pending_acquire(lock);
  410. /*
  411. * If we observe any contention; undo and queue.
  412. */
  413. if (unlikely(val & ~_Q_LOCKED_MASK)) {
  414. if (!(val & _Q_PENDING_MASK))
  415. clear_pending(lock);
  416. goto queue;
  417. }
  418. /*
  419. * We're pending, wait for the owner to go away.
  420. *
  421. * 0,1,1 -> 0,1,0
  422. *
  423. * this wait loop must be a load-acquire such that we match the
  424. * store-release that clears the locked bit and create lock
  425. * sequentiality; this is because not all
  426. * clear_pending_set_locked() implementations imply full
  427. * barriers.
  428. */
  429. if (val & _Q_LOCKED_MASK)
  430. smp_cond_load_acquire(&lock->val.counter, !(VAL & _Q_LOCKED_MASK));
  431. /*
  432. * take ownership and clear the pending bit.
  433. *
  434. * 0,1,0 -> 0,0,1
  435. */
  436. clear_pending_set_locked(lock);
  437. return;
  438. /*
  439. * End of pending bit optimistic spinning and beginning of MCS
  440. * queuing.
  441. */
  442. queue:
  443. node = this_cpu_ptr(&mcs_nodes[0]);
  444. idx = node->count++;
  445. tail = encode_tail(smp_processor_id(), idx);
  446. node += idx;
  447. /*
  448. * Ensure that we increment the head node->count before initialising
  449. * the actual node. If the compiler is kind enough to reorder these
  450. * stores, then an IRQ could overwrite our assignments.
  451. */
  452. barrier();
  453. node->locked = 0;
  454. node->next = NULL;
  455. pv_init_node(node);
  456. /*
  457. * We touched a (possibly) cold cacheline in the per-cpu queue node;
  458. * attempt the trylock once more in the hope someone let go while we
  459. * weren't watching.
  460. */
  461. if (queued_spin_trylock(lock))
  462. goto release;
  463. /*
  464. * We have already touched the queueing cacheline; don't bother with
  465. * pending stuff.
  466. *
  467. * p,*,* -> n,*,*
  468. *
  469. * RELEASE, such that the stores to @node must be complete.
  470. */
  471. old = xchg_tail(lock, tail);
  472. next = NULL;
  473. /*
  474. * if there was a previous node; link it and wait until reaching the
  475. * head of the waitqueue.
  476. */
  477. if (old & _Q_TAIL_MASK) {
  478. prev = decode_tail(old);
  479. /*
  480. * We must ensure that the stores to @node are observed before
  481. * the write to prev->next. The address dependency from
  482. * xchg_tail is not sufficient to ensure this because the read
  483. * component of xchg_tail is unordered with respect to the
  484. * initialisation of @node.
  485. */
  486. smp_store_release(&prev->next, node);
  487. pv_wait_node(node, prev);
  488. arch_mcs_spin_lock_contended(&node->locked);
  489. /*
  490. * While waiting for the MCS lock, the next pointer may have
  491. * been set by another lock waiter. We optimistically load
  492. * the next pointer & prefetch the cacheline for writing
  493. * to reduce latency in the upcoming MCS unlock operation.
  494. */
  495. next = READ_ONCE(node->next);
  496. if (next)
  497. prefetchw(next);
  498. }
  499. /*
  500. * we're at the head of the waitqueue, wait for the owner & pending to
  501. * go away.
  502. *
  503. * *,x,y -> *,0,0
  504. *
  505. * this wait loop must use a load-acquire such that we match the
  506. * store-release that clears the locked bit and create lock
  507. * sequentiality; this is because the set_locked() function below
  508. * does not imply a full barrier.
  509. *
  510. * The PV pv_wait_head_or_lock function, if active, will acquire
  511. * the lock and return a non-zero value. So we have to skip the
  512. * smp_cond_load_acquire() call. As the next PV queue head hasn't been
  513. * designated yet, there is no way for the locked value to become
  514. * _Q_SLOW_VAL. So both the set_locked() and the
  515. * atomic_cmpxchg_relaxed() calls will be safe.
  516. *
  517. * If PV isn't active, 0 will be returned instead.
  518. *
  519. */
  520. if ((val = pv_wait_head_or_lock(lock, node)))
  521. goto locked;
  522. val = smp_cond_load_acquire(&lock->val.counter, !(VAL & _Q_LOCKED_PENDING_MASK));
  523. locked:
  524. /*
  525. * claim the lock:
  526. *
  527. * n,0,0 -> 0,0,1 : lock, uncontended
  528. * *,*,0 -> *,*,1 : lock, contended
  529. *
  530. * If the queue head is the only one in the queue (lock value == tail)
  531. * and nobody is pending, clear the tail code and grab the lock.
  532. * Otherwise, we only need to grab the lock.
  533. */
  534. /* In the PV case we might already have _Q_LOCKED_VAL set */
  535. if ((val & _Q_TAIL_MASK) == tail) {
  536. /*
  537. * The smp_cond_load_acquire() call above has provided the
  538. * necessary acquire semantics required for locking.
  539. */
  540. old = atomic_cmpxchg_relaxed(&lock->val, val, _Q_LOCKED_VAL);
  541. if (old == val)
  542. goto release; /* No contention */
  543. }
  544. /* Either somebody is queued behind us or _Q_PENDING_VAL is set */
  545. set_locked(lock);
  546. /*
  547. * contended path; wait for next if not observed yet, release.
  548. */
  549. if (!next) {
  550. while (!(next = READ_ONCE(node->next)))
  551. cpu_relax();
  552. }
  553. arch_mcs_spin_unlock_contended(&next->locked);
  554. pv_kick_node(lock, next);
  555. release:
  556. /*
  557. * release the node
  558. */
  559. __this_cpu_dec(mcs_nodes[0].count);
  560. }
  561. EXPORT_SYMBOL(queued_spin_lock_slowpath);
  562. /*
  563. * Generate the paravirt code for queued_spin_unlock_slowpath().
  564. */
  565. #if !defined(_GEN_PV_LOCK_SLOWPATH) && defined(CONFIG_PARAVIRT_SPINLOCKS)
  566. #define _GEN_PV_LOCK_SLOWPATH
  567. #undef pv_enabled
  568. #define pv_enabled() true
  569. #undef pv_init_node
  570. #undef pv_wait_node
  571. #undef pv_kick_node
  572. #undef pv_wait_head_or_lock
  573. #undef queued_spin_lock_slowpath
  574. #define queued_spin_lock_slowpath __pv_queued_spin_lock_slowpath
  575. #include "qspinlock_paravirt.h"
  576. #include "qspinlock.c"
  577. #endif