public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v5 06/12] tcp: Pass queue pair explicitly through TCP send path
Date: Mon, 22 Jun 2026 09:44:45 +0200	[thread overview]
Message-ID: <b9845248-f75f-495d-9d99-7e02419a4c4d@redhat.com> (raw)
In-Reply-To: <ajifk9pWrNNHMnnB@zatzit>

On 6/22/26 04:36, David Gibson wrote:
> On Fri, Jun 19, 2026 at 07:07:56PM +0200, Laurent Vivier wrote:
>> On 6/19/26 08:00, David Gibson wrote:
>>> On Tue, Jun 16, 2026 at 02:51:24PM +0200, Laurent Vivier wrote:
>>>> Thread a qpair parameter from the entry points (tcp_sock_handler,
>>>> tcp_timer_handler, tcp_tap_handler, tcp_defer_handler) through every
>>>> intermediate function down to the vhost-user send functions, so callers
>>>> explicitly select the target RX virtqueue instead of hardcoding
>>>> QPAIR_DEFAULT.
>>>>
>>>> Add a qpair parameter to tcp_send_flag(), tcp_data_from_sock(),
>>>> tcp_rst_do() and its tcp_rst() macro, tcp_rewind_seq(),
>>>> tcp_data_from_tap(), tcp_conn_from_sock_finish(), tcp_connect_finish(),
>>>> tcp_tap_window_update(), tcp_conn_from_tap(), tcp_rst_no_conn(),
>>>> tcp_keepalive(), and tcp_inactivity().
>>>
>>> For the to-guest functions which take a connection parameter, this
>>> seems odd to me.  Can't they deduce the right queue from the
>>> connection?
>>
>> The connection's qpair (conn->f.qpair) can change at any time when
>> another thread processes a tap packet for the same flow and calls
>> FLOW_MIGRATE().
> 
> Ahh.  Hmm.  Right.  I guess I don't really know the concurrency model
> you're going for.  I had assumed that each flow was pinned to a
> thread, and migrating it was an operation requiring a maybe complex
> and heavyweight synchronization step.
> 
>> If a socket event fires on qpair 0's epoll instance and we read
>> conn->f.qpair during processing, another thread might change it
>> concurrently via FLOW_MIGRATE().  The qpair from the epoll event is
>> the stable, race-free reference for "which queue am I operating on."
> 
> Ok.  For call chains initiated on the tap side, that's clear enough -
> it's the queue we got the initiating event on.  For things initiaed on
> the socket side it's less clear what "queue I am operating on" means.
> I guess it means the queue associated with the epoll set tne
> initiating event occurred on?

Yes, qpairs are binded to an epoll fd. In the 3rd series (I didn't send it, 2nd is about 
to handle concurrency), each qpair is binded to an epollfd and each epollfd is handled by 
a thread. The socket-side qpair is the queue associated with the epoll instance that 
delivere the event.


> 
>> So the explicit parameter is intentional: it carries the qpair from
>> the epoll event through the call chain, independent of the mutable
>> flow state.
> 
> I guess I haven't looked at the multithread series yet, but it feels
> like the picture has a gap.  In general we freely access fields in the
> connection.  I had assumed that meant it was "owned" by the current
> thread.  If the owning thread can change midstream, don't we need some
> other sort of synchronization accessing *anything* in the flow entry?
> 

Yes, you're right, I missed that. I added lock to the flow table but only to access the 
table, not the individual entry.

Perhaps we can do the migration at the end of the processing of the entry, perhaps in the 
post processing function?

Thanks,
Laurent


  reply	other threads:[~2026-06-22  7:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 12:51 [PATCH v5 00/12] vhost-user: Add multiqueue support Laurent Vivier
2026-06-16 12:51 ` [PATCH v5 01/12] tap: Remove pool parameter from tap4_handler() and tap6_handler() Laurent Vivier
2026-06-16 12:51 ` [PATCH v5 02/12] vhost-user: Advertise multiqueue support Laurent Vivier
2026-06-19  5:17   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 03/12] test: Add multiqueue support to vhost-user test infrastructure Laurent Vivier
2026-06-19  5:06   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 04/12] tap: Thread queue pair through all remaining tap paths Laurent Vivier
2026-06-19  5:37   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 05/12] arp: Pass queue pair explicitly through ARP send path Laurent Vivier
2026-06-19  5:40   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 06/12] tcp: Pass queue pair explicitly through TCP " Laurent Vivier
2026-06-19  6:00   ` David Gibson
2026-06-19 17:07     ` Laurent Vivier
2026-06-22  2:36       ` David Gibson
2026-06-22  7:44         ` Laurent Vivier [this message]
2026-06-22 10:01           ` David Gibson
2026-06-16 12:51 ` [PATCH v5 07/12] udp: Pass queue pair explicitly through UDP " Laurent Vivier
2026-06-19  6:08   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 08/12] dhcp/dhcpv6: Pass queue pair explicitly through DHCP " Laurent Vivier
2026-06-19  6:10   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 09/12] icmp: Pass queue pair explicitly through ICMP " Laurent Vivier
2026-06-19  6:12   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 10/12] ndp: Pass queue pair explicitly through NDP " Laurent Vivier
2026-06-19  6:17   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 11/12] flow: Add queue pair tracking to flow management Laurent Vivier
2026-06-19  6:36   ` David Gibson
2026-06-16 12:51 ` [PATCH v5 12/12] flow: Derive epoll fd from queue pair, removing epollid field Laurent Vivier
2026-06-19  6:52   ` David Gibson

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=b9845248-f75f-495d-9d99-7e02419a4c4d@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).