[PATCH net-next] virtio-net: make napi_tx param easier to grasp

Subsystems: networking drivers, the rest, virtio net driver

STALE3344d

3 messages, 2 authors, 2017-08-21 · open the first message on its own page

[PATCH net-next] virtio-net: make napi_tx param easier to grasp

From: Koichiro Den <hidden>
Date: 2017-08-19 06:37:07

The module param napi_tx needs not to be writable for now since we do
not have any means of activating/deactivating it online, which seems to
be a low priority. Also make it clear that napi_tx is disabled when it
has been dynamically disabled behind the scenes.

Signed-off-by: Koichiro Den <redacted>
---
 drivers/net/virtio_net.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 4302f313d9a7..ea4e7ddcd377 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -37,7 +37,7 @@ module_param(napi_weight, int, 0444);
 static bool csum = true, gso = true, napi_tx;
 module_param(csum, bool, 0444);
 module_param(gso, bool, 0444);
-module_param(napi_tx, bool, 0644);
+module_param(napi_tx, bool, 0444);
 
 /* FIXME: MTU in config. */
 #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
@@ -1026,20 +1026,13 @@ static void virtnet_napi_enable(struct virtqueue *vq, struct napi_struct *napi)
 	local_bh_enable();
 }
 
-static void virtnet_napi_tx_enable(struct virtnet_info *vi,
-				   struct virtqueue *vq,
-				   struct napi_struct *napi)
+static void virtnet_napi_tx_enable(struct virtqueue *vq, struct napi_struct *napi)
 {
-	if (!napi->weight)
-		return;
-
-	/* Tx napi touches cachelines on the cpu handling tx interrupts. Only
-	 * enable the feature if this is likely affine with the transmit path.
-	 */
-	if (!vi->affinity_hint_set) {
+	if (!napi_tx)
 		napi->weight = 0;
+
+	if (!napi->weight)
 		return;
-	}
 
 	return virtnet_napi_enable(vq, napi);
 }
@@ -1179,13 +1172,19 @@ static int virtnet_open(struct net_device *dev)
 	struct virtnet_info *vi = netdev_priv(dev);
 	int i;
 
+	/* Tx napi touches cachelines on the cpu handling tx interrupts. Only
+	 * enable the feature if this is likely affine with the transmit path.
+	 */
+	if (!vi->affinity_hint_set)
+		napi_tx = false;
+
 	for (i = 0; i < vi->max_queue_pairs; i++) {
 		if (i < vi->curr_queue_pairs)
 			/* Make sure we have some buffers: if oom use wq. */
 			if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL))
 				schedule_delayed_work(&vi->refill, 0);
 		virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
-		virtnet_napi_tx_enable(vi, vi->sq[i].vq, &vi->sq[i].napi);
+		virtnet_napi_tx_enable(vi->sq[i].vq, &vi->sq[i].napi);
 	}
 
 	return 0;
@@ -1890,6 +1889,12 @@ static int virtnet_restore_up(struct virtio_device *vdev)
 
 	virtio_device_ready(vdev);
 
+	/* Tx napi touches cachelines on the cpu handling tx interrupts. Only
+	 * enable the feature if this is likely affine with the transmit path.
+	 */
+	if (!vi->affinity_hint_set)
+		napi_tx = false;
+
 	if (netif_running(vi->dev)) {
 		for (i = 0; i < vi->curr_queue_pairs; i++)
 			if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL))
@@ -1897,8 +1902,7 @@ static int virtnet_restore_up(struct virtio_device *vdev)
 
 		for (i = 0; i < vi->max_queue_pairs; i++) {
 			virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
-			virtnet_napi_tx_enable(vi, vi->sq[i].vq,
-					       &vi->sq[i].napi);
+			virtnet_napi_tx_enable(vi->sq[i].vq, &vi->sq[i].napi);
 		}
 	}
 
-- 
2.9.4

Re: [PATCH net-next] virtio-net: make napi_tx param easier to grasp

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2017-08-20 20:31:20

On Sat, Aug 19, 2017 at 2:37 AM, Koichiro Den [off-list ref] wrote:
The module param napi_tx needs not to be writable for now since we do
not have any means of activating/deactivating it online,
A virtio_net device inherits its napi tx mode from the global napi_tx flag
on device up. It is possible to change the parameter and bring a device
down/up to change the device mode.
quoted hunk
@@ -1179,13 +1172,19 @@ static int virtnet_open(struct net_device *dev)
        struct virtnet_info *vi = netdev_priv(dev);
        int i;

+       /* Tx napi touches cachelines on the cpu handling tx interrupts. Only
+        * enable the feature if this is likely affine with the transmit path.
+        */
+       if (!vi->affinity_hint_set)
+               napi_tx = false;
+
This disables napi globally if a specific device lacks affinity.

Re: [PATCH net-next] virtio-net: make napi_tx param easier to grasp

From: Koichiro Den <hidden>
Date: 2017-08-21 11:49:18

On Sun, 2017-08-20 at 16:30 -0400, Willem de Bruijn wrote:
On Sat, Aug 19, 2017 at 2:37 AM, Koichiro Den [off-list ref] wrote:
quoted
The module param napi_tx needs not to be writable for now since we do
not have any means of activating/deactivating it online,
A virtio_net device inherits its napi tx mode from the global napi_tx flag
on device up. It is possible to change the parameter and bring a device
down/up to change the device mode.
quoted
@@ -1179,13 +1172,19 @@ static int virtnet_open(struct net_device *dev)
        struct virtnet_info *vi = netdev_priv(dev);
        int i;

+       /* Tx napi touches cachelines on the cpu handling tx interrupts.
Only
+        * enable the feature if this is likely affine with the transmit
path.
+        */
+       if (!vi->affinity_hint_set)
+               napi_tx = false;
+
This disables napi globally if a specific device lacks affinity.
Now I see this is not appropriate since it just represents whether or not TX
napi is available, not that whether or not it is being turned on or off on a
particular device. Thank you.

To be honest I hoped to make it possible to see which mode it is currently
running on with ease, but I guess it's not nice to accomplish it with net sysfs
nor ethtool or whatever because it seems not much generic matter.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help