From: Jason Low <jason.low2@hpe.com>
To: Waiman Long <Waiman.Long@hpe.com>
Cc: jason.low2@hpe.com, 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>,
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>,
Imre Deak <imre.deak@intel.com>,
jason.low2@hp.com
Subject: Re: [PATCH-queue/locking/core] locking/mutex: Unify yield_to_waiter & waiter_spinning
Date: Thu, 18 Aug 2016 18:28:49 -0700 [thread overview]
Message-ID: <1471570129.4991.48.camel@j-VirtualBox> (raw)
In-Reply-To: <1471569328-41611-1-git-send-email-Waiman.Long@hpe.com>
On Thu, 2016-08-18 at 21:15 -0400, Waiman Long wrote:
> Both waiter_spinning and yield_to_waiter are used for somewhat similar
> purpose. The waiter_spinning flag is used in CONFIG_MUTEX_SPIN_ON_OWNER
> to make optimistic spinner yield to spinning waiter; whereas the
> yield_to_waiter is used in !CONFIG_MUTEX_SPIN_ON_OWNER to make new
> incoming mutex locker to yield to the sleeping waiter.
>
> This patch unifies these 2 flags into a single yield_to_waiter
> flag that is used in both CONFIG_MUTEX_SPIN_ON_OWNER and
> !CONFIG_MUTEX_SPIN_ON_OWNER codes.
>
> Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
> ---
> include/linux/mutex.h | 8 ++++++--
> kernel/locking/mutex.c | 12 ++++++------
> 2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/mutex.h b/include/linux/mutex.h
> index 988c020..2b3dcdb 100644
> --- a/include/linux/mutex.h
> +++ b/include/linux/mutex.h
> @@ -57,8 +57,12 @@ struct mutex {
> #endif
> #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
> struct optimistic_spin_queue osq; /* Spinner MCS lock */
> - int waiter_spinning;
> -#elif defined(CONFIG_SMP)
> +#endif
> +#ifdef CONFIG_SMP
> + /*
> + * Used by both CONFIG_MUTEX_SPIN_ON_OWNER (depends on CONFIG_SMP) &
> + * !CONFIG_MUTEX_SPIN_ON_OWNER codes.
> + */
> int yield_to_waiter;
> #endif
> #ifdef CONFIG_DEBUG_MUTEXES
> diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
> index c4261fa..7218835 100644
> --- a/kernel/locking/mutex.c
> +++ b/kernel/locking/mutex.c
> @@ -55,8 +55,8 @@ __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key)
> mutex_clear_owner(lock);
> #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
> osq_lock_init(&lock->osq);
> - lock->waiter_spinning = false;
> -#elif defined(CONFIG_SMP)
> +#endif
> +#ifdef CONFIG_SMP
> lock->yield_to_waiter = false;
> #endif
>
> @@ -351,7 +351,7 @@ static bool mutex_optimistic_spin(struct mutex *lock,
> * Turn on the waiter spinning flag to discourage the spinner
> * from getting the lock.
Might want to update this comment to "Turn on the yield to waiter flag
to discourage optimistic spinners from stealing the lock."
Besides that:
Acked-by: Jason Low <jason.low2@hpe.com>
next prev parent reply other threads:[~2016-08-19 1:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 1:15 [PATCH-queue/locking/core] locking/mutex: Unify yield_to_waiter & waiter_spinning Waiman Long
2016-08-19 1:28 ` Jason Low [this message]
2016-08-19 15:25 ` Waiman Long
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=1471570129.4991.48.camel@j-VirtualBox \
--to=jason.low2@hpe.com \
--cc=Waiman.Long@hpe.com \
--cc=Will.Deacon@arm.com \
--cc=dave@stgolabs.net \
--cc=dingtianhong@huawei.com \
--cc=imre.deak@intel.com \
--cc=jason.low2@hp.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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox