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=202502 header.b=O1J3ftRn; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id ADDC35A0622 for ; Tue, 11 Mar 2025 07:03:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1741673000; bh=nKpaGzD14/O8GXM9hUxcWspDY7NqGvOUL5gRg/ZG0VQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1J3ftRnN4421vMQcIG7z0U0+34XSotgQgdwcaOHQJRjdeLOMBXUk2gGXlneBPQuG yCAkSlQ5Uj1QyjNy+BmqPAPEwUwYIdhTwr9XUgD5EsGqk5X/+u15EjsJ46TRJad3Oy 707cLK9trgoCmf2JDhqSJDwH07wDk2Qn5FPk0mDP5FYzSMIGkHk/QivaCZb9I0Lb71 0I4hzB2ULrK0XFyNpPWKsWk/FkBegIjEVecz7xssgm/VAgE9Oo6jgCIxCA9TEJOjLK kuGcfSCRXLb3TEG/OzDWg0E6MPosA/7vlSky0n0nfqpHrk5sEcuITXl7XORCUg9aAP Q7c4YspmlCo+g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZBjqX4Q8Vz4xDy; Tue, 11 Mar 2025 17:03:20 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 7/9] Simplify sizing of pkt_buf Date: Tue, 11 Mar 2025 17:03:16 +1100 Message-ID: <20250311060318.1502861-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311060318.1502861-1-david@gibson.dropbear.id.au> References: <20250311060318.1502861-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XJJ6Y4TJ7ZJS4Q7VDXDGY72UODOY4DAT X-Message-ID-Hash: XJJ6Y4TJ7ZJS4Q7VDXDGY72UODOY4DAT 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: 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: We define the size of pkt_buf as large enough to hold 128 maximum size packets. Well, approximately, since we round down to the page size. We don't have any specific reliance on how many packets can fit in the buffer, we just want it to be big enough to allow reasonable batching. The current definition relies on the confusingly named ETH_MAX_MTU and adds in sizeof(uint32_t) rather non-obviously for the pseudo-physical header used by the qemu socket (passt mode) protocol. Instead, just define it to be 8MiB, which is what that complex calculation works out to. Signed-off-by: David Gibson --- passt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/passt.h b/passt.h index 6b248051..8f450912 100644 --- a/passt.h +++ b/passt.h @@ -69,8 +69,8 @@ union epoll_ref { static_assert(sizeof(union epoll_ref) <= sizeof(union epoll_data), "epoll_ref must have same size as epoll_data"); -#define PKT_BUF_BYTES \ - ROUND_DOWN(((ETH_MAX_MTU + sizeof(uint32_t)) * 128), PAGE_SIZE) +/* Large enough for ~128 maximum size frames */ +#define PKT_BUF_BYTES (8UL << 20) #define TAP_MSGS \ DIV_ROUND_UP(PKT_BUF_BYTES, ETH_ZLEN - 2 * ETH_ALEN + sizeof(uint32_t)) -- 2.48.1