From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Ingo Molnar <mingo@redhat.com>, Jonathan Corbet <corbet@lwn.net>,
Gustavo Padovan <gustavo@padovan.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Sean Paul <seanpaul@chromium.org>,
David Airlie <airlied@linux.ie>,
Davidlohr Bueso <dave@stgolabs.net>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Josh Triplett <josh@joshtriplett.org>,
Thomas Gleixner <tglx@linutronix.de>,
Kate Stewart <kstewart@linuxfoundation.org>,
Philippe Ombredanne <pombredanne@nexb.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-doc@vger.kernel.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, stern@rowland.harvard.edu
Subject: Re: [PATCH v3 2/2] locking: Implement an algorithm choice for Wound-Wait mutexes
Date: Fri, 15 Jun 2018 18:46:04 +0200 [thread overview]
Message-ID: <20180615164604.GD2458@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180615120827.3989-2-thellstrom@vmware.com>
On Fri, Jun 15, 2018 at 02:08:27PM +0200, Thomas Hellstrom wrote:
> @@ -772,6 +856,25 @@ __ww_mutex_add_waiter(struct mutex_waiter *waiter,
> }
>
> list_add_tail(&waiter->list, pos);
> + if (__mutex_waiter_is_first(lock, waiter))
> + __mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
> +
> + /*
> + * Wound-Wait: if we're blocking on a mutex owned by a younger context,
> + * wound that such that we might proceed.
> + */
> + if (!is_wait_die) {
> + struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
> +
> + /*
> + * See ww_mutex_set_context_fastpath(). Orders setting
> + * MUTEX_FLAG_WAITERS (atomic operation) vs the ww->ctx load,
> + * such that either we or the fastpath will wound @ww->ctx.
> + */
> + smp_mb__after_atomic();
> +
> + __ww_mutex_wound(lock, ww_ctx, ww->ctx);
> + }
I think we want the smp_mb__after_atomic() in the same branch as
__mutex_set_flag(). So something like:
if (__mutex_waiter_is_first()) {
__mutex_set_flag();
if (!is_wait_die)
smp_mb__after_atomic();
}
Or possibly even without the !is_wait_die. The rules for
smp_mb__*_atomic() are such that we want it unconditional after an
atomic, otherwise the semantics get too fuzzy.
Alan (rightfully) complained about that a while ago when he was auditing
users.
next prev parent reply other threads:[~2018-06-15 16:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 12:08 [PATCH 1/2] locking: WW mutex cleanup Thomas Hellstrom
2018-06-15 12:08 ` [PATCH v3 2/2] locking: Implement an algorithm choice for Wound-Wait mutexes Thomas Hellstrom
2018-06-15 16:46 ` Peter Zijlstra [this message]
2018-06-18 11:35 ` Thomas Hellstrom
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=20180615164604.GD2458@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=airlied@linux.ie \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@padovan.org \
--cc=josh@joshtriplett.org \
--cc=kstewart@linuxfoundation.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pombredanne@nexb.com \
--cc=seanpaul@chromium.org \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=thellstrom@vmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox