Skip to content

Commit

Permalink
xen/blkfront: speed up purge_persistent_grants()
Browse files Browse the repository at this point in the history
purge_persistent_grants() is scanning the grants list for persistent
grants being no longer in use by the backend. When having found such a
grant, it will be set to "invalid" and pushed to the tail of the list.

Instead of pushing it directly to the end of the list, add it first to
a temporary list, avoiding to scan those entries again in the main
list traversal. After having finished the scan, append the temporary
list to the grant list.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Link: https://lore.kernel.org/r/20220311103527.12931-1-jgross@suse.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Juergen Gross authored and Jens Axboe committed Mar 11, 2022
1 parent 67b5613 commit 85d9abc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/block/xen-blkfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,7 @@ static void purge_persistent_grants(struct blkfront_info *info)

for_each_rinfo(info, rinfo, i) {
struct grant *gnt_list_entry, *tmp;
LIST_HEAD(grants);

spin_lock_irqsave(&rinfo->ring_lock, flags);

Expand All @@ -2539,9 +2540,11 @@ static void purge_persistent_grants(struct blkfront_info *info)
gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
rinfo->persistent_gnts_c--;
gnt_list_entry->gref = GRANT_INVALID_REF;
list_add_tail(&gnt_list_entry->node, &rinfo->grants);
list_add_tail(&gnt_list_entry->node, &grants);
}

list_splice_tail(&grants, &rinfo->grants);

spin_unlock_irqrestore(&rinfo->ring_lock, flags);
}
}
Expand Down

0 comments on commit 85d9abc

Please sign in to comment.