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=bcr+hGrc; 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 8951B5A061C for ; Fri, 17 Oct 2025 12:31:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760697097; 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: in-reply-to:in-reply-to:references:references; bh=IlntkmSkKXA/+u5dHcDxPX7EuzhMjQIuqYf6xqMnXno=; b=bcr+hGrcQHbjVmfCQwzT1x2+YDn0KeiIgq8e64nEQ20rZ1fen8LLv5XSXTk/WffagC9FGi gLt/R+zao+BllaE6490Bc/GUQ3bT8JAvNR9LbJeODRLiazSwf8zsFeBVYuIWCIsjZDQnJV piey7qhaqytBmvgYePHg08w+ZCqLMCY= 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-130-PtCw0IqvOKe24CwgkZRiKA-1; Fri, 17 Oct 2025 06:31:36 -0400 X-MC-Unique: PtCw0IqvOKe24CwgkZRiKA-1 X-Mimecast-MFC-AGG-ID: PtCw0IqvOKe24CwgkZRiKA_1760697095 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 B70491800675; Fri, 17 Oct 2025 10:31:34 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.32.230]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D68AC180057C; Fri, 17 Oct 2025 10:31:32 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v4 1/7] util: Simplify epoll_del() interface to take epollfd directly Date: Fri, 17 Oct 2025 12:31:23 +0200 Message-ID: <20251017103129.229412-2-lvivier@redhat.com> In-Reply-To: <20251017103129.229412-1-lvivier@redhat.com> References: <20251017103129.229412-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6PxXPOv8217TMOVxRV7qjeWf8F2pgoGLZM8RFT8H4jE_1760697095 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: PQA6NN73HEZLHID4BIQSV7JUP6HJHA5A X-Message-ID-Hash: PQA6NN73HEZLHID4BIQSV7JUP6HJHA5A 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 , David Gibson 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: Change epoll_del() to accept the epoll file descriptor directly instead of the full context structure. This simplifies the interface and aligns with the threading refactoring by reducing dependency on the context structure for basic epoll operations as we will manage an epollfd per thread. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- icmp.c | 2 +- tap.c | 2 +- tcp.c | 6 +++--- tcp_splice.c | 4 ++-- udp_flow.c | 4 ++-- util.c | 6 +++--- util.h | 2 +- vhost_user.c | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/icmp.c b/icmp.c index 6dffafb0bf54..bd3108a21675 100644 --- a/icmp.c +++ b/icmp.c @@ -151,7 +151,7 @@ unexpected: static void icmp_ping_close(const struct ctx *c, const struct icmp_ping_flow *pingf) { - epoll_del(c, pingf->sock); + epoll_del(c->epollfd, pingf->sock); close(pingf->sock); flow_hash_remove(c, FLOW_SIDX(pingf, INISIDE)); } diff --git a/tap.c b/tap.c index f3d1f66041f8..9812f120d426 100644 --- a/tap.c +++ b/tap.c @@ -1142,7 +1142,7 @@ void tap_sock_reset(struct ctx *c) } /* Close the connected socket, wait for a new connection */ - epoll_del(c, c->fd_tap); + epoll_del(c->epollfd, c->fd_tap); close(c->fd_tap); c->fd_tap = -1; if (c->mode == MODE_VU) diff --git a/tcp.c b/tcp.c index 0f9e9b3fdc03..745353f782f5 100644 --- a/tcp.c +++ b/tcp.c @@ -511,9 +511,9 @@ static int tcp_epoll_ctl(const struct ctx *c, struct tcp_tap_conn *conn) if (conn->events == CLOSED) { if (conn->in_epoll) - epoll_del(c, conn->sock); + epoll_del(c->epollfd, conn->sock); if (conn->timer != -1) - epoll_del(c, conn->timer); + epoll_del(c->epollfd, conn->timer); return 0; } @@ -3476,7 +3476,7 @@ int tcp_flow_migrate_source_ext(const struct ctx *c, if (c->migrate_no_linger) close(s); else - epoll_del(c, s); + epoll_del(c->epollfd, s); /* Adjustments unrelated to FIN segments: sequence numbers we dumped are * based on the end of the queues. diff --git a/tcp_splice.c b/tcp_splice.c index 26cb63064583..666ee62b738f 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -204,8 +204,8 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn, } if (flag == CLOSING) { - epoll_del(c, conn->s[0]); - epoll_del(c, conn->s[1]); + epoll_del(c->epollfd, conn->s[0]); + epoll_del(c->epollfd, conn->s[1]); } } diff --git a/udp_flow.c b/udp_flow.c index cef3fb588bbe..84973f807167 100644 --- a/udp_flow.c +++ b/udp_flow.c @@ -51,7 +51,7 @@ void udp_flow_close(const struct ctx *c, struct udp_flow *uflow) flow_foreach_sidei(sidei) { flow_hash_remove(c, FLOW_SIDX(uflow, sidei)); if (uflow->s[sidei] >= 0) { - epoll_del(c, uflow->s[sidei]); + epoll_del(c->epollfd, uflow->s[sidei]); close(uflow->s[sidei]); uflow->s[sidei] = -1; } @@ -88,7 +88,7 @@ static int udp_flow_sock(const struct ctx *c, if (flowside_connect(c, s, pif, side) < 0) { int rc = -errno; - epoll_del(c, s); + epoll_del(c->epollfd, s); close(s); flow_dbg_perror(uflow, "Couldn't connect flow socket"); diff --git a/util.c b/util.c index c492f904b3fc..1067486be414 100644 --- a/util.c +++ b/util.c @@ -996,12 +996,12 @@ void raw_random(void *buf, size_t buflen) /** * epoll_del() - Remove a file descriptor from our passt epoll - * @c: Execution context + * @epollfd: epoll file descriptor to remove from * @fd: File descriptor to remove */ -void epoll_del(const struct ctx *c, int fd) +void epoll_del(int epollfd, int fd) { - epoll_ctl(c->epollfd, EPOLL_CTL_DEL, fd, NULL); + epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL); } diff --git a/util.h b/util.h index 22eaac56e719..c61cbef357aa 100644 --- a/util.h +++ b/util.h @@ -300,7 +300,7 @@ static inline bool mod_between(unsigned x, unsigned i, unsigned j, unsigned m) #define FPRINTF(f, ...) (void)fprintf(f, __VA_ARGS__) void raw_random(void *buf, size_t buflen); -void epoll_del(const struct ctx *c, int fd); +void epoll_del(int epollfd, int fd); /* * Starting from glibc 2.40.9000 and commit 25a5eb4010df ("string: strerror, diff --git a/vhost_user.c b/vhost_user.c index 223332d5018e..f8324c59cc6c 100644 --- a/vhost_user.c +++ b/vhost_user.c @@ -733,7 +733,7 @@ static bool vu_get_vring_base_exec(struct vu_dev *vdev, vdev->vq[idx].call_fd = -1; } if (vdev->vq[idx].kick_fd != -1) { - epoll_del(vdev->context, vdev->vq[idx].kick_fd); + epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); close(vdev->vq[idx].kick_fd); vdev->vq[idx].kick_fd = -1; } @@ -801,7 +801,7 @@ static bool vu_set_vring_kick_exec(struct vu_dev *vdev, vu_check_queue_msg_file(vmsg); if (vdev->vq[idx].kick_fd != -1) { - epoll_del(vdev->context, vdev->vq[idx].kick_fd); + epoll_del(vdev->context->epollfd, vdev->vq[idx].kick_fd); close(vdev->vq[idx].kick_fd); vdev->vq[idx].kick_fd = -1; } @@ -1093,7 +1093,7 @@ void vu_cleanup(struct vu_dev *vdev) vq->err_fd = -1; } if (vq->kick_fd != -1) { - epoll_del(vdev->context, vq->kick_fd); + epoll_del(vdev->context->epollfd, vq->kick_fd); close(vq->kick_fd); vq->kick_fd = -1; } -- 2.51.0