From: boris.ostrovsky@oracle.com
To: Juergen Gross <jgross@suse.com>,
xen-devel@lists.xenproject.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: "Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH 1/2] xen: add helpers for caching grant mapping pages
Date: Mon, 7 Dec 2020 18:52:24 -0500 [thread overview]
Message-ID: <67875212-a5e1-5ea3-6ecd-2cf878f3cd5d@oracle.com> (raw)
In-Reply-To: <20201207133024.16621-2-jgross@suse.com>
On 12/7/20 8:30 AM, Juergen Gross wrote:
> Instead of having similar helpers in multiple backend drivers use
> common helpers for caching pages allocated via gnttab_alloc_pages().
>
> Make use of those helpers in blkback and scsiback.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovksy@oracle.com>
> +
> +void gnttab_page_cache_shrink(struct gnttab_page_cache *cache, unsigned int num)
> +{
> + struct page *page[10];
> + unsigned int i = 0;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&cache->lock, flags);
> +
> + while (cache->num_pages > num) {
> + page[i] = list_first_entry(&cache->pages, struct page, lru);
> + list_del(&page[i]->lru);
> + cache->num_pages--;
> + if (++i == ARRAY_SIZE(page)) {
> + spin_unlock_irqrestore(&cache->lock, flags);
> + gnttab_free_pages(i, page);
> + i = 0;
> + spin_lock_irqsave(&cache->lock, flags);
> + }
> + }
> +
> + spin_unlock_irqrestore(&cache->lock, flags);
> +
> + if (i != 0)
> + gnttab_free_pages(i, page);
> +}
How about splitting cache->pages list into two lists (one @num long and the other holding the rest) and then batching gntab_free_pages() from that first list? Then you won't have to deal with locking.
In fact, I am not even sure batching gains us much, I'd consider going one-by-one.
-boris
next prev parent reply other threads:[~2020-12-07 23:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 13:30 [PATCH 0/2] xen: fix using ZONE_DEVICE memory for foreign mappings Juergen Gross
2020-12-07 13:30 ` [PATCH 1/2] xen: add helpers for caching grant mapping pages Juergen Gross
2020-12-07 23:52 ` boris.ostrovsky [this message]
2020-12-07 13:30 ` [PATCH 2/2] xen: don't use page->lru for ZONE_DEVICE memory Juergen Gross
2020-12-07 20:48 ` Jason Andryuk
2020-12-08 6:45 ` Jürgen Groß
2020-12-10 11:14 ` Roger Pau Monné
2020-12-10 11:25 ` Jürgen Groß
2020-12-10 13:30 ` Jason Andryuk
2020-12-07 23:56 ` boris.ostrovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67875212-a5e1-5ea3-6ecd-2cf878f3cd5d@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=axboe@kernel.dk \
--cc=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®