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 1E29A2836B0 for ; Sat, 14 Feb 2026 23:49: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=1771112991; cv=none; b=N66j7wo7O8k5CyKT5uCz4j0OyPzynep5Dsc3Wkab8kOftvJtXJ6oFVUFVKu4qj/V/XdCWAUSNOcA4FsJmHk/2KX/3gI1iEqOrtMTGPMuW0OYrXWdGha8lWjm1Kvmjqrcs3bWVjflvM1lhZIplpL+Ma8i15NpLJyb/MmH4gnVi6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771112991; c=relaxed/simple; bh=0teZB9CPEF5sbUbIUadXWlFPJ6ba1v4ykNaYGomwB0A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eQLsmAh0WG3GYsfUNhkt0RWjnHesygcajcgTlYWmiVouXvs++sGMUMh53UzsnrfXiHyH321sguvbcKuc29jarqHxIyjp7qaw94Yai01kW81tv2Mb6TPLVrjfdvztqpxGskwvWPsRV9cx8d9tB/k+JiGQtrfZ83A/SkLoHa0Q1yU= 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=UCSwp0pa; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=CF0AnH5A; 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="UCSwp0pa"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="CF0AnH5A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771112989; 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=oa/MMBMnbn+u985OU8+Ei4K9m3xtsJNKiEfMcHtZPG4=; b=UCSwp0pan/TKJosNZiXpVaj96v1p/09BOyWqUSwG58Lf9nVKI+MR864lhl5Ae6a0F/5+J6 G7CWgt0EfYgjoz2PV8zdzd8w61H3I639H9vysiiEUesh2BS+yEGax1ZXE12moqfyU6it7J Edqg9xfKlGwCQSGk5Il9NBwKOWQVli8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-vo7m8cTTMfmgwmz82Dd42Q-1; Sat, 14 Feb 2026 18:49:47 -0500 X-MC-Unique: vo7m8cTTMfmgwmz82Dd42Q-1 X-Mimecast-MFC-AGG-ID: vo7m8cTTMfmgwmz82Dd42Q_1771112987 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4837c597cd5so3774125e9.3 for ; Sat, 14 Feb 2026 15:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1771112987; x=1771717787; 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=oa/MMBMnbn+u985OU8+Ei4K9m3xtsJNKiEfMcHtZPG4=; b=CF0AnH5AUP0R1xe/ElFNWYgcqJzKytgNOJpYqhZJDmEuMG4rfLWHLDfi9lqMAHajKm +4reg57aA0a/+R/jrOFY0lYRP9rnS8wwDMQstNxVGhiKqZMjTk6LbtGs2IID6+XUcHss zBanLR8qpa2nClSoU0fNFSh8Zz8zGdlLlTxgv5lkXvf1TpdiaFlHOb4rgS91RPKBjpWT ey1BuyJuqYqJNOB0MVheuNvfdbg7GMDVH4YJfVSuBkPDb1lIEVfm3GuTqtbz7JuX9JuC 8R/0g9UfMTQmavqwPK2n1bDwcjp0TW2MU1N9U4/m68Jytt9YCBnSfbw6wlUAY4LOnL+n jR9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771112987; x=1771717787; 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=oa/MMBMnbn+u985OU8+Ei4K9m3xtsJNKiEfMcHtZPG4=; b=GTH3R3MhMfOrZMW00JbjPfW4Wm/e+HPWc5Enh/ZRXD9kohoDAUBmbB6B0MiVrmG4LW QkLBsqGPt/O0st5TdRCh0bpPbiHAe5RWSr8/uyih6wJ9//70NsX2gPrMWM4OLchxuiIe xChcc/gW8I4SKXdqjXZNTm1UxUUcBoulHe3etXNSbtgItJf4+eSI7/ZhFV9YYG9pI0XC sCaOnx0/4HTChpDjek9tA/EkZu6iAXCx0yvEs05Zu4N5cMfunmEQrjGMTPrUXBDF1Q5T Yz9yb2XxT//2EH/UxwSI1KRSk/GLHZFwjdyz/y1XsEcEkvkRYNC9VVzB5wHRun+QSIUW IWPQ== X-Forwarded-Encrypted: i=1; AJvYcCXyUltEw1v7ciZX2ZVciabvrd+XrqJposQ9vBVo7jrxqwQ3TRNN5Nw9KhxpNCqfAHEyEXT7XGGfrW313q0=@vger.kernel.org X-Gm-Message-State: AOJu0YwGeWHX04sl2slcTDNEUbKJbEl5ziH5oQiTzbV4ucCWKwwxC5qE PwR4+59y/B3yg6qTFuTxXGKRXpuG/G7+P4vANq7xT/96nnsdPAvbL1eW9B1BhCli/GgCmflEMbf 2VjmSmjJNsGspi0BPDupdiJFXFmEpxst+bxYhfRjKggZ5elQw9FBEi6PvBeDz/mOdPg== X-Gm-Gg: AZuq6aJwwJtTj35e5ftadFzg6SIMnJwG9BB6OFH+VezLPu6jfUnlWh450LDKEJ8hMaa OsPeUNzR9ecAS8K11O4nU4/ipvvrkeJF2dbd2g7GPjRT2TKNo6ba+vQO0J88GEkErgu1/1MSAbD x25jpedgEbu180S1r4t28VR2aCmCsyNP7oveHnWnZYh2Xff48Bhg6uL7oF0meqK8FZfVzdqP3Nh 4AVPX6/hqb4v69G1jG3sHnlbil6O348qyNvwlvV/1bv+fcDs/Sqb2ueOCEJ/HHXNFlQlygte3Id WTGA2h4dWCVORG2IAy0qGDVNYayaoauxLfeMc+n64FJrYP4F0QY94cKmFw/qRe1lD6sgpc1a9z8 LJFS1VjMWEpR5jLsH7b87zr1Wyc17xmOXU1GQBDWbu0cTnA== X-Received: by 2002:a05:600c:818c:b0:47b:e2a9:2bd7 with SMTP id 5b1f17b1804b1-48373a5d230mr97085865e9.19.1771112986593; Sat, 14 Feb 2026 15:49:46 -0800 (PST) X-Received: by 2002:a05:600c:818c:b0:47b:e2a9:2bd7 with SMTP id 5b1f17b1804b1-48373a5d230mr97085445e9.19.1771112986103; Sat, 14 Feb 2026 15:49:46 -0800 (PST) Received: from redhat.com (IGLD-80-230-34-155.inter.net.il. [80.230.34.155]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a6b563sm16099143f8f.12.2026.02.14.15.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Feb 2026 15:49:45 -0800 (PST) Date: Sat, 14 Feb 2026 18:49:42 -0500 From: "Michael S. Tsirkin" To: Simon Schippers Cc: Jason Wang , willemdebruijn.kernel@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, eperezma@redhat.com, leiyang@redhat.com, stephen@networkplumber.org, jon@nutanix.com, tim.gebauer@tu-dortmund.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev Subject: Re: [PATCH net-next v7 3/9] tun/tap: add ptr_ring consume helper with netdev queue wakeup Message-ID: <20260214184851-mutt-send-email-mst@kernel.org> References: <197573a1-df52-4928-adb9-55a7a4f78839@tu-dortmund.de> <0c776172-2f02-47fc-babf-2871adca42cb@tu-dortmund.de> <205aa139-975d-4092-aa04-a2c570ae43a6@tu-dortmund.de> <59529fd2-2a08-4a89-a853-27198b76f842@tu-dortmund.de> <20260214131703-mutt-send-email-mst@kernel.org> <1ab166aa-8e9c-4742-a80a-c2fa806218db@tu-dortmund.de> 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: <1ab166aa-8e9c-4742-a80a-c2fa806218db@tu-dortmund.de> On Sat, Feb 14, 2026 at 08:51:53PM +0100, Simon Schippers wrote: > On 2/14/26 19:18, Michael S. Tsirkin wrote: > > On Sat, Feb 14, 2026 at 06:13:14PM +0100, Simon Schippers wrote: > > > > ... > > > >> Patched: Waking on __ptr_ring_produce_created_space() is too early. The > >> stop/wake cycle occurs too frequently which slows down > >> performance as can be seen for TAP. > >> > >> Wake on empty variant: Waking on __ptr_ring_empty() is (slightly) too > >> late. The consumer starves because the producer > >> first has to produce packets again. This slows > >> down performance aswell as can be seen for TAP > >> and TAP+vhost-net (both down ~30-40Kpps). > >> > >> I think something inbetween should be used. > >> The wake should be done as late as possible to have as few > >> NET_TX_SOFTIRQs as possible but early enough that there are still > >> consumable packets remaining to not starve the consumer. > >> > >> However, I can not think of a proper way to implement this right now. > >> > >> Thanks! > > > > What is the difficulty? > > There is no way to tell how many entries are currently in the ring. > > > > > Your patches check __ptr_ring_consume_created_space(..., 1). > > Yes, and this returns if either 0 space or a batch size space was > created. > (In the current implementation it would be false or true, but as > discussed earlier this can be changed.) > > > > > How about __ptr_ring_consume_created_space(..., 8) then? 16? > > > > This would return how much space the last 8/16 consume operations > created. But in tap_ring_consume() we only consume a single entry. > > Maybe we could avoid __ptr_ring_consume_created_space with this: > 1. Wait for the queue to stop with netif_tx_queue_stopped() > 2. Then count the numbers of consumes we did after the queue stopped > 3. Wake the queue if count >= threshold with threshold >= ring->batch > > I would say that such a threshold could be something like ring->size/2. OK