Skip to contentSkip to conversation

xen/blkfront: correct purging of persistent grants

PATCH In review Juergen Gross 4 participants 15 messages Sep 28, 2018

Subsystems (3)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen/blkfront: correct purging of persistent grants

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +2 -2
index a71d817e900d..429d20131c7e 100644
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);
 		}
 
 		spin_unlock_irqrestore(&rinfo->ring_lock, flags);
Signature · 1 line
2.16.4
#1 lore raw
Quoted 3 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

s/pu /put /

Alan

#3 lore raw
In reply to Juergen Gross
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

-boris

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2677

Quoted 3 lines
drivers/block/xen-blkfront.c +0 -0
 		}
 
 		spin_unlock_irqrestore(&rinfo->ring_lock, flags);

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

#4 lore raw
In reply to Juergen Gross
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

-boris

Quoted 3 lines
drivers/block/xen-blkfront.c +0 -0
 		}
 
 		spin_unlock_irqrestore(&rinfo->ring_lock, flags);
author maintainer
#5 lore raw
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 12 lines
drivers/block/xen-blkfront.c +2 -2
index a71d817e900d..429d20131c7e 100644
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

The persistent grants are at the list head and the non-persistent ones at the tail.

Juergen

#6 lore raw
Quoted 26 lines · Juergen Gross
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 12 lines
drivers/block/xen-blkfront.c +2 -2
index a71d817e900d..429d20131c7e 100644
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

-boris

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

#7 lore raw
In reply to Juergen Gross
Quoted 26 lines · Juergen Gross
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 12 lines
drivers/block/xen-blkfront.c +2 -2
index a71d817e900d..429d20131c7e 100644
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

-boris

author maintainer
#8 lore raw
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Juergen Gross
Quoted 25 lines · Boris Ostrovsky
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 5 lines
Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

In theory: yes.

The persistent grant handling is rather complicated so I'd like to make sure not to deviate from the common standards.

When I find some time I want to modify the persistent grant handling to be more explicit and controlled completely by the frontend (within the backend defined limits, of course). Until then we should try to modify persistent grants not too much IMO.

Juergen

Reviewed-by
#9 lore raw
Quoted 28 lines · Juergen Gross
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Juergen Gross
Quoted 25 lines · Boris Ostrovsky
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

In theory: yes.

The persistent grant handling is rather complicated so I'd like to make sure not to deviate from the common standards.

I am not arguing with correctness of your patch, so

but I am a little surprised that it fixes Sander's problem.

-boris

Quoted 8 lines

When I find some time I want to modify the persistent grant handling to be more explicit and controlled completely by the frontend (within the backend defined limits, of course). Until then we should try to modify persistent grants not too much IMO.

Juergen

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

Reviewed-by
#10 lore raw
In reply to Juergen Gross
Quoted 28 lines · Juergen Gross
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Juergen Gross
Quoted 25 lines · Boris Ostrovsky
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

In theory: yes.

The persistent grant handling is rather complicated so I'd like to make sure not to deviate from the common standards.

I am not arguing with correctness of your patch, so

but I am a little surprised that it fixes Sander's problem.

-boris

Quoted 8 lines

When I find some time I want to modify the persistent grant handling to be more explicit and controlled completely by the frontend (within the backend defined limits, of course). Until then we should try to modify persistent grants not too much IMO.

Juergen

author maintainer
#11 lore raw
In reply to Boris Ostrovsky
Quoted 27 lines · Boris Ostrovsky
Quoted 26 lines · Juergen Gross
Quoted 25 lines · Boris Ostrovsky
Quoted 14 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/xen-blkfront.c +0 -0
index a71d817e900d..429d20131c7e 100644

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 7 lines
drivers/block/xen-blkfront.c +2 -2
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

Quoted 5 lines
Quoted 2 lines

The persistent grants are at the list head and the non-persistent ones at the tail.

Oh, I didn't realize that. But isn't that an optimization (and so not following this rule should not cause errors)?

In theory: yes.

The persistent grant handling is rather complicated so I'd like to make sure not to deviate from the common standards.

When I find some time I want to modify the persistent grant handling to be more explicit and controlled completely by the frontend (within the backend defined limits, of course). Until then we should try to modify persistent grants not too much IMO.

Juergen

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

author maintainer
#12 lore raw
In reply to Boris Ostrovsky
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

---
 drivers/block/xen-blkfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/block/xen-blkfront.c static void purge_persistent_grants(struct blkfront_info *info) · line 2674

Quoted 12 lines
drivers/block/xen-blkfront.c +2 -2
index a71d817e900d..429d20131c7e 100644
@@ -2670,8 +2670,8 @@ static void purge_persistent_grants(struct blkfront_info *info)
 			list_del(&gnt_list_entry->node);
 			gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
 			rinfo->persistent_gnts_c--;
-			__free_page(gnt_list_entry->page);
-			kfree(gnt_list_entry);
+			gnt_list_entry->gref = GRANT_INVALID_REF;
+			list_add_tail(&gnt_list_entry->node, &rinfo->grants);

Sorry, I don't follow this. What is the purpose of removing the grant from rinfo->grants list with list_del() and then adding it back with list_add_tail()?

The persistent grants are at the list head and the non-persistent ones at the tail.

Juergen

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

maintainer
#13 lore raw
In reply to Juergen Gross
Quoted 3 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

I'll apply this for 4.19, and if things unexpectedly don't work out, we can always revert the series next week.

Signature · 1 line
Jens Axboe
maintainer
#14 lore raw
In reply to Juergen Gross
Quoted 3 lines · Juergen Gross

Commit a46b53672b2c2e3770b38a4abf90d16364d2584b ("xen/blkfront: cleanup stale persistent grants") introduced a regression as purged persistent grants were not pu into the list of free grants again. Correct that.

I'll apply this for 4.19, and if things unexpectedly don't work out, we can always revert the series next week.

Signature · 7 lines
Jens Axboe


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