提交 bf53d6f8 编写于 作者: C Christoph Lameter 提交者: Linus Torvalds

vmalloc: clean up page array indexing

The page array is repeatedly indexed both in vunmap and vmalloc_area_node().
Add a temporary variable to make it easier to read (and easier to patch
later).
Signed-off-by: NChristoph Lameter <clameter@sgi.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9e2779fa
...@@ -384,8 +384,10 @@ static void __vunmap(const void *addr, int deallocate_pages) ...@@ -384,8 +384,10 @@ static void __vunmap(const void *addr, int deallocate_pages)
int i; int i;
for (i = 0; i < area->nr_pages; i++) { for (i = 0; i < area->nr_pages; i++) {
BUG_ON(!area->pages[i]); struct page *page = area->pages[i];
__free_page(area->pages[i]);
BUG_ON(!page);
__free_page(page);
} }
if (area->flags & VM_VPAGES) if (area->flags & VM_VPAGES)
...@@ -489,15 +491,19 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, ...@@ -489,15 +491,19 @@ void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
} }
for (i = 0; i < area->nr_pages; i++) { for (i = 0; i < area->nr_pages; i++) {
struct page *page;
if (node < 0) if (node < 0)
area->pages[i] = alloc_page(gfp_mask); page = alloc_page(gfp_mask);
else else
area->pages[i] = alloc_pages_node(node, gfp_mask, 0); page = alloc_pages_node(node, gfp_mask, 0);
if (unlikely(!area->pages[i])) {
if (unlikely(!page)) {
/* Successfully allocated i pages, free them in __vunmap() */ /* Successfully allocated i pages, free them in __vunmap() */
area->nr_pages = i; area->nr_pages = i;
goto fail; goto fail;
} }
area->pages[i] = page;
} }
if (map_vm_area(area, prot, &pages)) if (map_vm_area(area, prot, &pages))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册