Commit 464fb419 authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk

xen/blkback: Use 'vzalloc' for page arrays and pre-allocate pages.

Previously we would allocate the array for page using 'kmalloc' which
we can as easily do with 'vzalloc'. The pre-allocation of pages
was done a bit differently in the past - it used to be that
the balloon driver would export "alloc_empty_pages_and_pagevec"
which would have in one function created an array, allocated
the pages, balloned the pages out (so the memory behind those
pages would be non-present), and provide us those pages.

This was OK as those pages were shared between other guest and
the only thing we needed was to "swizzel" the MFN of those pages
to point to the other guest MFN. We can still "swizzel" the MFNs
using the M2P (and P2M) override API calls, but for the sake of
simplicity we are dropping the balloon API calls. We can return
to those later on.
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent c35950bf
...@@ -637,18 +637,23 @@ static int __init blkif_init(void) ...@@ -637,18 +637,23 @@ static int __init blkif_init(void)
blkbk->pending_reqs = kmalloc(sizeof(blkbk->pending_reqs[0]) * blkbk->pending_reqs = kmalloc(sizeof(blkbk->pending_reqs[0]) *
blkif_reqs, GFP_KERNEL); blkif_reqs, GFP_KERNEL);
blkbk->pending_grant_handles = kmalloc(sizeof(blkbk->pending_grant_handles[0]) * blkbk->pending_grant_handles = vzalloc(sizeof(blkbk->pending_grant_handles[0]) *
mmap_pages, GFP_KERNEL); mmap_pages);
blkbk->pending_pages = alloc_empty_pages_and_pagevec(mmap_pages); blkbk->pending_pages = vzalloc(sizeof(blkbk->pending_pages[0]) * mmap_pages);
if (!blkbk->pending_reqs || !blkbk->pending_grant_handles || !blkbk->pending_pages) { if (!blkbk->pending_reqs || !blkbk->pending_grant_handles || !blkbk->pending_pages) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_of_memory; goto out_of_memory;
} }
for (i = 0; i < mmap_pages; i++) for (i = 0; i < mmap_pages; i++) {
blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE; blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
blkbk->pending_pages[i] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
if (blkbk->pending_pages[i] == NULL) {
rc = -ENOMEM;
goto out_of_memory;
}
}
rc = blkif_interface_init(); rc = blkif_interface_init();
if (rc) if (rc)
goto failed_init; goto failed_init;
...@@ -672,8 +677,12 @@ static int __init blkif_init(void) ...@@ -672,8 +677,12 @@ static int __init blkif_init(void)
printk(KERN_ERR "%s: out of memory\n", __func__); printk(KERN_ERR "%s: out of memory\n", __func__);
failed_init: failed_init:
kfree(blkbk->pending_reqs); kfree(blkbk->pending_reqs);
kfree(blkbk->pending_grant_handles); vfree(blkbk->pending_grant_handles);
free_empty_pages_and_pagevec(blkbk->pending_pages, mmap_pages); for (i = 0; i < mmap_pages; i++) {
if (blkbk->pending_pages[i])
__free_page(blkbk->pending_pages[i]);
}
vfree(blkbk->pending_pages);
vfree(blkbk); vfree(blkbk);
blkbk = NULL; blkbk = NULL;
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment