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 A5BED223328 for ; Fri, 26 Dec 2025 14:50:49 +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=1766760651; cv=none; b=hmsNG2/T/JOzuy6Fa3TPDzSmQ011LkBougRLTgk+LilMIUGRDWkMNOFOjlAIUHKsG8vr5RzCKr5DK+uKntOosAWjtqZj2OaX2gRMFIF5BPD104LY+UkHJ3Cqcz4cZgjUAFNsUD7GIXNlcIwK2dfAEhQEWAsFwD4Aa3Pzuk0T+6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766760651; c=relaxed/simple; bh=PKXRGzbxh1OlfF0T9/TV4KDNz94u0vtq7bXgSU6XVJs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QzBxXMMVaDS2DdUQr6lbXVQd/oSbpfYpNSyKHI2J273weaRJV6rAbCIDkvHneU53GA0iCir0CwZlES3+WaVYYlzUnipHq6UvY78Uc9vN582/6TznOXhLEnaKbIc7T29Hd6vdHd7JqaNY6c/tv6bMLSeJ6F/F+hQgJPTtbpuYpPc= 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=CHrXcZO7; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=hJvbHwa8; 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="CHrXcZO7"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="hJvbHwa8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766760648; 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=7KQs8vvsCuYX4f4WNDWRFaCkEzOPPZG4H4J2HYQGAcg=; b=CHrXcZO7g1OZrGMGrtGz8+3NIf6ND1ORNozb17srJKyzXdqNjU0eMEkQQnGMVxoY1x2vdc xNUnhAzpS9cfQ+58Nalzsajl2RrelVcLYX+7ViezoxSQVxjrVk//Ep0hGjC3sksicbDX9Y JTPVf389+0rZS/tSBIvxc95EvZb1WKc= 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-93-t352ZHLVNIWcHg6Mak076Q-1; Fri, 26 Dec 2025 09:50:44 -0500 X-MC-Unique: t352ZHLVNIWcHg6Mak076Q-1 X-Mimecast-MFC-AGG-ID: t352ZHLVNIWcHg6Mak076Q_1766760644 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42fb1c2c403so4674950f8f.3 for ; Fri, 26 Dec 2025 06:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766760643; x=1767365443; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=7KQs8vvsCuYX4f4WNDWRFaCkEzOPPZG4H4J2HYQGAcg=; b=hJvbHwa8799PBmwVOaM7bXW0c3KVddDUR7e4R5OuikJxn6hBT7RUWFohqIH9v1pPJy PY2MA8sxSPDrGBkZhaCbXBUUNx2N3o8N64d3qIALdKsFMCmUANXAGB9vaoVdMnx8nkFj vEInM1eG82QFqFO3d5BD0WBOIMvIokA0l5i/MOHhJH5FJmo66lH9NI0VroFuCNB8YDen fT11EuZ1T5obyw3DWWCTaju9c1j1GD9/SDNZwOnlRnBH33C4AEl4zV/BPJDgr0OWUF+Y yfkSmp7NipJkR3/pFUYj94LX/Op0Gd00oFylx7EucAsBiXjMCnIBSp0Jjw2aMUephgjo cQzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766760643; x=1767365443; h=in-reply-to:content-transfer-encoding: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=7KQs8vvsCuYX4f4WNDWRFaCkEzOPPZG4H4J2HYQGAcg=; b=UaYg80luKUHIjlJhrOr/6oxAMzosLD9x3r+z/FhfJGCR9s0GpDdk5UX++NUKbbOrgy rKI4Rdvi7OjcvBt3biy2SR/QbD4Rzb3jX0z/cUg6Sr0Isa4EbBtwn2F3DmtPzJtkTZCj 6x+E0SG7ZYczIimGBY4Zsk36UF9tSmSiZf7MbeKd66FEjeocA3+QMKhnMzzdPED8BunF skZRtqZZ9+2lJTz/S4QozoM33xkXhhGkhDQoGBLyHxtBme1q/AyBAgQnRqY2FUrq6UPj 0RO1pFSoaOKDpb+kRzag22s13Rnvdp1Q/YsgyZCP/6gPP387Ok4RcOaa9mwFekt9CXqU RBEA== X-Forwarded-Encrypted: i=1; AJvYcCU8v0BHk8DwBGN9gig49rywUQiXfjbG05Ahhk115qJDLc1CqE0LUwFgwx+kDc/CRU0qPNx0z50zQ/9sSrE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzo01Ytfaj1YEXc6I++wQ1UooyPM7lYiARUz6SUWAG3IXzIsPqg I6pXv9spJKfy39kNbwaMOkZDqVlyO3G+dqTmOmDh0Kjol8n+TBQnVExA01SRy/yHGRoTqSQqj1g cL1VId55f9UTxs63vi+S5vipbNOWHxsvD03otds+Euhx9GKZmL+WkjZGyjj6JecysYw== X-Gm-Gg: AY/fxX4gt/crbwsdILmI2SbEvPFavayZhm4m8NPXPT3Ch+b6/lBaLoqGWwR7fKlKG48 SbLIJvdHt/6kZovreFP1bb/S5+H4lSqn8eZxn2PWg7dtAPFsqfW+QOTpwf5UbTxC8N5VY4a1jKJ WCFDbyOrVOyvvyS83fo+Q4SwJv9gyuqC5qf8ilD/ViRDVfF4cG54ioAW4Hu5cgk6bEUyhRk05Sk AHEhp5rW9hYGDpdq2NQkrEKEOv/Hez8/U9+bU7fNbqn17YdUmzcc2Ql5GZA8deNe4LOwibhPOUF CQk3RKvl4rD8yI9b+h5TnRA0UHlzjBcTZWpwdLdMbRDA0Bo0zpqUzftzfkJxo22THRHvweztIoj YXKPV+/YqY3rzFI4fCQq0g/2pGwpL1Ps5kw== X-Received: by 2002:a5d:4e46:0:b0:430:fe22:5f1c with SMTP id ffacd0b85a97d-4324e703af5mr20129794f8f.59.1766760643535; Fri, 26 Dec 2025 06:50:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMQ5W8XwHXEz0VCwLYh7DYgtWB1N+w4NhUInEUeh59gqlc2IFDP3VMltMmESqxQ1YzyY8Evg== X-Received: by 2002:a5d:4e46:0:b0:430:fe22:5f1c with SMTP id ffacd0b85a97d-4324e703af5mr20129768f8f.59.1766760643060; Fri, 26 Dec 2025 06:50:43 -0800 (PST) Received: from redhat.com (IGLD-80-230-31-118.inter.net.il. [80.230.31.118]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324eaa46c0sm46411703f8f.34.2025.12.26.06.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Dec 2025 06:50:42 -0800 (PST) Date: Fri, 26 Dec 2025 09:50:39 -0500 From: "Michael S. Tsirkin" To: Jon Kohler Cc: Jason Wang , Eugenio =?iso-8859-1?Q?P=E9rez?= , "kvm@vger.kernel.org" , "virtualization@lists.linux.dev" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net-next] vhost/net: check peek_head_len after signal to guest to avoid delays Message-ID: <20251226094933-mutt-send-email-mst@kernel.org> References: <20251125180034.1167847-1-jon@nutanix.com> <20251125184936-mutt-send-email-mst@kernel.org> <4F24DF4D-7F5F-4BFC-B535-57C1AD66762D@nutanix.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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4F24DF4D-7F5F-4BFC-B535-57C1AD66762D@nutanix.com> On Wed, Nov 26, 2025 at 04:49:11PM +0000, Jon Kohler wrote: > > > > On Nov 25, 2025, at 6:50 PM, Michael S. Tsirkin wrote: > > > > !-------------------------------------------------------------------| > > CAUTION: External Email > > > > |-------------------------------------------------------------------! > > > > On Tue, Nov 25, 2025 at 11:00:33AM -0700, Jon Kohler wrote: > >> In non-busypoll handle_rx paths, if peek_head_len returns 0, the RX > >> loop breaks, the RX wait queue is re-enabled, and vhost_net_signal_used > >> is called to flush done_idx and notify the guest if needed. > >> > >> However, signaling the guest can take non-trivial time. During this > >> window, additional RX payloads may arrive on rx_ring without further > >> kicks. These new payloads will sit unprocessed until another kick > >> arrives, increasing latency. In high-rate UDP RX workloads, this was > >> observed to occur over 20k times per second. > >> > >> To minimize this window and improve opportunities to process packets > >> promptly, immediately call peek_head_len after signaling. If new packets > >> are found, treat it as a busy poll interrupt and requeue handle_rx, > >> improving fairness to TX handlers and other pending CPU work. This also > >> helps suppress unnecessary thread wakeups, reducing waker CPU demand. > >> > >> Signed-off-by: Jon Kohler > > > > Given this is supposed to be a performance improvement, > > pls include info on the effect this has on performance. Thanks! > > I had already mentioned we’re avoiding ~20k schedulers/IPIs in that > example, but I can add more detail. Let’s resolve the other parts of > the thread first and go from there? the discussion seems to have died down. I suggest reposting with perf data you have (which test, how much improvement, what cpu usage) collected in the commit log. thanks! > > > >> --- > >> drivers/vhost/net.c | 21 +++++++++++++++++++++ > >> 1 file changed, 21 insertions(+) > >> > >> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > >> index 35ded4330431..04cb5f1dc6e4 100644 > >> --- a/drivers/vhost/net.c > >> +++ b/drivers/vhost/net.c > >> @@ -1015,6 +1015,27 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk, > >> struct vhost_virtqueue *tvq = &tnvq->vq; > >> int len = peek_head_len(rnvq, sk); > >> > >> + if (!len && rnvq->done_idx) { > >> + /* When idle, flush signal first, which can take some > >> + * time for ring management and guest notification. > >> + * Afterwards, check one last time for work, as the ring > >> + * may have received new work during the notification > >> + * window. > >> + */ > >> + vhost_net_signal_used(rnvq, *count); > >> + *count = 0; > >> + if (peek_head_len(rnvq, sk)) { > >> + /* More work came in during the notification > >> + * window. To be fair to the TX handler and other > >> + * potentially pending work items, pretend like > >> + * this was a busy poll interruption so that > >> + * the RX handler will be rescheduled and try > >> + * again. > >> + */ > >> + *busyloop_intr = true; > >> + } > >> + } > >> + > >> if (!len && rvq->busyloop_timeout) { > >> /* Flush batched heads first */ > >> vhost_net_signal_used(rnvq, *count); > >> -- > >> 2.43.0 > > >