From: Thomas Hellstrom <thellstrom@vmware.com>
To: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.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
Subject: Re: [PATCH v2 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes
Date: Thu, 14 Jun 2018 14:08:54 +0200 [thread overview]
Message-ID: <9c2bdfa1-745a-e618-5429-4305a095847f@vmware.com> (raw)
In-Reply-To: <20180614114944.GA18651@andrea>
Resending hopefully better formatted..
On 06/14/2018 01:49 PM, Andrea Parri wrote:
> [...]
>
>>>> + /*
>>>> + * wake_up_process() paired with set_current_state() inserts
>>>> + * sufficient barriers to make sure @owner either sees it's
>>>> + * wounded or has a wakeup pending to re-read the wounded
>>>> + * state.
>>> IIUC, "sufficient barriers" = full memory barriers (here). (You may
>>> want to be more specific.)
>> Thanks for reviewing!
>> OK. What about if someone relaxes that in the future?
> This is actually one of my main concerns ;-) as, IIUC, those barriers are
> not only sufficient but also necessary: anything "less than a full barrier"
> (in either wake_up_process() or set_current_state()) would _not_ guarantee
> the "condition" above unless I'm misunderstanding it.
>
> But am I misunderstanding it? Which barriers/guarantee do you _need_ from
> the above mentioned pairing? (hence my comment...)
>
> Andrea
No you are probably not misunderstanding me at all. My comment
originated from the reading of the kerneldoc of set_current_state()
/*
* set_current_state() includes a barrier so that the write of current->state
* is correctly serialised wrt the caller's subsequent test of whether to
* actually sleep:
*
* for (;;) {
* set_current_state(TASK_UNINTERRUPTIBLE);
* if (!need_sleep)
* break;
*
* schedule();
* }
* __set_current_state(TASK_RUNNING);
*
* If the caller does not need such serialisation (because, for instance, the
* condition test and condition change and wakeup are under the same
lock) then
* use __set_current_state().
*
* The above is typically ordered against the wakeup, which does:
*
* need_sleep = false;
* wake_up_state(p, TASK_UNINTERRUPTIBLE);
*
* Where wake_up_state() (and all other wakeup primitives) imply enough
* barriers to order the store of the variable against wakeup.
---
*/
And with ctx->wounded := !need_sleep this exactly matches what's
happening in my code. So what I was trying to say in the comment was
that this above contract is sufficient to guarantee the "condition"
above, whitout me actually knowing exactly what barriers are required.
Thanks, Thomas
next prev parent reply other threads:[~2018-06-14 12:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-14 7:29 [PATCH v2 0/2] locking,drm: Fix ww mutex naming / algorithm inconsistency Thomas Hellstrom
2018-06-14 7:29 ` [PATCH v2 1/2] locking: Implement an algorithm choice for Wound-Wait mutexes Thomas Hellstrom
2018-06-14 10:38 ` Andrea Parri
2018-06-14 11:10 ` Thomas Hellstrom
2018-06-14 11:49 ` Andrea Parri
2018-06-14 12:04 ` Thomas Hellstrom
2018-06-14 12:08 ` Thomas Hellstrom [this message]
2018-06-14 11:36 ` Peter Zijlstra
2018-06-14 11:54 ` Thomas Hellstrom
2018-06-14 13:29 ` Matthew Wilcox
2018-06-14 13:43 ` Thomas Hellstrom
2018-06-14 14:46 ` Peter Zijlstra
2018-06-14 12:41 ` Peter Zijlstra
2018-06-14 12:48 ` Thomas Hellstrom
2018-06-14 13:18 ` Thomas Hellstrom
2018-06-14 7:29 ` [PATCH v2 2/2] drm: Change deadlock-avoidance algorithm for the modeset locks 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=9c2bdfa1-745a-e618-5429-4305a095847f@vmware.com \
--to=thellstrom@vmware.com \
--cc=airlied@linux.ie \
--cc=andrea.parri@amarulasolutions.com \
--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=peterz@infradead.org \
--cc=pombredanne@nexb.com \
--cc=seanpaul@chromium.org \
--cc=tglx@linutronix.de \
/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