Skip to contentSkip to conversation

xen: issue warning message when out of grant maptrack entries

PATCH Superseded Juergen Gross 2 participants 11 messages Sep 18, 2018 – Sep 19, 2018 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen: issue warning message when out of grant maptrack entries

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +19 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
 		}
 	}
 
Signature · 1 line
2.16.4
#1 lore raw
Quoted 41 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +11 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 10 lines
drivers/xen/grant-table.c +8 -0
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
 		}
 	}

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Juergen Gross
Quoted 41 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +11 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 10 lines
drivers/xen/grant-table.c +8 -0
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
 		}
 	}

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

-boris

author maintainer
#3 lore raw
Quoted 49 lines · Boris Ostrovsky
Quoted 48 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +18 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
Quoted 8 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 3 lines
drivers/xen/grant-table.c +1 -0
+			break;
 		}
 	}

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

The loop is running until the end, so i == count for the call of kmap_ops().

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author maintainer
#4 lore raw
In reply to Boris Ostrovsky
Quoted 49 lines · Boris Ostrovsky
Quoted 48 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +18 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
Quoted 8 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 3 lines
drivers/xen/grant-table.c +1 -0
+			break;
 		}
 	}

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

The loop is running until the end, so i == count for the call of kmap_ops().

Juergen

#7 lore raw
In reply to Juergen Gross
Quoted 45 lines · Juergen Gross
Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +13 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
Quoted 8 lines
Quoted 8 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 8 lines
drivers/xen/grant-table.c +6 -0
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
 		}
 	}

After having a second look at this (and at the risk of embarrassing myself again with this patch) --- aren't we supposed to test status after gnttab_retry_eagain_gop() call, and then actually set foreign properties?

-boris

Quoted 8 lines
Quoted 4 lines

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

The loop is running until the end, so i == count for the call of kmap_ops().

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
In reply to Juergen Gross
Quoted 45 lines · Juergen Gross
Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +13 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
Quoted 8 lines
Quoted 8 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 8 lines
drivers/xen/grant-table.c +6 -0
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
 		}
 	}

After having a second look at this (and at the risk of embarrassing myself again with this patch) --- aren't we supposed to test status after gnttab_retry_eagain_gop() call, and then actually set foreign properties?

-boris

Quoted 8 lines
Quoted 4 lines

Should we pass 'i' instead of count to set_foreign_p2m_mapping() below? The loop there will skip entries that are in error, but does it make sense to do the hypercall for kmap_ops with count>i ?

The loop is running until the end, so i == count for the call of kmap_ops().

Juergen

author maintainer
#9 lore raw
Quoted 52 lines · Boris Ostrovsky
Quoted 51 lines · Juergen Gross
Quoted 50 lines · Boris Ostrovsky
Quoted 49 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +19 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 2 lines
drivers/xen/grant-table.c +0 -0
 		}
 	}

After having a second look at this (and at the risk of embarrassing myself again with this patch) --- aren't we supposed to test status after gnttab_retry_eagain_gop() call, and then actually set foreign properties?

Right. Thanks for catching that!

V2 coming soon...

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author maintainer
#10 lore raw
In reply to Boris Ostrovsky
Quoted 52 lines · Boris Ostrovsky
Quoted 51 lines · Juergen Gross
Quoted 50 lines · Boris Ostrovsky
Quoted 49 lines · Juergen Gross

When a driver domain (e.g. dom0) is running out of maptrack entries it can't map any more foreign domain pages. Instead of silently stalling the affected domUs issue a rate limited warning in this case in order to make it easier to detect that situation.

---
 drivers/xen/grant-table.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/xen/grant-table.c +19 -6
index 7bafa703a992..09f6ff8c1957 100644
@@ -1040,18 +1040,31 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
 		return ret;
 
 	for (i = 0; i < count; i++) {
-		/* Retry eagain maps */
-		if (map_ops[i].status == GNTST_eagain)
-			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref, map_ops + i,
-						&map_ops[i].status, __func__);
-
-		if (map_ops[i].status == GNTST_okay) {
+		switch (map_ops[i].status) {
+		case GNTST_okay:
+		{
 			struct xen_page_foreign *foreign;
 
 			SetPageForeign(pages[i]);
 			foreign = xen_page_foreign(pages[i]);
 			foreign->domid = map_ops[i].dom;
 			foreign->gref = map_ops[i].ref;
+			break;
+		}
+
+		case GNTST_no_device_space:
+			pr_warn_ratelimited("maptrack limit reached, can't map all guest pages\n");
+			break;
+
+		case GNTST_eagain:
+			/* Retry eagain maps */
+			gnttab_retry_eagain_gop(GNTTABOP_map_grant_ref,
+						map_ops + i,
+						&map_ops[i].status, __func__);
+			break;
+
+		default:
+			break;
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

drivers/xen/grant-table.c int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, · line 1069

Quoted 2 lines
drivers/xen/grant-table.c +0 -0
 		}
 	}

After having a second look at this (and at the risk of embarrassing myself again with this patch) --- aren't we supposed to test status after gnttab_retry_eagain_gop() call, and then actually set foreign properties?

Right. Thanks for catching that!

V2 coming soon...

Juergen