From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dyrmKeCo; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 03BFD5A026F for ; Tue, 07 Oct 2025 18:40:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759855231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IjiHtd6sQ3oTkbOwOiJ4P8pu63nisTnnXAEYSikSwOw=; b=dyrmKeCoueUrOBTT84YXqHLI+5uaCXfOF8D/5879P21bbrUazZoW6zCP7DktkEU9BwTLEo vJPQ6DRLpdF6C4z5sz4Hz+7OvfjxcmAyBdT5tPAMxrceShX8FNt/47OBGb/1Mpo4i0mgSH UxMMEaII3ApQL/lDcscC047wCnlABJA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-546-cNeHrcZdOg2xuJLNIMiKOw-1; Tue, 07 Oct 2025 12:40:30 -0400 X-MC-Unique: cNeHrcZdOg2xuJLNIMiKOw-1 X-Mimecast-MFC-AGG-ID: cNeHrcZdOg2xuJLNIMiKOw_1759855229 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C322180057E for ; Tue, 7 Oct 2025 16:40:29 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.224.166]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1ECAE1800446; Tue, 7 Oct 2025 16:40:27 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v2 0/6] Refactor epoll handling in preparation for multithreading Date: Tue, 7 Oct 2025 18:40:20 +0200 Message-ID: <20251007164026.3882026-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: I-eORBmpb0p0nZjTYm6S3PXVW6jVakFbCH3hTstZwTY_1759855229 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TTDWVSKVXAUITIQA7MAYDKTI7PBTV44L X-Message-ID-Hash: TTDWVSKVXAUITIQA7MAYDKTI7PBTV44L X-MailFrom: lvivier@redhat.com 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: Laurent Vivier 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: This series refactors how epoll file descriptors are managed throughout=0D the codebase in preparation for introducing multithreading support.=0D Currently, passt uses a single global epollfd accessed through the=0D context structure. With multithreading, each thread will need its own=0D epollfd managing its subset of flows.=0D =0D The key changes are:=0D =0D 1. Centralize epoll management by extracting helper functions into a new=0D epoll_ctl.c/h module and moving union epoll_ref from passt.h to its=0D more logical location in epoll_ctl.h.=0D =0D 2. Simplify epoll_del() to take the epollfd directly rather than=0D extracting it from the context structure, reducing coupling between=0D epoll operations and the global context.=0D =0D 3. Move epoll registration out of sock_l4_sa() into protocol-specific=0D code, giving callers explicit control over which epoll instance=0D manages each socket.=0D =0D 4. Replace the boolean in_epoll flag in TCP connections with an epollfd=0D field in flow_common. This serves dual purposes: tracking registration= =0D status (EPOLLFD_INVALID =3D not registered) and identifying the owning= =0D epoll instance. The epollfd field is 8 bits, limiting values to 0-254=0D (255 =3D EPOLLFD_INVALID).=0D =0D 5. Apply this pattern consistently across all protocol handlers (TCP,=0D ICMP, UDP), storing the managing epollfd in each flow's common=0D structure.=0D =0D These changes make epoll ownership explicit in the flow tracking system,=0D enabling flows to be managed by different epoll instances, a prerequisite= =0D for per-thread epollfd design in upcoming multithreading work.=0D =0D Changes since v1:=0D - New patch: "epoll_ctl: Extract epoll operations" - centralizes epoll=0D helpers into a dedicated module and relocates union epoll_ref from=0D passt.h to epoll_ctl.h=0D - Changed epollfd type in flow_common from int to 8-bit bitfield to avoid= =0D exceeding cacheline size threshold=0D - Added flow_epollfd_valid() helper to check epoll registration status=0D - Added flow_set_epollfd() helper to set the epoll instance for a flow=0D =0D Laurent Vivier (6):=0D util: Simplify epoll_del() interface to take epollfd directly=0D epoll_ctl: Extract epoll operations=0D util: Move epoll registration out of sock_l4_sa()=0D tcp, flow: Replace per-connection in_epoll flag with epollfd in=0D flow_common=0D icmp: Use epollfd from flow_common structure=0D udp: Use epollfd from flow_common structure=0D =0D Makefile | 22 +++++++++++-----------=0D epoll_ctl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++=0D epoll_ctl.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++=0D flow.c | 36 +++++++++++++++++++++++++++++-------=0D flow.h | 10 +++++++++-=0D icmp.c | 23 +++++++++++++++--------=0D passt.c | 2 +-=0D passt.h | 34 ----------------------------------=0D pasta.c | 7 +++----=0D pif.c | 32 +++++++++++++++++++++++++-------=0D repair.c | 14 +++++---------=0D tap.c | 15 +++++----------=0D tcp.c | 38 +++++++++++++++++++-------------------=0D tcp_conn.h | 8 +-------=0D tcp_splice.c | 25 ++++++++++++-------------=0D udp.c | 2 +-=0D udp_flow.c | 23 +++++++++++++++++++----=0D util.c | 28 ++--------------------------=0D util.h | 6 ++++--=0D vhost_user.c | 14 +++++---------=0D vu_common.c | 2 +-=0D 21 files changed, 263 insertions(+), 174 deletions(-)=0D create mode 100644 epoll_ctl.c=0D create mode 100644 epoll_ctl.h=0D =0D --=20=0D 2.50.1=0D =0D