From: "Ahmed S. Darwish" <a.darwish@linutronix.de>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"David (ChunMing) Zhou" <David1.Zhou@amd.com>,
amd-gfx@lists.freedesktop.org,
"Paul E. McKenney" <paulmck@kernel.org>,
"David Airlie" <airlied@linux.ie>,
"Sebastian A. Siewior" <bigeasy@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org,
"Daniel Vetter" <daniel@ffwll.ch>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Felix Kuehling" <Felix.Kuehling@amd.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
linux-media@vger.kernel.org
Subject: Re: [PATCH v1 13/25] dma-buf: Use sequence counter with associated wound/wait mutex
Date: Thu, 21 May 2020 02:09:30 +0200 [thread overview]
Message-ID: <20200521000930.GA359643@debian-buster-darwi.lab.linutronix.de> (raw)
In-Reply-To: <e28c251e-5771-598c-37dd-c6be2de4b9e1@gmail.com>
On Wed, May 20, 2020, Christian König wrote:
> Am 19.05.20 um 23:45 schrieb Ahmed S. Darwish:
> > A sequence counter write side critical section must be protected by some
> > form of locking to serialize writers. If the serialization primitive is
> > not disabling preemption implicitly, preemption has to be explicitly
> > disabled before entering the sequence counter write side critical
> > section.
> >
> > The dma-buf reservation subsystem uses plain sequence counters to manage
> > updates to reservations. Writer serialization is accomplished through a
> > wound/wait mutex.
> >
> > Acquiring a wound/wait mutex does not disable preemption, so this needs
> > to be done manually before and after the write side critical section.
> >
> > Use the newly-added seqcount_ww_mutex_t instead:
> >
> > - It associates the ww_mutex with the sequence count, which enables
> > lockdep to validate that the write side critical section is properly
> > serialized.
> >
> > - It removes the need to explicitly add preempt_disable/enable()
> > around the write side critical section because the write_begin/end()
> > functions for this new data type automatically do this.
> >
> > If lockdep is disabled this ww_mutex lock association is compiled out
> > and has neither storage size nor runtime overhead.
>
> Mhm, is the dma_resv object the only user of this new seqcount_ww_mutex
> variant ?
>
> If yes we are trying to get rid of this sequence counter for quite some
> time, so I would rather invest the additional time to finish this.
>
In this patch series, each extra "seqcount with associated lock" data
type costs us, exactly:
- 1 typedef definition, seqcount_ww_mutex_t
- 1 static initializer, SEQCNT_WW_MUTEX_ZERO()
- 1 runtime initializer, seqcount_ww_mutex_init()
Definitions for the typedef and the 2 initializers above are
template-code one liners.
The logic which automatically disables preemption upon entering a
seqcount_ww_mutex_t write side critical section is also already shared
with seqcount_mutex_t and any future, preemptible, associated lock.
So, yes, dma-resv is the only user of seqcount_ww_mutex.
But even in that case, given the one liner template code nature of
seqcount_ww_mutex_t logic, it does not make sense to block the dma_resv
and amdgpu change until at some point in the future the sequence counter
is completely removed.
**If and when** the sequence counter gets removed, please just remove
the seqcount_ww_mutex_t data type with it. It will be extremely simple.
> Regards,
> Christian.
>
Thanks,
--
Ahmed S. Darwish
Linutronix GmbH
next prev parent reply other threads:[~2020-05-21 0:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200519214547.352050-1-a.darwish@linutronix.de>
2020-05-19 21:45 ` [PATCH v1 06/25] dma-buf: Remove custom seqcount lockdep class key Ahmed S. Darwish
2020-05-19 21:45 ` [PATCH v1 13/25] dma-buf: Use sequence counter with associated wound/wait mutex Ahmed S. Darwish
2020-05-20 10:48 ` Christian König
2020-05-21 0:09 ` Ahmed S. Darwish [this message]
2020-05-21 13:20 ` Christian König
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=20200521000930.GA359643@debian-buster-darwi.lab.linutronix.de \
--to=a.darwish@linutronix.de \
--cc=David1.Zhou@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bigeasy@linutronix.de \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sumit.semwal@linaro.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).