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=202608 header.b=pvRWgLza; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id DDA1C5A0271 for ; Fri, 14 Aug 2026 08:52:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202608; t=1786690354; bh=XmfsWvmybeOSS+rFuGveVnMzJ2wcIi8Cp2aBwCqVN3Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pvRWgLzadgNpRks7MgGO5p3tmE7UNtXfRlQhWs1V3LAAPglvLQN0EKFNDiygfA4R9 bxDDDGLwnsAn0fPnK71TbYJk7RxefCPNgZJoFlPqQRPOP/nmdVwg81MO17zz0ouTUj N1SpuFlFM6aGw7knCnI4wxGWJ/PKDn+l+S6bO9lkn3kgob1xDarptN6En9aA7+8Xih DiBDu7yfuxERECGG9KSR4Ho1kqlFd7W7J3hH0FapYIzfxUZFNKP3n2I2jinKIoyHoP ZE0lv66ecxaT0oKLBMXOCsxHH2jk/NBwBFI4oCqKUewcUPUBZuUr6REQfkSrNqSYMX D/PtgW9lnkeBg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4hLtFt6zB1z4wDm; Fri, 14 Aug 2026 16:52:34 +1000 (AEST) Date: Fri, 14 Aug 2026 16:25:50 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 3/7] passt: Integrate main event loop with threading infrastructure Message-ID: References: <20260731164628.3556997-1-lvivier@redhat.com> <20260731164628.3556997-4-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="TG/u24cgEk1FV7gG" Content-Disposition: inline In-Reply-To: <20260731164628.3556997-4-lvivier@redhat.com> Message-ID-Hash: UWRCSIRAVUEGYVHX3B3L4VVHYGUGHXUS X-Message-ID-Hash: UWRCSIRAVUEGYVHX3B3L4VVHYGUGHXUS 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: --TG/u24cgEk1FV7gG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 31, 2026 at 06:46:24PM +0200, Laurent Vivier wrote: > Convert the main event loop to use the threading subsystem. The main > process now registers passt_worker() as thread #0 and starts it through > the threading infrastructure instead of running a manual epoll_wait loop. >=20 > Signed-off-by: Laurent Vivier > --- > passt.c | 20 ++++---------------- > threading.c | 3 --- > 2 files changed, 4 insertions(+), 19 deletions(-) >=20 > diff --git a/passt.c b/passt.c > index 8a06838c5ed8..2cedb7ba0756 100644 > --- a/passt.c > +++ b/passt.c > @@ -333,8 +333,7 @@ static void passt_worker(void *opaque, int nfds, stru= ct epoll_event *events) > */ > int main(int argc, char **argv) > { > - struct epoll_event events[NUM_EPOLL_EVENTS]; > - int nfds, devnull_fd =3D -1, fd; > + int devnull_fd =3D -1, fd; > struct ctx *c =3D &passt_ctx; > struct rlimit limit; > struct timespec now; > @@ -377,9 +376,7 @@ int main(int argc, char **argv) > madvise(pkt_buf, sizeof(pkt_buf), MADV_HUGEPAGE); > =20 > threading_init(); > - c->epollfd =3D epoll_create1(EPOLL_CLOEXEC); > - if (c->epollfd =3D=3D -1) > - die_perror("Failed to create epoll file descriptor"); > + c->epollfd =3D threading_epollfd(THREADING_ID_DEFAULT); > =20 > if (getrlimit(RLIMIT_NOFILE, &limit)) > die_perror("Failed to get maximum value of open files limit"); > @@ -449,15 +446,6 @@ int main(int argc, char **argv) > =20 > isolate_postfork(c); > =20 > -loop: > - /* NOLINTBEGIN(bugprone-branch-clone): intervals can be the same */ > - /* cppcheck-suppress [duplicateValueTernary, unmatchedSuppression] */ > - nfds =3D epoll_wait(c->epollfd, events, NUM_EPOLL_EVENTS, TIMER_INTERVA= L); > - /* NOLINTEND(bugprone-branch-clone) */ > - if (nfds =3D=3D -1 && errno !=3D EINTR) > - die_perror("epoll_wait() failed in main loop"); > - > - passt_worker(c, nfds, events); > - > - goto loop; > + threading_worker_set(THREADING_ID_DEFAULT, passt_worker, c); > + threading_start_thread(THREADING_ID_DEFAULT); Invoking this through threading_start_thread(), which then special cases thread 0 seems a bit odd. Could you just directly call threading_worker()? > } > diff --git a/threading.c b/threading.c > index fd5b30ed7ff6..e1ed644f5864 100644 > --- a/threading.c > +++ b/threading.c > @@ -66,7 +66,6 @@ void threading_init(void) > * > * Return: 0 on success, -1 if thread index is invalid > */ > -/* cppcheck-suppress unusedFunction */ > int threading_worker_set(unsigned int threadid, > void (*worker)(void *, int, struct epoll_event *), > void *opaque) > @@ -90,7 +89,6 @@ int threading_worker_set(unsigned int threadid, > * > * Return: epoll file descriptor for the specified thread, -1 if index i= nvalid > */ > -/* cppcheck-suppress unusedFunction */ > int threading_epollfd(unsigned int threadid) > { > if (threadid >=3D ARRAY_SIZE(threads)) > @@ -135,7 +133,6 @@ static void *threading_worker(void *opaque) > * > * #syscalls rt_sigaction rt_sigprocmask mprotect getrandom brk clone3 r= seq set_robust_list clock_nanosleep > */ > -/* cppcheck-suppress unusedFunction */ > void threading_start_thread(unsigned int threadid) > { > struct threading_context *tc; > --=20 > 2.54.0 >=20 --=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 --TG/u24cgEk1FV7gG Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmp+tOYACgkQzQJF27ox 2Gdrqg/7BhYrvO/YgXRPQ7C04UmQtbeWmLIUNA+vMiSvqOuBosYsVMT3s/sQM0Vf mEH6AQjUFEkTJQUSGQAxJ7t7JReJcmCE39Sr0IQWFsHppfvsN1ZD2dnKJW4AcWt8 h4Vg2QSppt678d5cvd/9FGTc4ZOsgdwJ22pnB2dNopVCXnhIN1JZr2C92PLOANZn zEb+SsOOGcoGCzSYJYL37KDf/3daer5By6mual5tJIEqjqWhGcVhwbv5tOqv10Wj Cv/QnqOcuAbT45XRWdLvpUpCEoZwyOSt8V+eOvN1xlpriscZDXqOS3qqm8Bi3UHe trirhe8KxOAO0zY+eWiovbP2B7krkkSX9wO9Y6lHClnoPmlplxD2j+/+vqmeqRV+ zRdwoKhOae0HuFGJOLew4FAvW19y3/f4XwoFpVtz6vGEZMn+zjz1Gwbz2Vz6GKHe /EO32/w9AC9E6gZtkwPEEtN9PuitTt/hXzrJ6BKY/DW7CzXdBBxTTSiKazh2hwIN fhC+Or5vK7zF69pAWOD2kXrCpFXJrBYA6NME+6MVFyekJ566nC25sb3ThHHVucyr EYkR48YP8MyZREI8QGVEh/J3TESb6o+uXABj1DKsI6/DTBDY3UNHeQyNdEn23KZj /yCVKiolVqHnldGiL/haZhIqQHoG7aYYghwljyZZXKlDAIh8LCw= =SRVd -----END PGP SIGNATURE----- --TG/u24cgEk1FV7gG--