From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 0C4311917F4 for ; Thu, 16 Jan 2025 07:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737014219; cv=none; b=eoWBVvXu67DCiZwxhEcJvdSVh15jFYsXcuXyJEng8eKMMVgA7ePI3IiLMH6ZrWawJu0qJ5Gcg0qa0Lre0nbQT2hpWWdm0djTzGmG/gPSJw67+UImcjVmA/kUaGOOl64hWKgUwiUt+jib6XBgK5/MJiMACih11CleCcKqhjL6S3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737014219; c=relaxed/simple; bh=ic1Tdl5eQV9IhEkanXH8pQd/pPr8stQL+iCCxmLxuHk=; h=Message-ID:Subject:Date:From:To:Cc:References:In-Reply-To; b=SbqFbUgLUOgF/e4Ox2XQIvds9bhUbDCUPw5i2ST4FaFVf2o73aHfAqPJq66vtl2braUteg2J4An+fIihHqAGBwGWNQEparQp0802Eizjfj2Ne42h2uZ/C2RDz7J70IvfJYuXXvg8Wd8EOxQ50YxlfEXZLRu3vJQ74sr8oZoEUmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=JJMWGcUP; arc=none smtp.client-ip=115.124.30.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="JJMWGcUP" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1737014215; h=Message-ID:Subject:Date:From:To; bh=ki0PBrtLkvSDIfEjuIbvOsNpP0XUwjZ9O5tjmqTVT3A=; b=JJMWGcUPkpGjVlYKTyGjbXEap8oOJJ2YMF3rqQs6ewF3fB2fh8kHOANRhLjxzQ1jbOR7fZD5JMyJhRqRVjaitjnhlOR1NKc8UAR/V6h8oHHHOyrnZMiqJSG4Y+r28XARDUhEItzuAimxK+GN73YBEWEDghWcYaqQIS2VS3JPz7M= Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0WNl-Mc3_1737014213 cluster:ay36) by smtp.aliyun-inc.com; Thu, 16 Jan 2025 15:56:54 +0800 Message-ID: <1737014207.587077-2-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH net-next v2 4/4] virtio_net: Use persistent NAPI config Date: Thu, 16 Jan 2025 15:56:47 +0800 From: Xuan Zhuo To: Joe Damato Cc: gerhard@engleder-embedded.com, jasowang@redhat.com, leiyang@redhat.com, mkarsten@uwaterloo.ca, Joe Damato , "Michael S. Tsirkin" , =?utf-8?q?Eugenio_P=C3=A9rez?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , virtualization@lists.linux.dev (open list:VIRTIO CORE AND NET DRIVERS), linux-kernel@vger.kernel.org (open list), netdev@vger.kernel.org References: <20250116055302.14308-1-jdamato@fastly.com> <20250116055302.14308-5-jdamato@fastly.com> In-Reply-To: <20250116055302.14308-5-jdamato@fastly.com> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: On Thu, 16 Jan 2025 05:52:59 +0000, Joe Damato wrote: > Use persistent NAPI config so that NAPI IDs are not renumbered as queue > counts change. > > $ sudo ethtool -l ens4 | tail -5 | egrep -i '(current|combined)' > Current hardware settings: > Combined: 4 > > $ ./tools/net/ynl/pyynl/cli.py \ > --spec Documentation/netlink/specs/netdev.yaml \ > --dump queue-get --json='{"ifindex": 2}' > [{'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'}, > {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'rx'}, > {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'}, > {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'}, > {'id': 0, 'ifindex': 2, 'type': 'tx'}, > {'id': 1, 'ifindex': 2, 'type': 'tx'}, > {'id': 2, 'ifindex': 2, 'type': 'tx'}, > {'id': 3, 'ifindex': 2, 'type': 'tx'}] > > Now adjust the queue count, note that the NAPI IDs are not renumbered: > > $ sudo ethtool -L ens4 combined 1 > $ ./tools/net/ynl/pyynl/cli.py \ > --spec Documentation/netlink/specs/netdev.yaml \ > --dump queue-get --json='{"ifindex": 2}' > [{'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'}, > {'id': 0, 'ifindex': 2, 'type': 'tx'}] > > $ sudo ethtool -L ens4 combined 8 > $ ./tools/net/ynl/pyynl/cli.py \ > --spec Documentation/netlink/specs/netdev.yaml \ > --dump queue-get --json='{"ifindex": 2}' > [{'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'}, > {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'rx'}, > {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'}, > {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'}, > {'id': 4, 'ifindex': 2, 'napi-id': 8197, 'type': 'rx'}, > {'id': 5, 'ifindex': 2, 'napi-id': 8198, 'type': 'rx'}, > {'id': 6, 'ifindex': 2, 'napi-id': 8199, 'type': 'rx'}, > {'id': 7, 'ifindex': 2, 'napi-id': 8200, 'type': 'rx'}, > [...] > > Signed-off-by: Joe Damato Reviewed-by: Xuan Zhuo > --- > v2: > - New in this v2. Adds persistent NAPI config so that NAPI IDs are > not renumbered and napi_config settings are persisted. > > drivers/net/virtio_net.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index c6fda756dd07..52094596e94b 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -6420,8 +6420,9 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) > INIT_DELAYED_WORK(&vi->refill, refill_work); > for (i = 0; i < vi->max_queue_pairs; i++) { > vi->rq[i].pages = NULL; > - netif_napi_add_weight(vi->dev, &vi->rq[i].napi, virtnet_poll, > - napi_weight); > + netif_napi_add_config(vi->dev, &vi->rq[i].napi, virtnet_poll, > + i); > + vi->rq[i].napi.weight = napi_weight; > netif_napi_add_tx_weight(vi->dev, &vi->sq[i].napi, > virtnet_poll_tx, > napi_tx ? napi_weight : 0); > -- > 2.25.1 >