<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Am 17.12.24 um 12:06 schrieb Wei Lin Guay:<br>
<blockquote type="cite" cite="mid:C369F330-5BAD-4AC6-A13C-EEABD29F2F08@meta.com">[SNIP]<span style="white-space: pre-wrap">
</span>
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""></pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Please send that out once more with me on explicit CC.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
I will resend the patch series. I was experiencing issues with my email client, which inadvertently split the series into two separate emails.</pre>
</blockquote>
<br>
Alternatively I can also copy the code from the list archive and
explain why that doesn't work:<br>
<br>
+void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev, bool
revoked)<br>
+{<br>
+ struct vfio_pci_dma_buf *priv;<br>
+ struct vfio_pci_dma_buf *tmp;<br>
+<br>
+ lockdep_assert_held_write(&vdev->memory_lock);<br>
<br>
This makes sure that the caller is holding vdev->memory_lock.<br>
<br>
+<br>
+ list_for_each_entry_safe(priv, tmp, &vdev->dmabufs,
dmabufs_elm) {<br>
+ if (!dma_buf_try_get(priv->dmabuf))<br>
<br>
This here only works because vfio_pci_dma_buf_release() also grabs
vdev->memory_lock and so we are protected against concurrent
releases.<br>
<br>
+ continue;<br>
+ if (priv->revoked != revoked) {<br>
+ dma_resv_lock(priv->dmabuf->resv, NULL);<br>
+ priv->revoked = revoked;<br>
+ dma_buf_move_notify(priv->dmabuf);<br>
+ dma_resv_unlock(priv->dmabuf->resv);<br>
+ }<br>
+ dma_buf_put(priv->dmabuf);<br>
<br>
The problem is now that this here might drop the last reference
which in turn calls vfio_pci_dma_buf_release() which also tries to
grab vdev->memory_lock and so results in a deadlock.<br>
<br>
+ }<br>
+}<br>
<br>
This pattern was suggested multiple times and I had to rejected it
every time because the whole idea is just fundamentally broken.<br>
<br>
It's really astonishing how people always come up with the same
broken pattern.<br>
<br>
Regards,<br>
Christian.<br>
<br>
<blockquote type="cite" cite="mid:C369F330-5BAD-4AC6-A13C-EEABD29F2F08@meta.com">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
Apart from that I have to reject the adding of dma_buf_try_get(), that is clearly not something we should do.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Understood. It appears that Vivek has confirmed that his v2 has resolved the issue. I will follow up with him to determine if he plans to resume his patch, and if so, I will apply my last patch on top of his updated patch series
Thanks,
Wei Lin
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
Thanks,
Christian.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
<br>
</body>
</html>