All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	amd-gfx@lists.freedesktop.org
Cc: emily.deng@amd.com, xinhui.pan@amd.com
Subject: Re: [RFC PATCH] drm/amdkfd: Run restore_workers on freezable WQs
Date: Mon, 30 Oct 2023 13:56:17 -0400	[thread overview]
Message-ID: <b6f9450c-c12e-4c2b-988a-bbb79c2ce6aa@amd.com> (raw)
In-Reply-To: <2e1e1fd3-ae15-4faa-98a6-a71ba3d8fafe@amd.com>

On 2023-10-30 13:48, Christian König wrote:
>
>
> Am 30.10.23 um 18:38 schrieb Felix Kuehling:
>> On 2023-10-30 12:16, Christian König wrote:
>>>>>> @@ -1904,6 +1906,19 @@ kfd_process_gpuid_from_node(struct 
>>>>>> kfd_process *p, struct kfd_node *node,
>>>>>>       return -EINVAL;
>>>>>>   }
>>>>>>   +static void signal_eviction_fence(struct kfd_process *p)
>>>>>> +{
>>>>>> +    spin_lock(&p->ef_lock);
>>>>>> +    if (!p->ef)
>>>>>> +        goto unlock_out;
>>>>>> +    dma_fence_signal(p->ef);
>>>>>
>>>>> This needs to grab the internal lock of the eviction fence, I'm 
>>>>> not sure that has correct ordering with the newly added ef_lock.
>>>>
>>>> Hmm, the only thing we could get a circular lock dependency would 
>>>> be, if we took the p->ef_lock in a fence callback. I don't think 
>>>> that ever happens, because even the eviction work runs on a worker 
>>>> thread (exactly to avoid such lock dependency issues).
>>>>
>>>> Anyway, I could try to move the fence_signal out of the critical 
>>>> section. The lock is only there to ensure that exactly one process 
>>>> signals and frees the fence.
>>>>
>>>
>>> So basically either the eviction worker or the GPU reset could 
>>> signal this fence.
>>>
>>> In that case I think it would be simpler to grab the reset lock in 
>>> the eviction worker to protect against a concurrent reset.
>>
>> Which reset lock? adev->reset_cntl->reset_lock? I only see that lock 
>> taken in aldebaran_mode2_perform_reset. I don't understand why this 
>> is in ASIC-specific code. But even so, it's only taken during the 
>> actual reset (in aldebaran_mode2_perform_reset). I don't think it 
>> covers the pre-reset code path that signals the eviction fence.
>
> No, what I mean is adev->reset_domain->sem. It's hold in write lock 
> during the reset and you can grab the read side if you need to delay a 
> reset.
>
> But thinking about that a bit more, you actually don't need any of 
> this. Something like this here should do fine:
>
> tmp = dma_fence_get_rcu_safe(&p->ef);
> dma_fence_signal(tmp);
> dma_fence_put(tmp);

dma_fence_get_rcu_safe gets a new reference that dma_fence_put drops. It 
doesn't drop the original reference in p->ef.

I need a way to ensure that exactly one thread frees the original 
reference in p->ef. Even with RCU, concurrent writers still need a lock 
or a mutex. So I don't think I can avoid using another lock here because 
I have potentially two concurrent writers.

Regards,
   Felix


>
> dma_fences are always RCU protected and can be signaled from multiple 
> sources by design.
>
> Regards,
> Christian.
>
>>
>> Regards,
>>   Felix
>>
>>
>>>
>>> Regards,
>>> Christian.
>

  reply	other threads:[~2023-10-30 17:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-27 22:39 [RFC PATCH] drm/amdkfd: Run restore_workers on freezable WQs Felix Kuehling
2023-10-30  8:23 ` Christian König
2023-10-30 15:16   ` Felix Kuehling
2023-10-30 16:16     ` Christian König
2023-10-30 17:38       ` Felix Kuehling
2023-10-30 17:48         ` Christian König
2023-10-30 17:56           ` Felix Kuehling [this message]
2023-10-30 18:00             ` 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=b6f9450c-c12e-4c2b-988a-bbb79c2ce6aa@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=emily.deng@amd.com \
    --cc=xinhui.pan@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.