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 77EF8285CB9 for ; Sun, 15 Feb 2026 10:39:04 +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=1771151945; cv=none; b=RAgrVOycLymDgc2/yKWVuhoPEKQNNS6h1zzB6EXSXX/w74t9ZZPqMK+E34/APZR7FuTujrwdSeIijO8fBKatV9U0vEimzKhX51jjd1ooH1O4eKMJ2YdAyOvNbeg+mHIitKX6dVlo3n5A2LaCX6styypJpCsAzT37Eb4OGEb9xYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771151945; c=relaxed/simple; bh=s0Gz1lbX6oWHaXjniFNDuQXFzRewjGHyGyA3SEPcAvc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P8lw1d2ktN0jcq7i3wfSLQma70fg12qi6O14QUwzdqDpguRf5VoHAh88HIMHLPk9ckcuImOD3qqqJqNUeJJN487rQ4DuP1qMp6HrWxnRTnxg6o++MnEiMyw+bmGAChDsb4ALaXXJG8EfhiJqmz0JkCKHk3dtIW7739bBqPQlNpA= 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=ZFztg3Ui; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=IcH2trGG; 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="ZFztg3Ui"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="IcH2trGG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771151943; 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=OaK+6zMcYsiCWtoK8iSxqAKGi6QUUb+Bn/H6Es8PiBw=; b=ZFztg3UiRYdFfJXbeFjUZxd0Qs/UNBZ4HXWrIwC1N+VzUkYEDctO/G90819GpWCEZWMGHe ktw+BM1vx2hO2m9dx8ypX85EaZIj4CcPRkKxWOkRk9ZTX0ogo5S3I/dXsSeH7qmaV6kQ9E yfUz6tlGAS2P8exkQ4nfVTnrl7pI2uk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-q4JxoF_5P-CbumjAkN9Ydw-1; Sun, 15 Feb 2026 05:39:01 -0500 X-MC-Unique: q4JxoF_5P-CbumjAkN9Ydw-1 X-Mimecast-MFC-AGG-ID: q4JxoF_5P-CbumjAkN9Ydw_1771151940 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-437159d3ff2so2643943f8f.1 for ; Sun, 15 Feb 2026 02:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1771151940; x=1771756740; 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=OaK+6zMcYsiCWtoK8iSxqAKGi6QUUb+Bn/H6Es8PiBw=; b=IcH2trGGVaOayp9/6bklHqS5tNfKvUpNMZjjbYTFwXtRaLHOeY3ouk+taFEJvV9Vie wauenIrpUFF4UD2eL5dmZ579ZUs/39oRhvWV2olcq6pmHV0hwGRCTAPfHE4aSsqzR2Ug tXFTTi3X+ri4k6dUIDGh3YU0LFFd1bsZ5PQSIIVNZMKd7W6ybjTHdNYiawZZt7slHTma QIZpvB5umd6qRLoJe6vyAWHg0Biaet5wNyPy9h24KsnoT/a840xvxTSeQriVOAKlFCI0 s4DdpN70QHeE24wOzjt2LFtbZpYiU3/68JWmeCg6fVpBTgA5JeI1vMYYiwYJPYXTZbSJ Mbqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771151940; x=1771756740; 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=OaK+6zMcYsiCWtoK8iSxqAKGi6QUUb+Bn/H6Es8PiBw=; b=kOlpr1o1oN8//tTGem84ig7uLSEfDLoAhmClKE6XvTkjsYoxbltS+0utyxySs3wAwG 2kiRsVLoJPXB1vjlx1rd5OPi1V7sm6pcq3GdgGnsXTrxHcxBOuEbw9rqCANn74JctVo9 jYqqES/bRQpq+qRUf14ygEqCrHoLlKIOZYtVJliknmf5d1nGv6cB5ZmlIQWJtviuRj0v tzESCB91be37ERvEs6ItOSSYImvofcckafDLzoUk6ZTT4WxZPm9vyVKcUZD8MvsSgEt1 ft2b+K3aLBWxo00ohkNijV8NVAar87hF++x57e7s+75XlLD6z0v4YOfSfG079/bvwZ28 rIJg== X-Forwarded-Encrypted: i=1; AJvYcCUMVZ/l56UtgtzopHDln0RtFDzdJkOMbhU169j7YWaOxC4rmP0N9lY2W0TS/xjWg4d3FXXD0tQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyKZF7oyuYU6wvh90FpvMLvJrlmAOnygR3ws+L/404p8ZT+pIIq 8JGcfFlvkmI2hPmBQIk03dZZxQI/MODwXaob2kjzhWG9ZB+x7p9ArVUXR5Mc4JzICB/VD+rYk5n tiasyw2zOChDZLxQSNPLM9itFJdCNp/NkvbHxpKUVCzAzANUWm+eu4fqm7Q== X-Gm-Gg: AZuq6aIHwIAejvLPWrpp8bdCUJSMiZHKRMfZRmopJkfAhMz9Fl7aWNSetJv5ggCBUa5 FhcY1zuU+iCR4FgSQGexGiyyGmIeAp83M5Pd7tGJeHPIiOBgOzCQAKGuWRj6mOl+hg44uVcCJRp I/AsILrON0qL8Tf2XkJID9Yj20dca/dDs7pqCoKSFUhze6aIfjmJtknHP8c/iuKZdey6ntLvVxY v7zrIkpR3P6pFPmyNHrfSrtp0H3HmSShIGp3z5f0ZXXjFTUJBbUu7dIfnrmdikWE0uVmCZf4boK TVJqOBnkZ1aBEaf0wURxFibpfACArA+jeweACfEWwFoUzxqB5jdu/wSleggLfHiutzv4TJkwLEb wrpnwQvJGRGOGU+4oLJXHdPWX1/I65FLW+wbVeL6VwNApAA== X-Received: by 2002:a05:6000:26cd:b0:435:a815:dd8d with SMTP id ffacd0b85a97d-43796b04f57mr14262758f8f.55.1771151940325; Sun, 15 Feb 2026 02:39:00 -0800 (PST) X-Received: by 2002:a05:6000:26cd:b0:435:a815:dd8d with SMTP id ffacd0b85a97d-43796b04f57mr14262729f8f.55.1771151939812; Sun, 15 Feb 2026 02:38:59 -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-43796ad112bsm19183634f8f.36.2026.02.15.02.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Feb 2026 02:38:59 -0800 (PST) Date: Sun, 15 Feb 2026 05:38:55 -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: <20260215053411-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: netdev@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. To add to what i wrote, size/2 means: leave half a ring for consumer, half a ring for producer. If one of the two is more bursty, we might want a different balance. Offhand, the kernel is less bursty and userspace is more bursty. So it's an interesting question but size/2 is a good start.