dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: "Janusz Krzysztofik" <janusz.krzysztofik@linux.intel.com>,
	dri-devel@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>
Cc: Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Chris Wilson <chris.p.wilson@linux.intel.com>
Subject: Re: [PATCH] drm/vgem-fence: Fix potential deadlock on release
Date: Mon, 6 Oct 2025 16:21:11 +0200	[thread overview]
Message-ID: <cf6e96ae-746c-43c6-a761-a3304745cf0c@linux.intel.com> (raw)
In-Reply-To: <4655664.8F6SAcFxjW@jkrzyszt-mobl2.ger.corp.intel.com>

Hey,

Den 2025-09-29 kl. 14:42, skrev Janusz Krzysztofik:
> Hi Christian,
> 
> Thank you for looking at it and providing your R-b.
> 
> On Sunday, 28 September 2025 16:00:57 CEST Christian König wrote:
>> On 26.09.25 17:26, Janusz Krzysztofik wrote:
>>> A timer that expires a vgem fence automatically in 10 seconds is now
>>> released with timer_delete_sync() from fence->ops.release() called on last
>>> dma_fence_put().  In some scenarios, it can run in IRQ context, which is
>>> not safe unless TIMER_IRQSAFE is used.  One potentially risky scenario was
>>> demonstrated in Intel DRM CI trybot, BAT run on machine bat-adlp-6, while
>>> working on new IGT subtests syncobj_timeline@stress-* as user space
>>> replacements of some problematic test cases of a dma-fence-chain selftest
> ...
>>> Make the timer IRQ safe.
>>>
>>> [1] https://patchwork.freedesktop.org/series/154987/#rev2
>>>
>>> Fixes: 4077798484459 ("drm/vgem: Attach sw fences to exported vGEM dma-buf (ioctl)")
>>> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
>>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>
>> We should also consider to lower the timeout massively. This needs to be in the range of 100m-1s to not cause the same trouble as the sw_sync framework.
> 
> Assuming you are referring to potential hard lockups observed in sw_sync based 
> version of the exercise, which piece of kernel code you would expect to loop 
> for too long with interrupts disabled due to the vgem fences auto expiry 
> timeout of 10s?
> 
>>
>> 10seconds is just way to long for that.
> 
> Do you think DRM objects can't be busy for that long in real life?  What about 
> long running GPU compute tasks?
> 
> Thanks,
> Janusz
> 
> 
>>
>> Regards,
>> Christian.
>>
>>> ---
>>>  drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/vgem/vgem_fence.c b/drivers/gpu/drm/vgem/vgem_fence.c
>>> index fd76730fd38c0..07db319c3d7f9 100644
>>> --- a/drivers/gpu/drm/vgem/vgem_fence.c
>>> +++ b/drivers/gpu/drm/vgem/vgem_fence.c
>>> @@ -79,7 +79,7 @@ static struct dma_fence *vgem_fence_create(struct vgem_file *vfile,
>>>  	dma_fence_init(&fence->base, &vgem_fence_ops, &fence->lock,
>>>  		       dma_fence_context_alloc(1), 1);
>>>  
>>> -	timer_setup(&fence->timer, vgem_fence_timeout, 0);
>>> +	timer_setup(&fence->timer, vgem_fence_timeout, TIMER_IRQSAFE);
>>>  
>>>  	/* We force the fence to expire within 10s to prevent driver hangs */
>>>  	mod_timer(&fence->timer, jiffies + VGEM_FENCE_TIMEOUT);
>>
>>
> 
> 
> 
> 
Pushed the ptach, thanks.

I'm imagining it's mostly because of potential chaining of multiple fences, which can worsen the worst-case timeout easily.

Kind regards,
~Maarten

      reply	other threads:[~2025-10-06 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26 15:26 [PATCH] drm/vgem-fence: Fix potential deadlock on release Janusz Krzysztofik
2025-09-28 14:00 ` Christian König
2025-09-29 12:42   ` Janusz Krzysztofik
2025-10-06 14:21     ` Maarten Lankhorst [this message]

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=cf6e96ae-746c-43c6-a761-a3304745cf0c@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=chris.p.wilson@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=janusz.krzysztofik@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.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