Skip to contentSkip to conversation

xen-netfront: always set num queues if possible

PATCH In review Charles (Chas) Williams 3 participants 9 messages Sep 14, 2015 – Sep 21, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-netfront: always set num queues if possible

The xen store preserves this information across module invocations. If you insmod netfront with two queues and later insmod again with one queue, the backend will still believe you asked for two queues.

---
 drivers/net/xen-netfront.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/xen-netfront.c +7 -5
index f821a97..b53a681 100644
@@ -1819,11 +1819,7 @@ again:
 		goto destroy_ring;
 	}
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(xbt, dev->nodename, "multi-queue-num-queues")) {
 		/* Write the number of queues */
 		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
 				    "%u", num_queues);
@@ -1831,7 +1827,13 @@ again:
 			message = "writing multi-queue-num-queues";
 			goto abort_transaction_no_dev_fatal;
 		}
+	}
 
+	if (num_queues == 1) {
+		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
+		if (err)
+			goto abort_transaction_no_dev_fatal;
+	} else {
 		/* Write the keys for each queue */
 		for (i = 0; i < num_queues; ++i) {
 			queue = &info->queues[i];
Signature · 1 line
2.1.0
#1 lore raw
Quoted 3 lines · Charles (Chas) Williams

The xen store preserves this information across module invocations. If you insmod netfront with two queues and later insmod again with one queue, the backend will still believe you asked for two queues.

Can you rewrite the commit message to be clearer?

"If netfront connects with 2 (or more) queues and then reconnects with only 1 queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support."

Quoted 5 lines
drivers/net/xen-netfront.c +0 -0
@@ -1819,11 +1819,7 @@ again:
 		goto destroy_ring;
 	}

drivers/net/xen-netfront.c again: · line 1825

Quoted 10 lines
drivers/net/xen-netfront.c +1 -5
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(xbt, dev->nodename, "multi-queue-num-queues")) {
 		/* Write the number of queues */
 		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
 				    "%u", num_queues);

Isn't this broken? It looks like it won't write the multi-queue-num-queues key the first time around.

It think this should be conditional on multi-queue-max-queues existing (which is written by the backend if multi-queue is supported).

David

#2 lore raw
Quoted 5 lines · David Vrabel
Quoted 3 lines · Charles (Chas) Williams

The xen store preserves this information across module invocations. If you insmod netfront with two queues and later insmod again with one queue, the backend will still believe you asked for two queues.

Quoted 7 lines

Can you rewrite the commit message to be clearer?

"If netfront connects with 2 (or more) queues and then reconnects with only 1 queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support."

Yes I can do that.

Quoted 20 lines
Quoted 6 lines
drivers/net/xen-netfront.c +0 -0
@@ -1819,11 +1819,7 @@ again:
 		goto destroy_ring;
 	}

drivers/net/xen-netfront.c again: · line 1825

Quoted 10 lines
drivers/net/xen-netfront.c +1 -5
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(xbt, dev->nodename, "multi-queue-num-queues")) {
 		/* Write the number of queues */
 		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
 				    "%u", num_queues);

Isn't this broken? It looks like it won't write the multi-queue-num-queues key the first time around.

Quoted 2 lines

It think this should be conditional on multi-queue-max-queues existing (which is written by the backend if multi-queue is supported).

You are right. I am testing against the wrong key here. I should have tested for multi-queue-max-queues.

#3 lore raw
In reply to David Vrabel
Quoted 5 lines · David Vrabel
Quoted 3 lines · Charles (Chas) Williams

The xen store preserves this information across module invocations. If you insmod netfront with two queues and later insmod again with one queue, the backend will still believe you asked for two queues.

Quoted 7 lines

Can you rewrite the commit message to be clearer?

"If netfront connects with 2 (or more) queues and then reconnects with only 1 queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support."

Yes I can do that.

Quoted 20 lines
Quoted 6 lines
drivers/net/xen-netfront.c +0 -0
@@ -1819,11 +1819,7 @@ again:
 		goto destroy_ring;
 	}

drivers/net/xen-netfront.c again: · line 1825

Quoted 10 lines
drivers/net/xen-netfront.c +1 -5
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(xbt, dev->nodename, "multi-queue-num-queues")) {
 		/* Write the number of queues */
 		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
 				    "%u", num_queues);

Isn't this broken? It looks like it won't write the multi-queue-num-queues key the first time around.

Quoted 2 lines

It think this should be conditional on multi-queue-max-queues existing (which is written by the backend if multi-queue is supported).

You are right. I am testing against the wrong key here. I should have tested for multi-queue-max-queues.

#4 lore raw

PATCH v2 1/1 xen-netfront: always set num queues if possible

In reply to David Vrabel

If netfront connects with two (or more) queues and then reconnects with only one queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support.

---
 drivers/net/xen-netfront.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/xen-netfront.c +10 -7
index f821a97..9bf63c2 100644
@@ -1819,19 +1819,22 @@ again:
 		goto destroy_ring;
 	}
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(XBT_NIL,
+			  info->xbdev->otherend, "multi-queue-max-queues")) {
 		/* Write the number of queues */
-		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
-				    "%u", num_queues);
+		err = xenbus_printf(xbt, dev->nodename,
+				    "multi-queue-num-queues", "%u", num_queues);
 		if (err) {
 			message = "writing multi-queue-num-queues";
 			goto abort_transaction_no_dev_fatal;
 		}
+	}
 
+	if (num_queues == 1) {
+		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
+		if (err)
+			goto abort_transaction_no_dev_fatal;
+	} else {
 		/* Write the keys for each queue */
 		for (i = 0; i < num_queues; ++i) {
 			queue = &info->queues[i];
Signature · 1 line
2.1.0
maintainer Applied
#5 lore raw

From: "Charles (Chas) Williams" <[email protected]>
Date: Wed, 16 Sep 2015 16:28:25 -0400

Quoted 7 lines

If netfront connects with two (or more) queues and then reconnects with only one queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support.

Applied, thanks Chas.

maintainer Applied
#6 lore raw
In reply to Charles (Chas) Williams

From: "Charles (Chas) Williams" <[email protected]>
Date: Wed, 16 Sep 2015 16:28:25 -0400

Quoted 7 lines

If netfront connects with two (or more) queues and then reconnects with only one queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support.

Applied, thanks Chas.

#7 lore raw

PATCH v2 1/1 xen-netfront: always set num queues if possible

In reply to David Vrabel

If netfront connects with two (or more) queues and then reconnects with only one queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support.

---
 drivers/net/xen-netfront.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/xen-netfront.c +10 -7
index f821a97..9bf63c2 100644
@@ -1819,19 +1819,22 @@ again:
 		goto destroy_ring;
 	}
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(XBT_NIL,
+			  info->xbdev->otherend, "multi-queue-max-queues")) {
 		/* Write the number of queues */
-		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
-				    "%u", num_queues);
+		err = xenbus_printf(xbt, dev->nodename,
+				    "multi-queue-num-queues", "%u", num_queues);
 		if (err) {
 			message = "writing multi-queue-num-queues";
 			goto abort_transaction_no_dev_fatal;
 		}
+	}
 
+	if (num_queues == 1) {
+		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
+		if (err)
+			goto abort_transaction_no_dev_fatal;
+	} else {
 		/* Write the keys for each queue */
 		for (i = 0; i < num_queues; ++i) {
 			queue = &info->queues[i];
Signature · 1 line
2.1.0
#8 lore raw
In reply to Charles (Chas) Williams
Quoted 3 lines · Charles (Chas) Williams

The xen store preserves this information across module invocations. If you insmod netfront with two queues and later insmod again with one queue, the backend will still believe you asked for two queues.

Can you rewrite the commit message to be clearer?

"If netfront connects with 2 (or more) queues and then reconnects with only 1 queue it fails to delete or rewrite the multi-queue-num-queues key and netback will try to use the wrong number of queues.

Always write the num-queues field if the backend has multi-queue support."

Quoted 5 lines
drivers/net/xen-netfront.c +0 -0
@@ -1819,11 +1819,7 @@ again:
 		goto destroy_ring;
 	}

drivers/net/xen-netfront.c again: · line 1825

Quoted 10 lines
drivers/net/xen-netfront.c +1 -5
 
-	if (num_queues == 1) {
-		err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */
-		if (err)
-			goto abort_transaction_no_dev_fatal;
-	} else {
+	if (xenbus_exists(xbt, dev->nodename, "multi-queue-num-queues")) {
 		/* Write the number of queues */
 		err = xenbus_printf(xbt, dev->nodename, "multi-queue-num-queues",
 				    "%u", num_queues);

Isn't this broken? It looks like it won't write the multi-queue-num-queues key the first time around.

It think this should be conditional on multi-queue-max-queues existing (which is written by the backend if multi-queue is supported).

David