lkml.org 
[lkml]   [2016]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 1/3] locking/mutex: Add waiter parameter to mutex_optimistic_spin()
On Mon, Jul 18, 2016 at 04:39:24PM -0400, Waiman Long wrote:
> @@ -302,22 +306,42 @@ static inline bool mutex_try_to_acquire(struct mutex *lock)
> *
> * Returns true when the lock was taken, otherwise false, indicating
> * that we need to jump to the slowpath and sleep.
> + *
> + * The waiter flag is set to true if the spinner is a waiter in the wait
> + * queue. As the waiter has slept for a while, it should have priority to
> + * get the lock over the regular spinners. So going to wait at the end of
> + * the OSQ isn't fair to the waiter.

If the OSQ lock were a full FIFO it would in fact be fair, but its not
and things can drop out the middle and go (back) to sleep.

This has nothing to do with the end or not.

> Instead, it will spin on the lock
> + * directly and concurrently with the spinner at the head of the OSQ, if
> + * present.

Note that this isn't starvation proof in any way.

> There may be a bit more cacheline contention in this case.

This is relevant how ?

> + * The waiter also needs to set the lock to -1 instead of 0 on lock
> + * acquisition.

This is unrelated to the previous bits and thus should not be in the
same paragraph. Also, a 'why' would be more helpful.

> */
> static bool mutex_optimistic_spin(struct mutex *lock,
> - struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
> + struct ww_acquire_ctx *ww_ctx,
> + const bool use_ww_ctx, int waiter)
> {

\
 
 \ /
  Last update: 2016-08-08 20:21    [W:0.109 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site