public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v2 05/10] flow: Make flow timer per-caller for thread safety
Date: Mon, 3 Aug 2026 16:35:04 +1000	[thread overview]
Message-ID: <anA2jDcjAtK2e0Wy@zatzit> (raw)
In-Reply-To: <anAw_cEP3vlV4er_@zatzit>

[-- Attachment #1: Type: text/plain, Size: 2132 bytes --]

On Mon, Aug 03, 2026 at 04:11:24PM +1000, David Gibson wrote:
> On Fri, Jul 31, 2026 at 06:23:24PM +0200, Laurent Vivier wrote:
> > Move the static flow_timer_run variable out of flow.c and pass it as a
> > parameter to flow_defer_handler().  This allows each caller to maintain
> > its own timer state: each vhost-user queue pair worker uses the per-qpair
> > context.
> > 
> > Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> 
> One small misgiving about this, although I doubt it can cause a real
> problem.  Becayse this timer processing now doesn't happen all at
> once, at each queue is on a separate timer cycle, it's theoretically
> possible for a flow to change qpair every FLOW_TIMER_INTERVAL and
> thereby indefinitely avoid having the timer running on it.
> 
> It's pretty tricky to do (depending on how close in real time each
> queue's timers end up running), and I don't *think* that can do
> anything terribly bad (maybe delay cleanup).  But since the guest
> could in principle control the qpair placements to specifically
> trigger this, it just makes me think it warrants a good close look to
> make sure that something bad can't be triggered that way.

Looking at the next patch, I realised there's a much easier to hit
concern here.  Kind of the opposite of the one above, if there's a
migration at the wrong moment, we might run the timer twice on a flow
in a much smaller interval than usual.  AFAICT, the worst that can do
- at least with our current flow_defer() and flow_timer() functions is
a little bit of unnecessary work, so I think it's ok.  That's because
none of them unconditionally do anything damaging - they always check
an independent timestamp.

However, it does add another wrinkle to what is and isn't safe in the
defer and timer functions: they cannot rely on being called at most
every INTERVAL seconds.  We should probably document
that... somewhere.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-08-03  6:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 16:23 [PATCH v2 00/10] multithreading: Prepare data structures for concurrent queue pair workers Laurent Vivier
2026-07-31 16:23 ` [PATCH v2 01/10] tap: Convert packet pools to per-queue-pair arrays for multiqueue Laurent Vivier
2026-08-03  5:41   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 02/10] tap: Make L4 sequence pools per-qpair for thread safety Laurent Vivier
2026-08-03  5:43   ` David Gibson
2026-08-03  5:55     ` David Gibson
2026-07-31 16:23 ` [PATCH v2 03/10] tcp: Make static buffers stack-local " Laurent Vivier
2026-08-03  5:59   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 04/10] udp_vu: Make virtqueue " Laurent Vivier
2026-08-03  6:00   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 05/10] flow: Make flow timer per-caller " Laurent Vivier
2026-08-03  6:11   ` David Gibson
2026-08-03  6:35     ` David Gibson [this message]
2026-07-31 16:23 ` [PATCH v2 06/10] tcp: Make TCP timer state per-caller and guard global tasks Laurent Vivier
2026-08-03  6:40   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 07/10] tcp: Protect init socket pools with mutex for thread safety Laurent Vivier
2026-08-03  6:53   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 08/10] tcp: Extract tcp_timer_epoll_add() helper Laurent Vivier
2026-08-03  6:54   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 09/10] flow: Add locking, per-qpair filtering, and intermediate state handling Laurent Vivier
2026-08-03  9:58   ` David Gibson
2026-07-31 16:23 ` [PATCH v2 10/10] flow: Add lazy, lock-free flow migration between queue pairs Laurent Vivier

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=anA2jDcjAtK2e0Wy@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --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).