[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 01/10] balloon_compaction: don't BUG() when it is not necessary
Xen balloon driver has several sources for ballooned pages. One of the sources will be generic balloon driver, in the sense that Xen balloon driver gets pages from that. When Xen balloon driver asks for a page from these sources, generic balloon driver might not have enough pages to return to caller. In that case we don't want to call BUG(). Simply return NULL will be sufficient. So this patch introduces a flag indicating if caller want to be very strict about empty list in generic balloon driver. If the flag is set to true, generic balloon driver calls BUG() when a request cannot be satisfied, which is the same behavior as before; otherwise it will just return NULL and let caller handle that situation. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- drivers/virtio/virtio_balloon.c | 2 +- include/linux/balloon_compaction.h | 3 ++- mm/balloon_compaction.c | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 25ebe8e..9733731 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -179,7 +179,7 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num) mutex_lock(&vb->balloon_lock); for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) { - page = balloon_page_dequeue(vb_dev_info); + page = balloon_page_dequeue(vb_dev_info, true); if (!page) break; set_page_pfns(vb->pfns + vb->num_pfns, page); diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h index 089743a..1e1f888 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -62,7 +62,8 @@ struct balloon_dev_info { }; extern struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info); -extern struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info); +extern struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info, + bool strict); extern struct balloon_dev_info *balloon_devinfo_alloc( void *balloon_dev_descriptor); diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c index 6e45a50..d604e83 100644 --- a/mm/balloon_compaction.c +++ b/mm/balloon_compaction.c @@ -72,14 +72,17 @@ EXPORT_SYMBOL_GPL(balloon_page_enqueue); * balloon_page_dequeue - removes a page from balloon's page list and returns * the its address to allow the driver release the page. * @b_dev_info: balloon device decriptor where we will grab a page from. + * @strict: strictly bookkeep number of pages. * * Driver must call it to properly de-allocate a previous enlisted balloon page * before definetively releasing it back to the guest system. * This function returns the page address for the recently dequeued page or * NULL in the case we find balloon's page list temporarily empty due to - * compaction isolated pages. + * compaction isolated pages. If @strict is set to true and caller asks for + * more pages than we have, BUG(). */ -struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info) +struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info, + bool strict) { struct page *page, *tmp; unsigned long flags; @@ -122,7 +125,7 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info) */ spin_lock_irqsave(&b_dev_info->pages_lock, flags); if (unlikely(list_empty(&b_dev_info->pages) && - !b_dev_info->isolated_pages)) + !b_dev_info->isolated_pages) && strict) BUG(); spin_unlock_irqrestore(&b_dev_info->pages_lock, flags); page = NULL; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |