Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1334984
| 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-16 04:40 +0100 |
| Message-ID | <r2EEx-27L-5@gated-at.bofh.it> (permalink) |
| References | <r1pRg-1EI-13@gated-at.bofh.it> <r1pRg-1EI-11@gated-at.bofh.it> <r1sP7-3ws-3@gated-at.bofh.it> <r2CCJ-GB-1@gated-at.bofh.it> <r2Ebv-1RL-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/15/2016 10:00 PM, Jason Low wrote: > On Mon, 2016-02-15 at 18:55 -0500, Waiman Long wrote: >> On 02/12/2016 03:40 PM, Peter Zijlstra wrote: >>> On Fri, Feb 12, 2016 at 12:32:12PM -0500, Waiman Long wrote: >>>> @@ -358,8 +373,8 @@ static bool mutex_optimistic_spin(struct mutex *lock, >>>> } >>>> >>>> mutex_set_owner(lock); >>>> - osq_unlock(&lock->osq); >>>> - return true; >>>> + acquired = true; >>>> + break; >>>> } >>>> >>>> /* >>>> @@ -380,7 +395,10 @@ static bool mutex_optimistic_spin(struct mutex *lock, >>>> cpu_relax_lowlatency(); >>>> } >>>> >>>> - osq_unlock(&lock->osq); >>>> + if (!waiter) >>>> + osq_unlock(&lock->osq); >>>> + if (acquired || waiter) >>>> + return acquired; >>>> done: >>>> /* >>>> * If we fell out of the spin path because of need_resched(), >>> Is there a reason to not also preempt in the wait-loop? Surely the same >>> reason is still valid there too? >> The waiter does check for need_sched(). So it will break out of the loop >> and return false in this case. This causes the waiter to loop back and >> goes to sleep if the lock can't be acquired. That is why I don't think >> we need to do another schedule_preempt_disabled() here. > The purpose of the additional reschedule point is to avoid delaying > preemption, which still applies if the spinner is a waiter. If it is a > waiter, the difference is that the delay isn't as long since it doesn't > need to be added to the wait_list. Nonetheless, preemption delays can > still occur, so I think the additional preemption point should also be > there in the waiter case. You are right. Taking the wait lock can introduce arbitrary delay. So I will modify the patch to fall through and check for preemption. 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