diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index 7868418ea58683d320eae318ab0dd029334ca47c..365b2033f55eda18e73654f95e2310e7fcef8f89 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c @@ -407,6 +407,16 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) pv_wait_node(node); arch_mcs_spin_lock_contended(&node->locked); + + /* + * While waiting for the MCS lock, the next pointer may have + * been set by another lock waiter. We optimistically load + * the next pointer & prefetch the cacheline for writing + * to reduce latency in the upcoming MCS unlock operation. + */ + next = READ_ONCE(node->next); + if (next) + prefetchw(next); } /*