From: Jason Low <jason.low2@hp.com>
To: Waiman Long <waiman.long@hpe.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Ding Tianhong <dingtianhong@huawei.com>,
Jason Low <jason.low2@hpe.com>,
Davidlohr Bueso <dave@stgolabs.net>,
"Paul E. McKenney" <paulmck@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <Will.Deacon@arm.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Waiman Long <Waiman.Long@hp.com>,
jason.low2@hp.com
Subject: Re: [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin()
Date: Mon, 15 Feb 2016 19:00:54 -0800 [thread overview]
Message-ID: <1455591654.2276.64.camel@j-VirtualBox> (raw)
In-Reply-To: <56C2655C.9030707@hpe.com>
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.
next prev parent reply other threads:[~2016-02-16 3:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-12 17:32 [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Waiman Long
2016-02-12 17:32 ` [PATCH v2 1/4] locking/mutex: Add waiter parameter to mutex_optimistic_spin() Waiman Long
2016-02-12 20:23 ` Peter Zijlstra
2016-02-12 22:14 ` Davidlohr Bueso
2016-02-13 12:10 ` Peter Zijlstra
2016-02-13 18:14 ` Davidlohr Bueso
2016-02-16 2:15 ` Jason Low
2016-02-16 2:22 ` Jason Low
2016-02-16 8:53 ` Peter Zijlstra
2016-02-17 1:40 ` Waiman Long
2016-02-15 22:06 ` Waiman Long
2016-02-12 20:40 ` Peter Zijlstra
2016-02-15 23:55 ` Waiman Long
2016-02-16 3:00 ` Jason Low [this message]
2016-02-16 3:30 ` Waiman Long
2016-02-12 22:02 ` Davidlohr Bueso
2016-02-12 22:09 ` Davidlohr Bueso
2016-02-16 0:03 ` Waiman Long
2016-02-12 17:32 ` [PATCH v2 2/4] locking/mutex: Enable optimistic spinning of woken task in wait queue Waiman Long
2016-02-12 17:32 ` [PATCH v2 3/4] locking/mutex: Avoid missed wakeup of mutex waiter Waiman Long
2016-02-12 17:32 ` [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Waiman Long
2016-02-12 20:18 ` Peter Zijlstra
2016-02-12 21:22 ` Waiman Long
2016-02-13 12:09 ` Peter Zijlstra
2016-02-16 8:51 ` [PATCH v2 0/4] locking/mutex: Enable optimistic spinning of lock waiter Peter Zijlstra
2016-02-17 1:39 ` Waiman Long
2016-03-22 3:19 ` Waiman Long
2016-03-22 9:59 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455591654.2276.64.camel@j-VirtualBox \
--to=jason.low2@hp.com \
--cc=Waiman.Long@hp.com \
--cc=Will.Deacon@arm.com \
--cc=dave@stgolabs.net \
--cc=dingtianhong@huawei.com \
--cc=jason.low2@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@us.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=waiman.long@hpe.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.