The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dragos Tatulea <dtatulea@nvidia.com>
To: bobbyeshleman <bobbyeshleman@devvm29614.prn0.facebook.com>,
	j@devvm29614.prn0.facebook.com
Cc: Bobby Eshleman <bobbyeshleman@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	tariqt@nvidia.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: devmem: add netdev_has_dmabuf_binding() helper
Date: Tue, 11 Aug 2026 20:46:08 +0200	[thread overview]
Message-ID: <0ba50bc1-d7ea-4874-9bee-acc8a3f89bd7@nvidia.com> (raw)
In-Reply-To: <anthYJ3RSVWnhVoE@devvm29614.prn0.facebook.com>



On 11.08.26 19:52, bobbyeshleman wrote:
> On Tue, Aug 11, 2026 at 12:44:07PM +0200, Dragos Tatulea wrote:
>>
>> On 11.08.26 09:24, Dragos Tatulea wrote:
>>>
>>>
>>> On 11.08.26 00:17, bobbyeshleman wrote:
>>>> On Mon, Aug 10, 2026 at 08:54:45PM +0300, Dragos Tatulea wrote:> [...]
>>>>> +bool netdev_has_dmabuf_binding(struct net_device *dev, struct device *dma_dev)
>>>>> +{
>>>>> +	struct net_devmem_dmabuf_binding *binding;
>>>>> +	unsigned long id;
>>>>> +	bool found = false;
>>>>> +
>>>>> +	rcu_read_lock();
>>>>> +	xa_for_each(&net_devmem_dmabuf_bindings, id, binding) {
>>>>> +		if (READ_ONCE(binding->dev) == dev &&
>>>>> +		    (!dma_dev || binding->attachment->dev == dma_dev)) {
>>>>> +			found = true;
>>>>> +			break;
>>>>> +		}
>>>>> +	}
>>>>> +	rcu_read_unlock();
>>>>> +
>>>>> +	return found;
>>>>> +}
>>>>> +EXPORT_SYMBOL_GPL(netdev_has_dmabuf_binding);
>>>>> +
>>>>>  void net_devmem_get_net_iov(struct net_iov *niov)
>>>>>  {
>>>>>  	net_devmem_dmabuf_binding_get(net_devmem_iov_binding(niov));
>>>>> -- 
>>>>> 2.54.0
>>>>>
>>>>
>>>> I think netdev_has_dmabuf_binding() can return false even when there
>>>> exists one or more in-flight skbs (e.g., in sk_write_queue) backed by
>>>> the txq binding (won't technically be inactive until the final reference
>>>> is dropped and the binding is freed)? If so, can this still detect when
>>>> it is safe to swap the underlying dma dev?
>>>>
>>> Oh, good point! I didn't realize that the binding is refcounted and can
>>> outlive its xarray slot.
>>>
>> I can only think of adding another list that tracks bindings for their
>> lifetime or between xarray erasure and deletion. Not too happy about it
>> though.
>>
>> There's also the possibility of iterating over dmabufs and their attachment.
>> But this requires a function in dmabuf to scan the dmabufs and attachments
>> under the internal lock similar to dma_buf_debug_show(). But I don't think
>> that will be accepted. So this is even worse.
>>
>> Thanks,
>> Dragos
> 
> I agree, those options aren't great.
> 
> Would it be possible to drop these skbs (based on some comparison with
> binding->attachment->dev) in validate_xmit_unreadable_skb()? Not sure if
> we have enough context at that point in the TX path?
> 
Even if we would, I wouldn't do it...

> tbh I'd lean towards your idea of adding a new lifetime list, if there
> isn't a better way.
>
Ok. Will implement the lifetime list (or xarray) if I can't come up with
something better until then.

Thanks,
Dragos

  parent reply	other threads:[~2026-08-11 18:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 17:54 [PATCH net-next] net: devmem: add netdev_has_dmabuf_binding() helper Dragos Tatulea
2026-08-11  0:25 ` Stanislav Fomichev
2026-08-11 10:47   ` Dragos Tatulea
     [not found] ` <anpN3vJUig93aSB8@devvm29614.prn0.facebook.com>
2026-08-11  7:24   ` Dragos Tatulea
2026-08-11 10:44     ` Dragos Tatulea
     [not found]       ` <anthYJ3RSVWnhVoE@devvm29614.prn0.facebook.com>
2026-08-11 18:46         ` Dragos Tatulea [this message]
2026-08-11 17:25 ` Mina Almasry
2026-08-11 18:13   ` Dragos Tatulea

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=0ba50bc1-d7ea-4874-9bee-acc8a3f89bd7@nvidia.com \
    --to=dtatulea@nvidia.com \
    --cc=bobbyeshleman@devvm29614.prn0.facebook.com \
    --cc=bobbyeshleman@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=j@devvm29614.prn0.facebook.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tariqt@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox