Skip to content

Commit 85d9abc

Browse files
jgross1axboe
authored andcommitted
xen/blkfront: speed up purge_persistent_grants()
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>
1 parent 67b5613 commit 85d9abc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/block/xen-blkfront.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,7 @@ static void purge_persistent_grants(struct blkfront_info *info)
25212521

25222522
for_each_rinfo(info, rinfo, i) {
25232523
struct grant *gnt_list_entry, *tmp;
2524+
LIST_HEAD(grants);
25242525

25252526
spin_lock_irqsave(&rinfo->ring_lock, flags);
25262527

@@ -2539,9 +2540,11 @@ static void purge_persistent_grants(struct blkfront_info *info)
25392540
gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL);
25402541
rinfo->persistent_gnts_c--;
25412542
gnt_list_entry->gref = GRANT_INVALID_REF;
2542-
list_add_tail(&gnt_list_entry->node, &rinfo->grants);
2543+
list_add_tail(&gnt_list_entry->node, &grants);
25432544
}
25442545

2546+
list_splice_tail(&grants, &rinfo->grants);
2547+
25452548
spin_unlock_irqrestore(&rinfo->ring_lock, flags);
25462549
}
25472550
}

0 commit comments

Comments
 (0)