[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cfde5db9-2b05-52df-4f88-1928779db669@amd.com>
Date: Thu, 21 May 2020 15:20:04 +0200
From: Christian König <christian.koenig@....com>
To: "Ahmed S. Darwish" <a.darwish@...utronix.de>,
Christian König <ckoenig.leichtzumerken@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
"David (ChunMing) Zhou" <David1.Zhou@....com>,
amd-gfx@...ts.freedesktop.org,
"Paul E. McKenney" <paulmck@...nel.org>,
David Airlie <airlied@...ux.ie>,
"Sebastian A. Siewior" <bigeasy@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>,
Steven Rostedt <rostedt@...dmis.org>,
dri-devel@...ts.freedesktop.org, Daniel Vetter <daniel@...ll.ch>,
Alex Deucher <alexander.deucher@....com>,
Felix Kuehling <Felix.Kuehling@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Sumit Semwal <sumit.semwal@...aro.org>,
linux-media@...r.kernel.org
Subject: Re: [PATCH v1 13/25] dma-buf: Use sequence counter with associated
wound/wait mutex
Am 21.05.20 um 02:09 schrieb Ahmed S. Darwish:
> 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.
In this case I'm perfectly fine with this.
>
> 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.
Completely agree, just wanted to prevent that we now add a lot of code
which gets removed again ~3 month from now.
Regards,
Christian.
>
>> Regards,
>> Christian.
>>
> Thanks,
>
> --
> Ahmed S. Darwish
> Linutronix GmbH
Powered by blists - more mailing lists