Netdev List
 help / color / mirror / Atom feed
From: ayaka <ayaka@soulik.info>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>,
	netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: tuntap: add ioctl() TUNGETQUEUEINDX to fetch queue index
Date: Thu, 8 Aug 2024 12:16:46 +0800	[thread overview]
Message-ID: <6C9DA933-5EAA-4711-BF89-0B71834DA211@soulik.info> (raw)
In-Reply-To: <CAF=yD-+2SnOzALmisVVBZAKNKrCMv07FdEDP1ov35APNMYOTew@mail.gmail.com>


Sent from my iPad

> On Aug 8, 2024, at 11:13 AM, Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
> 
> 
>> 
>>> In that case, a tc egress tc_bpf program may be able to do both.
>>> Again, by writing to __sk_buff queue_mapping. Instead of u32 +
>>> skbedit.
>>> 
>>> See also
>>> 
>>> "
>>> commit 74e31ca850c1cddeca03503171dd145b6ce293b6
>>> Author: Jesper Dangaard Brouer <brouer@redhat.com>
>>> Date:   Tue Feb 19 19:53:02 2019 +0100
>>> 
>>>    bpf: add skb->queue_mapping write access from tc clsact
>>> "
>>> 
>>> But I suppose you could prefer u32 + skbedit.
>>> 
>>> Either way, the pertinent point is that you want to map some flow
>>> match to a specific queue id.
>>> 
>>> This is straightforward if all queues are opened and none are closed.
>>> But it is not if queues can get detached and attached dynamically.
>>> Which I guess you encounter in practice?
>>> 
>>> I'm actually not sure how the current `tfile->queue_index =
>>> tun->numqueues;` works in that case. As __tun_detach will do decrement
>>> `--tun->numqueues;`. So multiple tfiles could end up with the same
>>> queue_index. Unless dynamic detach + attach is not possible.
>> 
>> It is expected to work, otherwise there should be a bug.
>> 
>>> But it
>>> seems it is. Jason, if you're following, do you know this?
>> 
>> __tun_detach() will move the last tfile in the tfiles[] array to the
>> current tfile->queue_index, and modify its queue_index:
>> 
>>        rcu_assign_pointer(tun->tfiles[index],
>>                                   tun->tfiles[tun->numqueues - 1]);
>>        ntfile = rtnl_dereference(tun->tfiles[index]);
>>        ntfile->queue_index = index;
>>        rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
>>                                   NULL);
>> 
>>        --tun->numqueues;
>> 
>> tun_attach() will move the detached tfile to the end of the tfiles[]
>> array and enable it:
>> 
>> 
>>        tfile->queue_index = tun->numqueues;
>>        ....
>>        rcu_assign_pointer(tun->tfiles[tun->numqueues], tfile);
>>        tun->numqueues++;
>> 
> 
> Ah right. Thanks. I had forgotten about that.
> 
> So I guess an application that owns all the queues could keep track of
> the queue-id to FD mapping. But it is not trivial, nor defined ABI
> behavior.
> 
> Querying the queue_id as in the proposed patch might not solve the
> challenge, though. Since an FD's queue-id may change simply because
Yes, when I asked about those eBPF thing, I thought I don’t need the queue id in those ebpf. It turns out a misunderstanding.
Do we all agree that no matter which filter or steering method we used here, we need a method to query queue index assigned with a fd?
> another queue was detached. So this would have to be queried on each
> detach.
> 
Thank you Jason. That is why I mentioned I may need to submit another patch to bind the queue index with a flow.

I think here is a good chance to discuss about this.
I think from the design, the number of queue was a fixed number in those hardware devices? Also for those remote processor type wireless device(I think those are the modem devices).
The way invoked with hash in every packet could consume lots of CPU times. And it is not necessary to track every packet.
Could I add another property in struct tun_file and steering program return wanted value. Then it is application’s work to keep this new property unique.
> I suppose one underlying question is how important is the mapping of
> flows to specific queue-id's? Is it a problem if the destination queue
> for a flow changes mid-stream?
Yes, it matters. Or why I want to use this feature. From all the open source VPN I know, neither enabled this multiqueu feature nor create more than one queue for it.
And virtual machine would use the tap at the most time(they want to emulate a real nic).
So basically this multiple queue feature was kind of useless for the VPN usage.
If the filter can’t work atomically here, which would lead to unwanted packets transmitted to the wrong thread.

  parent reply	other threads:[~2024-08-08  4:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 11:19 [PATCH] net: tuntap: add ioctl() TUNGETQUEUEINDX to fetch queue index Randy Li
2024-07-31 14:12 ` Willem de Bruijn
2024-07-31 16:45   ` Randy Li
2024-07-31 21:57     ` Willem de Bruijn
2024-08-01  9:15       ` Randy Li
2024-08-01 13:04         ` Willem de Bruijn
2024-08-01 13:36           ` Randy Li
2024-08-01 14:17             ` Willem de Bruijn
2024-08-01 19:52               ` Randy Li
2024-08-02 15:10                 ` Willem de Bruijn
2024-08-07 18:54                   ` Randy Li
2024-08-08  2:10                     ` Willem de Bruijn
2024-08-08  2:49                       ` Jason Wang
2024-08-08  3:11                         ` Willem de Bruijn
2024-08-08  3:36                           ` Jason Wang
2024-08-08  4:16                           ` ayaka [this message]
2024-08-08 18:48                             ` Willem de Bruijn
2024-08-09  4:45                               ` ayaka
2024-08-09 14:55                                 ` Willem de Bruijn
2024-08-12  6:05                                   ` Jason Wang
2024-08-12 17:10                                     ` Willem de Bruijn
2024-08-13  3:53                                       ` Jason Wang
2024-08-13 13:22                                         ` Willem de Bruijn
  -- strict thread matches above, loose matches on Subject: below --
2024-08-09  4:50 ayaka

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=6C9DA933-5EAA-4711-BF89-0B71834DA211@soulik.info \
    --to=ayaka@soulik.info \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemdebruijn.kernel@gmail.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