Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1335994
| From | Waiman Long <waiman.long@hpe.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() |
| Date | 2016-02-17 03:00 +0100 |
| Message-ID | <r2Zzk-7EN-9@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <r1svM-3ox-19@gated-at.bofh.it> <r1ued-4Bn-1@gated-at.bofh.it> <r2Dp9-1gU-45@gated-at.bofh.it> <r2DyN-1ku-3@gated-at.bofh.it> <r2JEe-5wa-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/16/2016 03:53 AM, Peter Zijlstra wrote:
> On Mon, Feb 15, 2016 at 06:22:14PM -0800, Jason Low wrote:
>> On Mon, 2016-02-15 at 18:15 -0800, Jason Low wrote:
>>> On Fri, 2016-02-12 at 14:14 -0800, Davidlohr Bueso wrote:
>>>> On Fri, 12 Feb 2016, Peter Zijlstra wrote:
>>>>
>>>>> On Fri, Feb 12, 2016 at 12:32:12PM -0500, Waiman Long wrote:
>>>>>> 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() ?
>>>> afaict because mutex_can_spin_on_owner() fails immediately when the counter
>>>> is -1, which is a nono for the waiters case.
>>> mutex_can_spin_on_owner() returns false if the task needs to reschedule
>>> or if the lock owner is not on_cpu. In either case, the task will end up
>>> not spinning when it enters the spin loop. So it makes sense if the
>>> waiter also checks mutex_can_spin_on_owner() so that the optimistic spin
>>> queue overhead can be avoided in those cases.
>> Actually, since waiters bypass the optimistic spin queue, that means the
>> the mutex_can_spin_on_owner() isn't really beneficial. So Waiman is
>> right in that it's fine to skip this in the waiter case.
> My concern was the 'pointless' divergence between the code-paths. The
> less they diverge the easier it is to understand and review.
>
> If it doesn't hurt, please keep it the same. If it does need to diverge,
> include a comment on why.
I will keep the preemption, but will still leave out the
mutex_can_spin_on_owner() check for waiter. I will add a comment to
document that.
Cheers,
Longman
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Waiman Long <Waiman.Long@hpe.com> - 2016-02-12 18:40 +0100
[PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <Waiman.Long@hpe.com> - 2016-02-12 18:40 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Peter Zijlstra <peterz@infradead.org> - 2016-02-12 21:30 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Davidlohr Bueso <dave@stgolabs.net> - 2016-02-12 23:20 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Peter Zijlstra <peterz@infradead.org> - 2016-02-13 13:20 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Davidlohr Bueso <dave@stgolabs.net> - 2016-02-13 19:20 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Jason Low <jason.low2@hp.com> - 2016-02-16 03:20 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Jason Low <jason.low2@hp.com> - 2016-02-16 03:30 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Peter Zijlstra <peterz@infradead.org> - 2016-02-16 10:00 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <waiman.long@hpe.com> - 2016-02-17 03:00 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <waiman.long@hpe.com> - 2016-02-15 23:10 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Peter Zijlstra <peterz@infradead.org> - 2016-02-12 21:50 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <waiman.long@hpe.com> - 2016-02-16 02:30 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Jason Low <jason.low2@hp.com> - 2016-02-16 04:10 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <waiman.long@hpe.com> - 2016-02-16 04:40 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Davidlohr Bueso <dave@stgolabs.net> - 2016-02-12 23:10 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Davidlohr Bueso <dave@stgolabs.net> - 2016-02-12 23:10 +0100
Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long <waiman.long@hpe.com> - 2016-02-16 01:10 +0100
[PATCH v2 3/4] locking/mutex: Avoid missed wakeup of mutex waiter Waiman Long <Waiman.Long@hpe.com> - 2016-02-12 18:40 +0100
[PATCH v2 2/4] locking/mutex: Enable optimistic spinning of woken task in wait queue Waiman Long <Waiman.Long@hpe.com> - 2016-02-12 18:40 +0100
Re: [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Peter Zijlstra <peterz@infradead.org> - 2016-02-16 10:00 +0100
Re: [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Waiman Long <waiman.long@hpe.com> - 2016-02-17 03:00 +0100
csiph-web