* [PATCH] xen/blkfront: speed up purge_persistent_grants()
@ 2022-03-11 10:35 Juergen Gross
2022-03-11 10:50 ` Jan Beulich
2022-03-11 11:01 ` Roger Pau Monné
0 siblings, 2 replies; 3+ messages in thread
From: Juergen Gross @ 2022-03-11 10:35 UTC (permalink / raw)
To: xen-devel, linux-block, linux-kernel
Cc: Juergen Gross, Boris Ostrovsky, Stefano Stabellini,
Roger Pau Monné, Jens Axboe, Jan Beulich
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>
---
drivers/block/xen-blkfront.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index aa996b637d0b..378262ec47ae 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2533,6 +2533,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);
@@ -2550,9 +2551,11 @@ static void purge_persistent_grants(struct blkfront_info *info)
list_del(&gnt_list_entry->node);
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);
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] xen/blkfront: speed up purge_persistent_grants()
2022-03-11 10:35 [PATCH] xen/blkfront: speed up purge_persistent_grants() Juergen Gross
@ 2022-03-11 10:50 ` Jan Beulich
2022-03-11 11:01 ` Roger Pau Monné
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2022-03-11 10:50 UTC (permalink / raw)
To: Juergen Gross
Cc: Boris Ostrovsky, Stefano Stabellini, Roger Pau Monné,
Jens Axboe, xen-devel, linux-block, linux-kernel
On 11.03.2022 11:35, Juergen Gross wrote:
> 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: Jan Beulich <jbeulich@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/blkfront: speed up purge_persistent_grants()
2022-03-11 10:35 [PATCH] xen/blkfront: speed up purge_persistent_grants() Juergen Gross
2022-03-11 10:50 ` Jan Beulich
@ 2022-03-11 11:01 ` Roger Pau Monné
1 sibling, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2022-03-11 11:01 UTC (permalink / raw)
To: Juergen Gross
Cc: xen-devel, linux-block, linux-kernel, Boris Ostrovsky,
Stefano Stabellini, Jens Axboe, Jan Beulich
On Fri, Mar 11, 2022 at 11:35:27AM +0100, Juergen Gross wrote:
> 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>
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-11 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-11 10:35 [PATCH] xen/blkfront: speed up purge_persistent_grants() Juergen Gross
2022-03-11 10:50 ` Jan Beulich
2022-03-11 11:01 ` Roger Pau Monné
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox