dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: phasta@kernel.org, matthew.brost@intel.com, sumit.semwal@linaro.org
Cc: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH 1/8] dma-buf: protected fence ops by RCU v5
Date: Thu, 19 Feb 2026 11:23:57 +0100	[thread overview]
Message-ID: <53a84ddb-9202-48bb-bcb1-e76ee3097eb7@amd.com> (raw)
In-Reply-To: <9f929535744546bcb4eed26f6c27b4497ebc37bb.camel@mailbox.org>

On 2/12/26 09:56, Philipp Stanner wrote:
>>>> @@ -454,13 +465,19 @@ dma_fence_test_signaled_flag(struct dma_fence *fence)
>>>>  static inline bool
>>>>  dma_fence_is_signaled_locked(struct dma_fence *fence)
>>>>  {
>>>> +	const struct dma_fence_ops *ops;
>>>> +
>>>>  	if (dma_fence_test_signaled_flag(fence))
>>>>  		return true;
>>>>  
>>>> -	if (fence->ops->signaled && fence->ops->signaled(fence)) {
>>>> +	rcu_read_lock();
>>>> +	ops = rcu_dereference(fence->ops);
>>>> +	if (ops->signaled && ops->signaled(fence)) {
>>>
>>> Maybe you can educate me a bit about RCU here – couldn't this still
>>> race? If the ops were unloaded before you take rcu_read_lock(),
>>> rcu_dereference() would give you an invalid pointer here since you
>>> don't check for !ops, no?
>>
>> Perfectly correct thinking, yes.
>>
>> But the check for !ops is added in patch #2 when we actually start to set ops = NULL when the fence signals.
>>
>> I intentionally separated that because it is basically the second step in making the solution to detach the fence ops from the module by RCU work.
>>
>> We could merge the two patches together, but I think the separation actually makes sense should anybody start to complain about the additional RCU overhead.
>>
> 
> Alright, makes sense. However the above does not read correct..
> 
> But then my question would be: What's the purpose of this patch, what
> does it solve or address atomically?

Adding the RCU annotation and related logic, e.g. rcu_read_lock()/rcu_read_unlock()/rcu_dereference() etc...

This allows the automated statically RCU checker to validate what we do here and point out potential mistakes.

Additional to that should adding the rcu_read_lock() protection cause performance problems it will bisect to this patch here alone.

> Adding RCU here does not yet change behavior and it does not solve the
> unloading problem, does it?

Nope, no functional behavior change. It's purely to get the automated checkers going.

> If it's a mere preperational step and the patches should not be merged,
> I'd guard the above with a simple comment like "Cleanup preparation.
> 'ops' can yet not be NULL, but this will be the case subsequently."

A comment added in this patch and removed in the next one? Na, that sounds like overkill to me.

Christian.

> 
> 
> P.
> 


  reply	other threads:[~2026-02-19 10:24 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10 10:01 Independence for dma_fences! v7 Christian König
2026-02-10 10:01 ` [PATCH 1/8] dma-buf: protected fence ops by RCU v5 Christian König
2026-02-11 10:06   ` Philipp Stanner
2026-02-11 15:43     ` Christian König
2026-02-12  8:56       ` Philipp Stanner
2026-02-19 10:23         ` Christian König [this message]
2026-02-19 10:35           ` Philipp Stanner
2026-02-19 12:49             ` Christian König
2026-02-12  9:03       ` Tvrtko Ursulin
2026-02-12  9:31   ` Tvrtko Ursulin
2026-02-13 14:20   ` Boris Brezillon
2026-02-10 10:01 ` [PATCH 2/8] dma-buf: detach fence ops on signal v2 Christian König
2026-02-13 14:22   ` Boris Brezillon
2026-02-19 12:52     ` Christian König
2026-02-19 15:49       ` Boris Brezillon
2026-02-10 10:01 ` [PATCH 3/8] dma-buf: abstract fence locking v2 Christian König
2026-02-12  9:07   ` Tvrtko Ursulin
2026-02-10 10:01 ` [PATCH 4/8] dma-buf: inline spinlock for fence protection v4 Christian König
2026-02-11  9:50   ` Philipp Stanner
2026-02-11 14:59     ` Christian König
2026-02-12  9:01       ` Philipp Stanner
2026-02-12  9:16   ` Tvrtko Ursulin
2026-02-13 14:27   ` Boris Brezillon
2026-02-15  8:48     ` Boris Brezillon
2026-02-16  7:33     ` Philipp Stanner
2026-02-16  9:48       ` Boris Brezillon
2026-02-10 10:02 ` [PATCH 5/8] dma-buf/selftests: test RCU ops and inline lock v2 Christian König
2026-02-10 10:02 ` [PATCH 6/8] dma-buf: use inline lock for the stub fence v2 Christian König
2026-02-13 14:32   ` Boris Brezillon
2026-02-10 10:02 ` [PATCH 7/8] dma-buf: use inline lock for the dma-fence-array Christian König
2026-02-13 14:33   ` Boris Brezillon
2026-02-10 10:02 ` [PATCH 8/8] dma-buf: use inline lock for the dma-fence-chain Christian König
2026-02-13 14:33   ` Boris Brezillon

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=53a84ddb-9202-48bb-bcb1-e76ee3097eb7@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=matthew.brost@intel.com \
    --cc=phasta@kernel.org \
    --cc=sumit.semwal@linaro.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