From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=jZ4t0ReU; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 642C95A061C for ; Wed, 22 Oct 2025 03:01:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1761094876; bh=FZt8JjKcSCe8hX+OJ8pwxrW+0uoMA+k9DBbsMwC+ffg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jZ4t0ReUNbxsmhxfTPguRFoe0ScCNe2IAYhjiXMWQXpOAg5SxhDQv1+8vQ+pYoveM fMHtE2Z9lz4zOvtO1Lb56nBY7IC+FfpjEBovKihIti5jYf/hGH2LQRhS09jW5U7YNo gXvYdw8sYxv3tS4w7XB0OVWn0NhjNIjrFPSr6fYCD46MKpN+B7k7tTfnog0R4DREsi ecsH2JIrpju5V/+/9r7dYlkBV7p92xtZCcDa6INP1Ok60T6PG1JuS0V9KwJuvQVe8I 5vYnG0X3eLPEOT3FdfP2+46aM+swSVg5RIERuhdNvlRNmYqsHe8cbgd62M8kQIIYgw DVVa597Jvfwjg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4crrT81jycz4w9Q; Wed, 22 Oct 2025 12:01:16 +1100 (AEDT) Date: Wed, 22 Oct 2025 11:53:52 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v4 7/7] passt: Move main event loop processing into passt_worker() Message-ID: References: <20251017103129.229412-1-lvivier@redhat.com> <20251017103129.229412-8-lvivier@redhat.com> <997ad29f-4c62-495b-b4bf-7405dbc55537@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qQMkEaop+CGKuXKV" Content-Disposition: inline In-Reply-To: <997ad29f-4c62-495b-b4bf-7405dbc55537@redhat.com> Message-ID-Hash: 3GJCYD4T6B5AM5HOD2UDI3SJJFUYCQMP X-Message-ID-Hash: 3GJCYD4T6B5AM5HOD2UDI3SJJFUYCQMP X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --qQMkEaop+CGKuXKV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 21, 2025 at 10:00:58AM +0200, Laurent Vivier wrote: > On 20/10/2025 03:43, David Gibson wrote: > > On Fri, Oct 17, 2025 at 12:31:29PM +0200, Laurent Vivier wrote: > > > Extract the epoll event processing logic from main() into a separate > > > passt_worker() function. This refactoring prepares the code for future > > > threading support where passt_worker() will be called as a worker thr= ead > > > callback. > > >=20 > > > The new function handles: > > > - Processing epoll events and dispatching to protocol handlers > > > - Event statistics tracking and printing > > > - Post-handler periodic tasks (timers, deferred work) > > > - Migration handling > > >=20 > > > No functional changes, purely a code restructuring. > > >=20 > > > Signed-off-by: Laurent Vivier > >=20 > > Looks good as far as it goes, and I've though often in the past that > > it would make more sense for the "engine" to go in its own function. > >=20 > > Wondering if it would make more sense to include the epoll_wait() > > itself and the loop in this function, rather than leaving that > > outside. > >=20 >=20 > When I introduce the multithreading and the multiqueue, as the thread is > driven by the epollfd, the events are managed by the multiqueue part and = the > epollfd by the multithread part. >=20 > The "threading" worker is: >=20 > static void *threading_worker(void *opaque) > { > struct threading_context *tc =3D opaque; >=20 > while (true) { > struct epoll_event events[NUM_EPOLL_EVENTS]; > int nfds; >=20 > nfds =3D epoll_wait(tc->epollfd, events, NUM_EPOLL_EVENTS, > TIMER_INTERVAL); > if (nfds =3D=3D -1 && errno !=3D EINTR) > die_perror("epoll_wait() failed"); >=20 > tc->worker(tc->opaque, nfds, events); IIUC the point here is that eventually the epoll_wait() will be common, but the worker might be different for different threads. Is that correct? --=20 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 --qQMkEaop+CGKuXKV Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmj4Kx8ACgkQzQJF27ox 2Ge6qQ/+MceEJAL1pnX77nOqWD0J+FXejECJcmJpkb15cgEsehBaCQjpzYi4/ld0 Aq+4uDZXb+T/Ls9vyxMrRExRW1nvxutd4/KX6uyGo8nblZAzajVbbT0utLeneVZm 1T8YrtTwuTJ64s3qH8Nw/mOiFIKp0Wj+pS5cSRz55hNvM8ZI2SrUmILENjHmHETJ +LADC+yMgdnkIB2SujOhGiHm4XehqeAwKukFoBlIULz7fi1p6RXSWHBld83IWRVP SgZ7MA2v6O/UDTvO89Zr91j9/5J60cgX6BTrKAO1c004/m41oeYq2rbCW+G2kNn4 h304e0Asf+XDQJDTdfa4TJYm5KG36VWBfOrrccAia76AzSmkqFoxISRktMWxxDvQ yNoSzbAsE7EXX6fo92827MANIpVCKWZoajEiRC+unT1rcuoy45xh25zcRXD3A+1Z QfOH4jvPHIXsAGkVvMdXqi6/UleseIEB0+HHXSOSoWGuPNDKfe7YKIqj5lw9i2J/ YWxVjbTR6mYWyd89xAaQhNEwdfxJqjmIolLQHB1Vu+kUbjOoqCQSK6InyeM/+4J4 ejD0uPKqTFwVMFKNOmwI4TiizRA5zoFHNJdzlWLSHljFGYdvnteaiAK6udBAZpeW mhJfcLVLZ0nR7KLQkAQbj8O345hojMdXFuM3A66JCBnYd3xTg2w= =dRo7 -----END PGP SIGNATURE----- --qQMkEaop+CGKuXKV--