lkml.org 
[lkml]   [2016]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin()
On Fri, Feb 12, 2016 at 12:32:12PM -0500, Waiman Long wrote:
> This patch adds a new waiter parameter to the mutex_optimistic_spin()
> function to prepare it to be used by a waiter-spinner that doesn't
> need to go into the OSQ as there can only be one waiter-spinner which
> is the head of the waiting queue.

Does not explain why..

> static bool mutex_optimistic_spin(struct mutex *lock,
> + struct ww_acquire_ctx *ww_ctx,
> + const bool use_ww_ctx, int waiter)
> {
> struct task_struct *task = current;
> + bool acquired = false;
>
> + if (!waiter) {
> + if (!mutex_can_spin_on_owner(lock))
> + goto done;

Why doesn't the waiter have to check mutex_can_spin_on_owner() ?

>
> + /*
> + * In order to avoid a stampede of mutex spinners trying to
> + * acquire the mutex all at once, the spinners need to take a
> + * MCS (queued) lock first before spinning on the owner field.
> + */
> + if (!osq_lock(&lock->osq))
> + goto done;
> + }
>
> while (true) {
> struct task_struct *owner;

\
 
 \ /
  Last update: 2016-02-12 21:41    [W:0.447 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site