Skip to contentSkip to conversation

xen/grant-table: log the lack of grants

PATCH In review Wengang Wang 3 participants 5 messages Jul 7, 2017 – Jul 18, 2017 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/grant-table: log the lack of grants

log a message when we enter this situation:
1) we already allocated the max number of available grants from hypervisor and
2) we still need more (but the request fails because of 1)).

Sometimes the lack of grants causes IO hangs in xen_blkfront devices. Adding this log would help debuging.

---
 drivers/xen/grant-table.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/xen/grant-table.c +8 -1
index d6786b8..2c6a911 100644
@@ -42,6 +42,7 @@
 #include <linux/delay.h>
 #include <linux/hardirq.h>
 #include <linux/workqueue.h>
+#include <linux/ratelimit.h>
 
 #include <xen/xen.h>
 #include <xen/interface/xen.h>
@@ -1072,8 +1073,14 @@ static int gnttab_expand(unsigned int req_entries)
 	cur = nr_grant_frames;
 	extra = ((req_entries + (grefs_per_grant_frame-1)) /
 		 grefs_per_grant_frame);
-	if (cur + extra > gnttab_max_grant_frames())
+	if (cur + extra > gnttab_max_grant_frames()) {
+		pr_warn_ratelimited("xen/grant-table: max_grant_frames reached"
+				    " cur=%u extra=%u limit=%u"
+				    " gnttab_free_count=%u req_entries=%u\n",
+				    cur, extra, gnttab_max_grant_frames(),
+				    gnttab_free_count, req_entries);
 		return -ENOSPC;
+	}
 
 	rc = gnttab_map(cur, cur + extra - 1);
 	if (rc == 0)
Signature · 1 line
2.9.4
author
#1 lore raw

Hi,

Anyone can you please review this patch?

thanks,

wengang

Quoted 43 lines · Wengang Wang

log a message when we enter this situation:
1) we already allocated the max number of available grants from hypervisor and
2) we still need more (but the request fails because of 1)).

Sometimes the lack of grants causes IO hangs in xen_blkfront devices. Adding this log would help debuging.

---
  drivers/xen/grant-table.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
drivers/xen/grant-table.c +8 -1
index d6786b8..2c6a911 100644
@@ -42,6 +42,7 @@
  #include <linux/delay.h>
  #include <linux/hardirq.h>
  #include <linux/workqueue.h>
+#include <linux/ratelimit.h>
 
  #include <xen/xen.h>
  #include <xen/interface/xen.h>
@@ -1072,8 +1073,14 @@ static int gnttab_expand(unsigned int req_entries)
  	cur = nr_grant_frames;
  	extra = ((req_entries + (grefs_per_grant_frame-1)) /
  		 grefs_per_grant_frame);
-	if (cur + extra > gnttab_max_grant_frames())
+	if (cur + extra > gnttab_max_grant_frames()) {
+		pr_warn_ratelimited("xen/grant-table: max_grant_frames reached"
+				    " cur=%u extra=%u limit=%u"
+				    " gnttab_free_count=%u req_entries=%u\n",
+				    cur, extra, gnttab_max_grant_frames(),
+				    gnttab_free_count, req_entries);
  		return -ENOSPC;
+	}
 
  	rc = gnttab_map(cur, cur + extra - 1);
  	if (rc == 0)
#2 lore raw
Quoted 1 line · Wengang

Hi,

Hello,

Quoted 1 line

Anyone can you please review this patch?

Most of the developer community were at Xen Summit this week, so you may expect some delay in review.

However, in general it is better to CC relevant maintainers of your code to raise attention on your patch. I did it for you this time.

Cheers,

Quoted 54 lines

thanks,

wengang

Quoted 31 lines · Wengang Wang

log a message when we enter this situation:
1) we already allocated the max number of available grants from hypervisor and
2) we still need more (but the request fails because of 1)).

Sometimes the lack of grants causes IO hangs in xen_blkfront devices. Adding this log would help debuging.

---
  drivers/xen/grant-table.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
drivers/xen/grant-table.c +1 -1
index d6786b8..2c6a911 100644
@@ -42,6 +42,7 @@
  #include <linux/delay.h>
  #include <linux/hardirq.h>
  #include <linux/workqueue.h>
+#include <linux/ratelimit.h>
  #include <xen/xen.h>
  #include <xen/interface/xen.h>
@@ -1072,8 +1073,14 @@ static int gnttab_expand(unsigned int req_entries)
      cur = nr_grant_frames;
      extra = ((req_entries + (grefs_per_grant_frame-1)) /
           grefs_per_grant_frame);
-    if (cur + extra > gnttab_max_grant_frames())

drivers/xen/grant-table.c static int gnttab_expand(unsigned int req_entries) · line 1085

Quoted 10 lines
drivers/xen/grant-table.c +7 -0
+    if (cur + extra > gnttab_max_grant_frames()) {
+        pr_warn_ratelimited("xen/grant-table: max_grant_frames reached"
+                    " cur=%u extra=%u limit=%u"
+                    " gnttab_free_count=%u req_entries=%u\n",
+                    cur, extra, gnttab_max_grant_frames(),
+                    gnttab_free_count, req_entries);
          return -ENOSPC;
+    }
      rc = gnttab_map(cur, cur + extra - 1);
      if (rc == 0)

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

Signature · 1 line
Julien Grall
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Wengang Wang
Quoted 11 lines · Wengang Wang

log a message when we enter this situation:
1) we already allocated the max number of available grants from hypervisor and
2) we still need more (but the request fails because of 1)).

Sometimes the lack of grants causes IO hangs in xen_blkfront devices. Adding this log would help debuging.

Thanks,

Juergen

maintainer
#4 lore raw
In reply to Wengang Wang
Quoted 11 lines · Wengang Wang

log a message when we enter this situation:
1) we already allocated the max number of available grants from hypervisor and
2) we still need more (but the request fails because of 1)).

Sometimes the lack of grants causes IO hangs in xen_blkfront devices. Adding this log would help debuging.

Committed to xen/tip for-linus-4.13

Thanks,

Juergen