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 8FF882882CE for ; Mon, 12 Jan 2026 04:42:24 +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=1768192945; cv=none; b=AtWUkJhztn9FD6rQpZa2HX8xYEzr1Gn0wmMn8Loj/BkPFX4UkusnsiYYOdfJoNhlKPYoPfk0Im2zALBTGQaj+wFnCuc/DQ5Z1uSNqv0cHTVTCXD7dAmy1rlClfQkjXzKn65kQ+kK4dQ4vaGy5oTie9BFT9dLIGqdQQjHiJ1VPso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768192945; c=relaxed/simple; bh=2VltQBFJygJXWBbOcvlhVXQ2y5H6Win1bazyoi6YOU0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jhcP5smB5t+c5HueYS/fj1BER3pRHZkBtze6jhPC0fg2sUCxCODP8RtvSprEKmGL4PVaPnNtf0fP/uql9XYwplqNLMAHLrcU5G/eT74ZkBwaD129P79p7zM3+siXuD/1P0cf0R/o1bJcaA93z2ksUt8eh+dgN41oCFHcuHg3L+c= 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=BS9iPDiS; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=YQE5Yfco; 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="BS9iPDiS"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="YQE5Yfco" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768192943; 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=eRnCSJo0TmvquSWDDIrpEWk/wUKA+CvYamy20zcpVrg=; b=BS9iPDiS6g/TN7mDR/hTCCd+7nZbfzhK6CE0+jEQK/f/8OBYBRn20kyLOmxSVkMqnm9ntq aeheU9vVL6D4scENC+KD1kox1uLOtNpH/kUTFB9FLu7Dg9UgOQMpPAngJckElhPb4xIhBR QOWJCC2htovAqhl01idenfE0pL58wtQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-AhREv4zGPFWKr--dyg5fUA-1; Sun, 11 Jan 2026 23:42:22 -0500 X-MC-Unique: AhREv4zGPFWKr--dyg5fUA-1 X-Mimecast-MFC-AGG-ID: AhREv4zGPFWKr--dyg5fUA_1768192941 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-432a9ef3d86so3094230f8f.2 for ; Sun, 11 Jan 2026 20:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768192941; x=1768797741; 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=eRnCSJo0TmvquSWDDIrpEWk/wUKA+CvYamy20zcpVrg=; b=YQE5YfcoVGsc3kel5AZsPv+5MwoVhhFfz1JXQSX/M9CqPf9Sp5r28AoLrkLxNolKew VJvvJOs7OCcjc6DyT3IzQKB6lEe5n71/Gx1e3DBjkfhQQB0NOfp7CkFunWKVMj32/a3b n7NohkN93JvaCdb1VWZ3BsLNICjQbm4dREMxBgjJS4NnZ2D2xow+Fc/vuYgbCzUFcjQq k9oP2XkTPOBWtLXaMixyiAuh9IbWvoMR1t2kmPKoJxFhRK7/L4ihN2O6DBxM5avfOEVK ok1pz+Z2akl5/7aTvDO+vOo2mrPL5uIEmzK4INT9gIceZZR4umPSsAVC9iScz083ZsXG GhiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768192941; x=1768797741; 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=eRnCSJo0TmvquSWDDIrpEWk/wUKA+CvYamy20zcpVrg=; b=kTrBtXL39ayJdjR0SMjOjzAa8TBh6fBeFTv2Q7RfrySi1MC9z8/xVR6JwjRoYFQbiF hpUr/1J09b4kmGNYuT51UEYXnArCAvXiE7uflpWJtmyAXE4OK/GVS82hNRPkMYY5TFn4 JbD8+KOS4kVBK566rT/yX+IOWntkUVBj/Ln6qgS2Swp47EfySwNyXJleb0QQvFN4unv8 coGzRmKHw8fPMNJoGxLJrDbPHrgrWzTn06LLcMe7WzvUtKSzcXkrrkI5J71BgGEWRmxb Tkjc3oHpiG1AVqeRzx1wa1vekZ/xXXG4soeVWak8PxSuQ5xcMh45UwjGOqXyPMrUUTHJ tHJA== X-Forwarded-Encrypted: i=1; AJvYcCXAmnhDXls/Jh/BKSrcb6YnP3mCuyw2B2otXPLPVXvWpRXIxY8iRc7OemiS3b0annhZsHh/xziDgfNbWLI=@vger.kernel.org X-Gm-Message-State: AOJu0YxfXA6Q39AICNKt06B7s7IKho3A/c7dBrMBWgKVQk/+QLLIxtSW ZCAPpT8Z9XcLQNsKjwQ3Mvojc5MyOGGFBELKVrkReMH344GpGtk9NZxFwxOh2jBsjTCZtPQp2QE z2xcypCnR5HVZnGw1QV8IrH9IUoN8sR2aeqyJJAG9/AVK0KKMeRbYQ428EL9qyNe+5g== X-Gm-Gg: AY/fxX56uslJwxh3pVkhELV7HVVOD7KdzfOOy2LuB9KQLdUFqZMGJDtsPwOcuqf8f7o iduas2dVCIKkleJOc8KGQD1J+TZ+Jh2hkLVA4tx4YUV6vzAK1mm7GHsT071uGE9ZzayBeLNJDUK /5WUOHFs8QIlByZ3sKKJf+Nkj9X2F5dxei4+weRXOq4g3QkE9BjS4vBP2jF4BhhvxTsGQi4NmBY +WhhSak6QbuoP4elOS47LeoeCRS/mFCHuccQ6XD0T4oXvXbcjqp9bl/dymdAKgip0HNjmLtk1Ef IAURUC8ckJy/eCU2d/eGh753AnzzsI8CtKNghoyJRdKqyq9zWm9RGQlgh9xDjLZe1cZSVr0jBYV W2RMm3EFTfm4DVxy1USj26fEYcEJ06v8= X-Received: by 2002:a5d:5888:0:b0:42f:edb6:3642 with SMTP id ffacd0b85a97d-432c37767acmr20558551f8f.60.1768192940941; Sun, 11 Jan 2026 20:42:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGksWsEOp11E7do7kSJe9rVBAth4jOqGHv4mw3q8StsdQQPY6PxltAQTL2SJSNkU9vJyWdeOw== X-Received: by 2002:a5d:5888:0:b0:42f:edb6:3642 with SMTP id ffacd0b85a97d-432c37767acmr20558531f8f.60.1768192940549; Sun, 11 Jan 2026 20:42:20 -0800 (PST) Received: from redhat.com (IGLD-80-230-35-22.inter.net.il. [80.230.35.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ff319sm36985010f8f.43.2026.01.11.20.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jan 2026 20:42:19 -0800 (PST) Date: Sun, 11 Jan 2026 23:42:16 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Simon Schippers , 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 7/9] vhost-net: vhost-net: replace rx_ring with tun/tap ring wrappers Message-ID: <20260111234112-mutt-send-email-mst@kernel.org> References: <20260107210448.37851-1-simon.schippers@tu-dortmund.de> <20260107210448.37851-8-simon.schippers@tu-dortmund.de> <5961e982-9c52-4e7a-b1ca-caaf4c4d0291@tu-dortmund.de> <0ae9071b-6d76-4336-8aee-d0338eecc6f5@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jan 12, 2026 at 10:54:15AM +0800, Jason Wang wrote: > On Fri, Jan 9, 2026 at 5:57 PM Simon Schippers > wrote: > > > > On 1/9/26 07:04, Jason Wang wrote: > > > On Thu, Jan 8, 2026 at 3:48 PM Simon Schippers > > > wrote: > > >> > > >> On 1/8/26 05:38, Jason Wang wrote: > > >>> On Thu, Jan 8, 2026 at 5:06 AM Simon Schippers > > >>> wrote: > > >>>> > > >>>> Replace the direct use of ptr_ring in the vhost-net virtqueue with > > >>>> tun/tap ring wrapper helpers. Instead of storing an rx_ring pointer, > > >>>> the virtqueue now stores the interface type (IF_TUN, IF_TAP, or IF_NONE) > > >>>> and dispatches to the corresponding tun/tap helpers for ring > > >>>> produce, consume, and unconsume operations. > > >>>> > > >>>> Routing ring operations through the tun/tap helpers enables netdev > > >>>> queue wakeups, which are required for upcoming netdev queue flow > > >>>> control support shared by tun/tap and vhost-net. > > >>>> > > >>>> No functional change is intended beyond switching to the wrapper > > >>>> helpers. > > >>>> > > >>>> Co-developed-by: Tim Gebauer > > >>>> Signed-off-by: Tim Gebauer > > >>>> Co-developed by: Jon Kohler > > >>>> Signed-off-by: Jon Kohler > > >>>> Signed-off-by: Simon Schippers > > >>>> --- > > >>>> drivers/vhost/net.c | 92 +++++++++++++++++++++++++++++---------------- > > >>>> 1 file changed, 60 insertions(+), 32 deletions(-) > > >>>> > > >>>> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c > > >>>> index 7f886d3dba7d..215556f7cd40 100644 > > >>>> --- a/drivers/vhost/net.c > > >>>> +++ b/drivers/vhost/net.c > > >>>> @@ -90,6 +90,12 @@ enum { > > >>>> VHOST_NET_VQ_MAX = 2, > > >>>> }; > > >>>> > > >>>> +enum if_type { > > >>>> + IF_NONE = 0, > > >>>> + IF_TUN = 1, > > >>>> + IF_TAP = 2, > > >>>> +}; > > >>> > > >>> This looks not elegant, can we simply export objects we want to use to > > >>> vhost like get_tap_socket()? > > >> > > >> No, we cannot do that. We would need access to both the ptr_ring and the > > >> net_device. However, the net_device is protected by an RCU lock. > > >> > > >> That is why {tun,tap}_ring_consume_batched() are used: > > >> they take the appropriate locks and handle waking the queue. > > > > > > How about introducing a callback in the ptr_ring itself, so vhost_net > > > only need to know about the ptr_ring? > > > > That would be great, but I'm not sure whether this should be the > > responsibility of the ptr_ring. > > > > If the ptr_ring were to keep track of the netdev queue, it could handle > > all the management itself - stopping the queue when full and waking it > > again once space becomes available. > > > > What would be your idea for implementing this? > > During ptr_ring_init() register a callback, the callback will be > trigger during ptr_ring_consume() or ptr_ring_consume_batched() when > ptr_ring find there's a space for ptr_ring_produce(). > > Thanks Not sure the perceived elegance is worth the indirect call overhead. ptr_ring is trying hard to be low overhead. What this does is not really complex to justify that. We just need decent documentation. > > > > > > > > Thanks > > > > > >> > > >>> > > >>> Thanks > > >>> > > >> > > > > >