Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1465513

Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning is enabled
Date 2016-08-18 16:30 +0200
Message-ID <s7wut-WK-21@gated-at.bofh.it> (permalink)
References <s4GJI-j6-57@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Aug 10, 2016 at 11:44:08AM -0700, Jason Low wrote:
> @@ -556,8 +604,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
>  		 * other waiters. We only attempt the xchg if the count is
>  		 * non-negative in order to avoid unnecessary xchg operations:
>  		 */
> -		if (atomic_read(&lock->count) >= 0 &&
> +		if ((!need_yield_to_waiter(lock) || wakeups > 1) &&
> +		    atomic_read(&lock->count) >= 0 &&
>  		    (atomic_xchg_acquire(&lock->count, -1) == 1))
> +			if (wakeups > 1)
> +				clear_yield_to_waiter(lock);
> +
>  			break;
>  
>  		/*

There's some { } gone missing there...

Also, I think I'll change it to avoid that extra wakeups > 1 condition..

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning  is enabled Peter Zijlstra <peterz@infradead.org> - 2016-08-18 16:30 +0200
  Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning  is enabled Peter Zijlstra <peterz@infradead.org> - 2016-08-19 02:50 +0200
    Re: [PATCH v2] locking/mutex: Prevent lock starvation when spinning  is enabled Peter Zijlstra <peterz@infradead.org> - 2016-08-19 02:50 +0200

csiph-web