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 1431442B332 for ; Wed, 8 Jul 2026 10:59:51 +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=1783508398; cv=none; b=BE2D6pYzkwQzOp5OotYY+a2u17P6o719SIYiL/v5UtSHKzBpBAZiLKIY9Bdn/6lYx0dOiQB2HPsHTqslK4ACLMhuQQzDqmerJmvaug2LzkpW6TfA70wQ0ANPBGLCl/kViTOXHd9eGXnjefKVjWoHDLSMlZRElcodimHrY0prhUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783508398; c=relaxed/simple; bh=Wxh1h5TWAdT1dv/JQYXllO6752pAMRojLLF30bzxwcE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Auw3UMzhG5+1LphvoY93nvhmmr+pQnIOU4QNyZ7JkNnlWXs7cJEWQPy/Sbwd5M3HAcvrPNRWuf/XiwFUGS+FfJ+XsKHD1oJPGwqD1gpV5a9QrlktxNmGuyAPzRP26sR1xMy8ulzfZ0h37FoOu0hkNoOeDGH3fwl90eYCNk7PDSY= 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=fSIgkP4a; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=U43iV86f; 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="fSIgkP4a"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="U43iV86f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783508388; 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=6E0ixpEMrHT9a5crJiV6RHWP5trgVnT1h9yDneEUY78=; b=fSIgkP4aB8vRI30T8/D1IVgLDQMg6UJqNGmESanK4fH0qws8UEKVIfwGBMmTBnmHqstjvg GJz/YUzukx5WzVeKEEVnQxjmjelT5/6q38jJ3UB91pbDQ0jdT0GuIvTBQJKj02Em0H+e/I 4XpsKnuzjanPWBwPABMAXzyQZmtZfUA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-8OV4RI_ENJa1i6yQqMU8yQ-1; Wed, 08 Jul 2026 06:59:46 -0400 X-MC-Unique: 8OV4RI_ENJa1i6yQqMU8yQ-1 X-Mimecast-MFC-AGG-ID: 8OV4RI_ENJa1i6yQqMU8yQ_1783508385 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-47345535410so875352f8f.1 for ; Wed, 08 Jul 2026 03:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783508385; x=1784113185; 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=6E0ixpEMrHT9a5crJiV6RHWP5trgVnT1h9yDneEUY78=; b=U43iV86fQCWGaoUI/WbpgRWUHK8p0DDASayl+U6HMl3tGqxvancJNoM0c599lEZw9L 20rXFVd7Le8jtiCtOTnNoF2ec0xRqSep8iJM5MBAfHPsSVuD/vxEY291bip7esSQ80U3 MRO/J9rVE8PwfMgvW1wvC0GIQ1Eucn+57cmgJ9wxkTO5aJ6eUcRm0TBZVNaaBtZi+hP2 f50H7ZEqCXlnufZgQUeK67RWMPp1f8Q8zFJjdRu4Fumh88QjBpFzlWeLzbU16TL2r31N 1VhKcCdBca0ciN0ndeoB+BoJTR1er/q7Oo3VPGfPOxEdDg7eiMZz7dqFU8YXlilHRLbQ HYlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783508385; x=1784113185; 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=6E0ixpEMrHT9a5crJiV6RHWP5trgVnT1h9yDneEUY78=; b=U0ZnotaecBLr6nzbQIBW4v+VpDE7YN3v8fuhRxz/DI31ttZWqrM4MfukGeEEs0IlD6 DFX81WXwEDq5wIeoa20jXjQA2fITzf7UnxhxCmQBkPeclhzHy1YCEP/NyPg+7A862y8F uBxRTWCBNON1uToJg+E43wTiyamghreRUhJjgxEDlvtknWPeHmo4oPyUiQ2Gs2D7DPRt 8N5ggKSgt84g9E/UkgxKeIlXl5tHLUtZT+B/k+Es96EjZIl4Pv0qfbtMsroYPQcZIlMn yu8XC4YWslLr8fVhtV5EHzx5zmmflL2abv6q96I3uzbxvLlFOkeO/1aswoCaWDR9n7OU BRUw== X-Forwarded-Encrypted: i=1; AHgh+Rqr3E2a7CBK5vw/636OHosgUzzUTmfEzaChBJOb3EAWJLvMuT6i3H/n8GYte096YN1tqH/hiGyQv2HcKag=@vger.kernel.org X-Gm-Message-State: AOJu0YwVCA18X9WsUrxhbbCz7M+RfegOv/Y30yx6fQw1J1xEX412LHCu gd3ObhHHY/O3vLK9Xpj330hDC9CTyMFkNby6kFOAY8yb6pVz0iQEfIrjj2SkWBlybAiBXFIrY1H QK2TCGVEeRYhWBgObEzAWMPJsm5ERstPhg6lcsL5v4Exg9gPeobTJGauqczRQxdouTQ== X-Gm-Gg: AfdE7cn2VNttd4YCrfjaa/SgT6iXtyirWGLrFiYmOVMUDfbDMlusbhy7nAl0clGIvXZ grbL7l97+lm7C3P9JwCbYvMNN6HHS7b3gKrj6zZg7/zE8ODr2f2CkzoHdI7MLh7KcsR0b2ngSHS xZy11FEzv8j6jV2h+oLsm8ADcIEJObX8tRZQJrne12n78Mt8TV60DK5nA23ZdFtVXWfeEqLMsrE dLSZmFZFdMUJ40ZIGDe67WMlgGMdVBHLnVbfwEPnQW0CVoUG4P2sO6y01PkgrdkXmz2GCUot1CR q2c+UfzbxHdLDHmDuIFxSC4NWpV1witNFuEJGm8PZdYI0sh0yhlqpu3lEM6yXjunt63JsyijtlA fXfoMF4MGjSEvQEptgdeRn8P5Tuu3sMhA X-Received: by 2002:a5d:5f42:0:b0:475:5e4b:588f with SMTP id ffacd0b85a97d-47df075a119mr2128507f8f.16.1783508385271; Wed, 08 Jul 2026 03:59:45 -0700 (PDT) X-Received: by 2002:a5d:5f42:0:b0:475:5e4b:588f with SMTP id ffacd0b85a97d-47df075a119mr2128475f8f.16.1783508384801; Wed, 08 Jul 2026 03:59:44 -0700 (PDT) Received: from redhat.com (IGLD-80-230-68-31.inter.net.il. [80.230.68.31]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9de1d905sm43295235f8f.2.2026.07.08.03.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 03:59:44 -0700 (PDT) Date: Wed, 8 Jul 2026 06:59:41 -0400 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: netdev@vger.kernel.org, Jason Wang , Xuan Zhuo , Eric Dumazet , Eugenio =?iso-8859-1?Q?P=E9rez?= , Simon Horman , Stefan Hajnoczi , "David S. Miller" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Abeni , virtualization@lists.linux.dev, Jakub Kicinski , Jason Wang Subject: Re: [PATCH net v2 2/2] vsock/test: add test for small packets under pressure Message-ID: <20260708065853-mutt-send-email-mst@kernel.org> References: <20260708102904.50732-1-sgarzare@redhat.com> <20260708102904.50732-3-sgarzare@redhat.com> 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: <20260708102904.50732-3-sgarzare@redhat.com> On Wed, Jul 08, 2026 at 12:29:04PM +0200, Stefano Garzarella wrote: > From: Stefano Garzarella > > Add a test that sends 2 MB of data using randomly sized small packets > (129-512 bytes) over a SOCK_STREAM connection. Packets above > GOOD_COPY_LEN (128) bypass the in-place coalescing in recv_enqueue(), > forcing each one into its own skb. > > Without receive queue collapsing, the per-skb overhead eventually > exceeds buf_alloc and the connection is reset. The test verifies > that all data arrives and that content integrity is preserved. > > Signed-off-by: Stefano Garzarella maybe cut down SO_VM_SOCKETS_BUFFER_SIZE? will make it easier to trigger? anyway Acked-by: Michael S. Tsirkin > --- > tools/testing/vsock/vsock_test.c | 87 ++++++++++++++++++++++++++++++++ > 1 file changed, 87 insertions(+) > > diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c > index 76be0e4a7f0e..b4ff9f946565 100644 > --- a/tools/testing/vsock/vsock_test.c > +++ b/tools/testing/vsock/vsock_test.c > @@ -2347,6 +2347,88 @@ static void test_stream_tx_credit_bounds_server(const struct test_opts *opts) > close(fd); > } > > +/* Test that many small packets don't cause a connection reset under pressure > + * and that data integrity is preserved. Packet sizes vary randomly between > + * 129 and 512 bytes, above GOOD_COPY_LEN (128) to bypass in-place coalescing > + * in recv_enqueue, forcing each one into its own skb. Without receive queue > + * collapsing, the per-skb overhead eventually exceeds buf_alloc and the > + * connection is reset. > + */ > +#define COLLAPSE_PKT_MIN 129 > +#define COLLAPSE_PKT_MAX 512 > +#define COLLAPSE_TOTAL (2 * 1024 * 1024) > + > +static void test_stream_collapse_client(const struct test_opts *opts) > +{ > + unsigned char *data; > + unsigned long hash; > + size_t offset = 0; > + int i, fd; > + > + data = malloc(COLLAPSE_TOTAL); > + if (!data) { > + perror("malloc"); > + exit(EXIT_FAILURE); > + } > + > + for (i = 0; i < COLLAPSE_TOTAL; i++) > + data[i] = rand() & 0xff; > + > + fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); > + if (fd < 0) { > + perror("connect"); > + exit(EXIT_FAILURE); > + } > + > + while (offset < COLLAPSE_TOTAL) { > + size_t pkt_size = COLLAPSE_PKT_MIN + > + rand() % (COLLAPSE_PKT_MAX - COLLAPSE_PKT_MIN + 1); > + > + pkt_size = min(pkt_size, COLLAPSE_TOTAL - offset); > + > + send_buf(fd, data + offset, pkt_size, 0, pkt_size); > + offset += pkt_size; > + } > + > + hash = hash_djb2(data, COLLAPSE_TOTAL); > + control_writeulong(hash); > + > + free(data); > + close(fd); > +} > + > +static void test_stream_collapse_server(const struct test_opts *opts) > +{ > + unsigned long hash, remote_hash; > + unsigned char *data; > + int fd; > + > + data = malloc(COLLAPSE_TOTAL); > + if (!data) { > + perror("malloc"); > + exit(EXIT_FAILURE); > + } > + > + fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); > + if (fd < 0) { > + perror("accept"); > + exit(EXIT_FAILURE); > + } > + > + recv_buf(fd, data, COLLAPSE_TOTAL, 0, COLLAPSE_TOTAL); > + > + hash = hash_djb2(data, COLLAPSE_TOTAL); > + remote_hash = control_readulong(); > + if (hash != remote_hash) { > + fprintf(stderr, "hash mismatch: local %lu remote %lu\n", > + hash, remote_hash); > + exit(EXIT_FAILURE); > + } > + > + free(data); > + close(fd); > +} > + > static struct test_case test_cases[] = { > { > .name = "SOCK_STREAM connection reset", > @@ -2546,6 +2628,11 @@ static struct test_case test_cases[] = { > .run_client = test_stream_msg_peek_client, > .run_server = test_stream_peek_after_recv_server, > }, > + { > + .name = "SOCK_STREAM small packets backpressure", > + .run_client = test_stream_collapse_client, > + .run_server = test_stream_collapse_server, > + }, > {}, > }; > > -- > 2.55.0