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.129.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 A73903ACF07 for ; Tue, 12 May 2026 11:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778584683; cv=none; b=EXk5ByOk7ExzPijll5EWr6TdcDnYHMNHkhH/3c9zfc8iPTLf7MduRWkAe6MVcmmPkiBzbLaGQ5oWreKIQQFWLJSQv5X+F9b0fU3/Q7Llzh8xdCYnDOU86DsQHnUEEtUCENm6icr49MO9sCc5Ej76IqaS0KU3BLQZnnww7Eag3sM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778584683; c=relaxed/simple; bh=3pilreO7Jxj4wUh3RXkY1+6fibHwDc1PkYQ0dqDnEg8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ufzmQdID1zNvBzQVWNvL98650s59mk4CCJsUUxFHBRF6Hwn6c0k//WOew9EHrOZh8jSzvd/FdEGKYZBkoWwC0cumKM++/wj712MzlUj85tDNBY5c8pFkJBnmkvfR2dd/A71Au5DUnaTtkr/KlDF7Fij+lmNYuKR0piI0wPPq2iA= 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=jBAvkLU2; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=fRuX/FN6; arc=none smtp.client-ip=170.10.129.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="jBAvkLU2"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="fRuX/FN6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778584680; 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=eZVeaoeGQMUpM7eRCOoBsTgdkpWc0LAFF4999VoUN0k=; b=jBAvkLU2Iup9kO1Z2nvhy+d6NZJj/gyve01FmKWU6HKJ2EgOVbn2P7clbLHzthjsE+7qlO SumMIuJaTFQPMA7BnwyqepJ1nFetxk8yqly2PMwmw5k+vrX/8VDk+QI06tdD7ZbnqvQC5N xJaQfAyJT4ma9PF5nWPCOVOgvi8YdYA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-0wz0A7KTOGOh-jJc6kv71w-1; Tue, 12 May 2026 07:17:59 -0400 X-MC-Unique: 0wz0A7KTOGOh-jJc6kv71w-1 X-Mimecast-MFC-AGG-ID: 0wz0A7KTOGOh-jJc6kv71w_1778584678 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-48a589c7879so49010925e9.1 for ; Tue, 12 May 2026 04:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778584678; x=1779189478; 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=eZVeaoeGQMUpM7eRCOoBsTgdkpWc0LAFF4999VoUN0k=; b=fRuX/FN6dm1C0Ye5oQwmlUqlEQEwx8xz3DrkfMms55t6vKjxQHnQ/FWUSH8OuJDu5H UbmgSKwuTPHteKN0LRKiNbRwKEr2u1ltkKOcpEOjnHqI50i0WxgW3OqZSVexGdbCDla/ aA/Jom1jsqTrftAQipTz9t8gASuO+dxJ2JRDU5CKa2g8rHFmWXR9lJJwX9ku0pee0E7c 6aKLNHac6hiYlFRFwHt4EMRS83p24An5OfSwmOImKndlBoVot+S7WA4TEqu/Gx5lt17y vbR4OBrVdMnWJwYfOJK8+QNbw3fRY3fx0Qpty58z7I3eauiszpeWy6XUIJ82V+6VEDvS vt7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778584678; x=1779189478; 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=eZVeaoeGQMUpM7eRCOoBsTgdkpWc0LAFF4999VoUN0k=; b=PqEzH2YlI3damwTiKcGSWldVrYzqt+MdPmvtjIhXlWNGWP7pZHcErz9dZ7ocqB+vOK iTHxyNm5YkAOOINKKWH5Y8fkrNuJxzx8C8fvviOECJ5BzSGrFUzwH6kzBBQ4dfhSaEwk aaocQ36r7Ii29rfitWv9LtgD93TMGXVh/aAqFiXqnKR9hrUigSeadju63xXDqUdVJh/O Oqsvgi6q4GwlhKMTVXwXOVaCdv2E20QXdhRnOlWK40y81Z7tnBqMaLLFilG47TvUA2Kn /4orDQ9x3JDxGNITVQUFYanlXt4yZ4ivdF7KPMbsR4gSpOote+kr7sykt0OmRDi9WZ7T tsaA== X-Forwarded-Encrypted: i=1; AFNElJ8nRBMqGf7VV0ng56qACbH89ig1BI1iF+P+QVMRnlmp5HS+N91KPDQGvdTQxlMbIsCwzBYHE+IfXZtXj4U=@vger.kernel.org X-Gm-Message-State: AOJu0YyHpmDaNRcaoQNYlO1TBxqHVwzgsj2jguPRHSPRaj1AtsQ/Uub2 6l7wwxVKdr64xJ9LcRRQYyA8eQZRmxjtJBPXlf4VT7WoUiKhbUcbs3YVZt3rxEdA/xcrkw80uvK mcKoIHXBrFw697AbIix4RW7/lQj7AfboSb7tyMbvyAm4sQUDAiMdjP7tbQUBhBasvfQ== X-Gm-Gg: Acq92OH0VdhHKHsP1HZuOp3fmZOsEf339rDDlqx3iCWWcgtXm9v1W8k6HZQN/9yn0dY CATP4AlKVhNhCF8IMvnztdqn7FjH0lsx0TTVKPSE8dCgXh5GK+9ezVoG0RZkTDYS7dkOWAzbsjc qKPCDwR+hNX0XNVYmOYXkHyFsrZOS0SbO/Rh5MPB8eDb+5a/n+vkfRwRMP2IK68gTpQ1G0E1uRx GQLeYBFjZEawyLRjv664Mbj+2Wo7dcUl3Z6SPMLMlNleKihjMFhnyissmmbhDfuKRhIAuV7bl8v Vo08c/XEAx2I8H8pv8bwh5lGkkoLo/y/IrGZY1fYGqPUE3qdfKUShOe9CdI+vJSMby+0eTs0p+7 C6g9ZJJVdO2kR1DhErTzbaF/BNn9H/o6SxVV/YHFG X-Received: by 2002:a05:600c:c167:b0:48a:761:5816 with SMTP id 5b1f17b1804b1-48e8e207f2bmr53750775e9.8.1778584677962; Tue, 12 May 2026 04:17:57 -0700 (PDT) X-Received: by 2002:a05:600c:c167:b0:48a:761:5816 with SMTP id 5b1f17b1804b1-48e8e207f2bmr53750065e9.8.1778584677428; Tue, 12 May 2026 04:17:57 -0700 (PDT) Received: from redhat.com (IGLD-80-230-48-7.inter.net.il. [80.230.48.7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e8f3c65f2sm26866475e9.1.2026.05.12.04.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 04:17:56 -0700 (PDT) Date: Tue, 12 May 2026 07:17:53 -0400 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: netdev@vger.kernel.org, Paolo Abeni , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Eric Dumazet , "David S. Miller" , kvm@vger.kernel.org, Jason Wang , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, Simon Horman , Jakub Kicinski , Stefan Hajnoczi Subject: Re: [PATCH net v2] vsock/virtio: fix skb overhead accounting to preserve full buf_alloc Message-ID: <20260512071726-mutt-send-email-mst@kernel.org> References: <20260512080737.36787-1-sgarzare@redhat.com> <20260512044008-mutt-send-email-mst@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 Content-Disposition: inline In-Reply-To: On Tue, May 12, 2026 at 12:03:38PM +0200, Stefano Garzarella wrote: > On Tue, May 12, 2026 at 04:54:34AM -0400, Michael S. Tsirkin wrote: > > On Tue, May 12, 2026 at 10:07:37AM +0200, Stefano Garzarella wrote: > > > From: Stefano Garzarella > > > > > > After commit 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb > > > queue"), virtio_transport_inc_rx_pkt() subtracts per-skb overhead from > > > buf_alloc when checking whether a new packet fits. This reduces the > > > effective receive buffer below what the user configured via > > > SO_VM_SOCKETS_BUFFER_SIZE, causing legitimate data packets to be > > > silently dropped and applications that rely on the full buffer size > > > to deadlock. > > > > > > Also, the reduced space is not communicated to the remote peer, so > > > its credit calculation accounts more credit than the receiver will > > > actually accept, causing data loss (there is no retransmission). > > > > > > With this approach we currently have failures in > > > tools/testing/vsock/vsock_test.c. Test 18 sometimes fails, while > > > test 22 always fails in this way: > > > 18 - SOCK_STREAM MSG_ZEROCOPY...hash mismatch > > > > > > 22 - SOCK_STREAM virtio credit update + SO_RCVLOWAT...send failed: > > > Resource temporarily unavailable > > > > > > Fix this by using `buf_alloc * 2` as the total budget for payload plus > > > skb overhead in virtio_transport_inc_rx_pkt(), similar to how SO_RCVBUF > > > is doubled to reserve space for sk_buff metadata. This preserves the > > > full buf_alloc for payload under normal operation, while still bounding > > > the skb queue growth. > > > > > > When the total budget (buf_alloc * 2) is exceeded (e.g. under small-packet > > > flooding where overhead dominates), the connection is reset and local > > > socket error set to ENOBUFS, so both peers are explicitly notified of > > > the failure rather than silently losing data. > > > > > > With this patch, all tests in tools/testing/vsock/vsock_test.c are > > > now passing again. > > > > > > A solution to handle small-packet overhead efficiently also for > > > SEQPACKET (we already do that for STREAM) is planned as follow-up work. > > > This patch is needed in any case to prevent silent data loss, because > > > even if we reduce the overhead, we can't eliminate it entirely. > > > > > > Fixes: 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb queue") > > > Signed-off-by: Stefano Garzarella > > > > Thanks for the patch! I'd like to split this: > > 1. buf alloc boost > > 2. reset when out of credits > > Good point, also the reset maybe should have an other fixes tag (i.e. when > we introduced that check) > > > > > this way we can revert 2 easier later. > > I'm not sure if we should revert them at some point, even though we'll be > able to handle the overhead better, I mean we'll prevent the overflow, the condition will never be met. > but I agree that we should split them. > > I'll wait for a few more comments and then send v3 with the split. > > Thanks, > Stefano