From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C8BD1DEFF5 for ; Mon, 12 Jan 2026 14:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768229301; cv=none; b=OOI5lm+KTkmP5psARRmpdu5uc1D5O92vKhCauhzr9AwmRzkLj5lt6cMgEN2OBh25OsUOipOUFJHtyEiOUzcvf/pP4wGj1uxwWhc+psbSnq2TnBF8g0M0h4IZ/gmHx65Z2vgXB7vmGyStucdO64YTw4/VdYow3iMgnvxiViw6YwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768229301; c=relaxed/simple; bh=unu+z7fUfKJmL/eHLl0giWFWnZl9lhh73IswOVtZOOM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p5YtYeNG9Hu49lXtNMjADJNDhYjMuaT8jWuPnl5oq8N9h480JROxL/r2Nf7krM9lbVsLb3yxOVrQbNX/1CkQtWfLRtBVfhK5ndzsaM4geL0B4iuVCeyz8TP0ayZqLBxX3w3a2tAKJQSnwc77W2W0zJHIsW0eu15dbvkGReaRslg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ld3QigNw; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=TZHAQQrn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ld3QigNw"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="TZHAQQrn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768229299; 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: in-reply-to:in-reply-to:references:references; bh=+4uY6QtcEAOdroKyjwSP1zoQ56MLnzMwcJEHXal3TGs=; b=Ld3QigNwd3vrrBBohigK3opYRaesqO8WkwovrmMX1RqHOLSLuwzbr6YX9NRnV20Rt7xjy4 dKJCTjaUPl4b37X+uEdimTiT9iFqgKzXu0mMLh2ET9sG1O4PgwK1uD4weUSk8/p2Wx1Iln diNCPRjp74Z2Y8aVdVozKN84QLnEQf4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-Ia676-ZaNI-n1KtOAfo7CA-1; Mon, 12 Jan 2026 09:48:18 -0500 X-MC-Unique: Ia676-ZaNI-n1KtOAfo7CA-1 X-Mimecast-MFC-AGG-ID: Ia676-ZaNI-n1KtOAfo7CA_1768229297 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-430fc153d50so4788859f8f.1 for ; Mon, 12 Jan 2026 06:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768229297; x=1768834097; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+4uY6QtcEAOdroKyjwSP1zoQ56MLnzMwcJEHXal3TGs=; b=TZHAQQrnFm0NsXxpCwiKV14D4sSbSnp/ZKrtKYAN9oDZv09rzEQagt4uxI0u3tGgr4 egVrNxwetLlLron4Ij/mlK1UAe4LVPKa1Gy/7fTdj2hzO3dDg4GdQLHzGmiVCIdG2xf9 bdXP6U5D7fqWaoI7tcpoOQJhRyHGONZ39Bn2ObxqKgLWiKzGKY2UMi7sgfRmKN4XYh44 USj9JILFjjo3CC10SmfTGGZhG5j5c4Iq+fyMuhsJq8Y/eXmJxE/h3OnEPQeOebdqppWu 5vaxy3l6cb+HFv4QxTgomME64ENEOYrACy6japjmO5LNYbql9q0tgWnFsEmXF9CVGA+t i9HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768229297; x=1768834097; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+4uY6QtcEAOdroKyjwSP1zoQ56MLnzMwcJEHXal3TGs=; b=Y79tgZMn1OxcbaHPTa/wb4hVe2IVcnGrKDlnIPeHYOMNykJ1jDdY6xdXYR/uihRnQm o1thNjWcPzhjy4qF349n+n3EP8P0RxZpaahONH0/QtdCK8CCD6FrCzBKVt+qGFwPW55j CPj8s3NaLPHP91vpAMy7Nsj78jc850vHUYUrfHoekDW1c4/W32yP58rpirRUuMGIqziv CaoByviJ2g/1rS9vArxleH2uRMMTnB5vc7NT5tXv+3EgtlucfxLJuzhQhBVSccw0GtW1 5m8MHFFbZenwlhbDwvxSUk3LlT5dz0NpvAzGXx/6XC1nLLfCUuuT11cLQmYjW4VAKbCz 8Kng== X-Forwarded-Encrypted: i=1; AJvYcCW40qikekg0Qx6wqdDvwMEl6WuA0JduPIIZsO5Ar++L9xxoRXnHgiCjbtRtFNPvNvdwJdbwHVar2ECA0aY=@vger.kernel.org X-Gm-Message-State: AOJu0YyO/RpW+z4J/uU0RqYgKNoJoM0gsIUicXgN44Ypug9t7XmhwRfk 2DSSUvxnkGmc0Ax+HMK9yql5vbaSErz4UAUWtSRjEBoy1vBuEu7GUCuGqVUmCo6Z2eXzodWFaSP K+HY802uNsyKARv0RaSEohF5prGI25NNczGaNZlcgHE+OmzTMFNLUW5OE+heHlGgtAQ== X-Gm-Gg: AY/fxX7L4bJ5nFjNo1JBSLOHULkiMhpokboIVjeVF0uFUgP+ThbtXiJNGeqZXOIN7ck ZpgHLgs++lkkVsl+FtW4Gkeb/5PTWH062Z1EowjIKUoQ6W0kACpRtXdsqQszGYHoBg6ObYeRGJX jEpw4p2F/L2kdyWaPt+d49T9tG8DJtn2YpvpqZTASSfrkznoUB1SW/2f7XsLpxmFQvG4JEB/3Xv Vp54VfHkoXQuzUNlbV+sBEtVAAYfkyyld3rF8FaHSdzONnJxDZPcSMu3jeMIXXSNqbzfa170O9d 6phLe/++bghiYzwmLqnwukx/iDTJjf8xJXMueRV1xGqJwQ/zLUN+iIWLsDbpgcXOCEEBzne3Lph 4jJ7PvYaqwE5PQC+qX/Ay+C4eZbZPQE8tXjiQvU9i9yf0/s1gW52pcestjQqvUQ== X-Received: by 2002:a05:600c:8b82:b0:477:7b9a:bb07 with SMTP id 5b1f17b1804b1-47d84b5405amr219660085e9.35.1768229296678; Mon, 12 Jan 2026 06:48:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJzr4Y2fS6XgBSkiJLd05rWsmzsrdXz2PkPaLKrPstYswApqBsGl7lyU7UX/8hluUAjZao2w== X-Received: by 2002:a05:600c:8b82:b0:477:7b9a:bb07 with SMTP id 5b1f17b1804b1-47d84b5405amr219659855e9.35.1768229296265; Mon, 12 Jan 2026 06:48:16 -0800 (PST) Received: from sgarzare-redhat (host-87-12-25-233.business.telecomitalia.it. [87.12.25.233]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432dd78f5a8sm19136662f8f.27.2026.01.12.06.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 06:48:15 -0800 (PST) Date: Mon, 12 Jan 2026 15:48:11 +0100 From: Stefano Garzarella To: David Woodhouse Cc: Will Deacon , linux-kernel@vger.kernel.org, Keir Fraser , Steven Moreland , Frederick Mayle , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= , netdev@vger.kernel.org, virtualization@lists.linux.dev Subject: Re: [PATCH v4 4/9] vsock/virtio: Resize receive buffers so that each SKB fits in a 4K page Message-ID: References: <20250717090116.11987-1-will@kernel.org> <20250717090116.11987-5-will@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: On Thu, Jan 08, 2026 at 05:33:42PM +0100, David Woodhouse wrote: >On Thu, 2025-07-17 at 10:01 +0100, Will Deacon wrote: >> >> -#define VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE (1024 * 4) >> +/* Dimension the RX SKB so that the entire thing fits exactly into >> + * a single 4KiB page. This avoids wasting memory due to alloc_skb() >> + * rounding up to the next page order and also means that we >> + * don't leave higher-order pages sitting around in the RX queue. >> + */ >> +#define >> VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE SKB_WITH_OVERHEAD(1024 * 4) > >Should this be SKB_WITH_OVERHEAD()? ehm, is what the patch is doing, no? > >Or should it subtract VIRTIO_VSOCK_SKB_HEADROOM instead? Why? IIRC the goal of the patch was to have an SKB that fit entirely on one page, to avoid wasting memory, so yes, we are reducing the payload a little bit (4K vs 4K - VIRTIO_VSOCK_SKB_HEADROOM - SKB_OVERHEAD), but we are also reducing segmentation. > >(And also, I have use cases where I want to expand this to 64KiB. Can I >make it controllable with a sockopt? module param?) I'm not sure about sockopt, because this is really device specific and can't be linked to a specific socket, since the device will pre-fill the queue with buffers that can be assigned to different sockets. But yeah, perhaps a module parameter would suffice, provided that it can only be modified at load time, otherwise we would have to do something similar to NIC and ethtool, but I feel that would be too complicated for this use case. Thanks, Stefano