[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450741676-5865-59-git-send-email-viro@ZenIV.linux.org.uk>
Date: Mon, 21 Dec 2015 23:47:32 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: linux-kernel@...r.kernel.org
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [POC][PATCH 59/83] add pointer-returning variants of __get_free_pages/__get_free_page
From: Al Viro <viro@...iv.linux.org.uk>
Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
drivers/block/xen-blkback/blkback.c | 4 ++--
drivers/xen/xen-scsiback.c | 6 +++---
include/linux/gfp.h | 9 +++++++--
mm/page_alloc.c | 8 ++++----
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index f909994..aa1c52a 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -113,7 +113,7 @@ module_param(log_stats, int, 0644);
/* Number of free pages to remove on each call to gnttab_free_pages */
#define NUM_BATCH_FREE_PAGES 10
-static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
+static inline int xen_get_free_page(struct xen_blkif *blkif, struct page **page)
{
unsigned long flags;
@@ -819,7 +819,7 @@ again:
pages[i]->page = persistent_gnt->page;
pages[i]->persistent_gnt = persistent_gnt;
} else {
- if (get_free_page(blkif, &pages[i]->page))
+ if (xen_get_free_page(blkif, &pages[i]->page))
goto out_of_memory;
addr = vaddr(pages[i]->page);
pages_to_gnt[segs_to_map] = pages[i]->page;
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 43bcae8..ebd2321 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -229,7 +229,7 @@ static void put_free_pages(struct page **page, int num)
spin_unlock_irqrestore(&free_pages_lock, flags);
}
-static int get_free_page(struct page **page)
+static int xen_get_free_page(struct page **page)
{
unsigned long flags;
@@ -439,7 +439,7 @@ static int scsiback_gnttab_data_map_list(struct vscsibk_pend *pending_req,
struct vscsibk_info *info = pending_req->info;
for (i = 0; i < cnt; i++) {
- if (get_free_page(pg + mapcount)) {
+ if (xen_get_free_page(pg + mapcount)) {
put_free_pages(pg, mapcount);
pr_err("no grant page\n");
return -ENOMEM;
@@ -1902,7 +1902,7 @@ static void __exit scsiback_exit(void)
struct page *page;
while (free_pages_num) {
- if (get_free_page(&page))
+ if (xen_get_free_page(&page))
BUG();
gnttab_free_pages(1, &page);
}
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index fc4529d..bb1626a 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -473,18 +473,23 @@ extern struct page *alloc_kmem_pages(gfp_t gfp_mask, unsigned int order);
extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask,
unsigned int order);
-extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
+extern void *get_free_pages(gfp_t gfp_mask, unsigned int order);
+#define __get_free_pages(gfp_mask, order) \
+ ((unsigned long)get_free_pages(gfp_mask, order))
extern void *get_zeroed_page(gfp_t gfp_mask);
void *alloc_pages_exact(size_t size, gfp_t gfp_mask);
void free_pages_exact(void *virt, size_t size);
void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
+#define get_free_page(gfp_mask) \
+ get_free_pages((gfp_mask), 0)
+
#define __get_free_page(gfp_mask) \
__get_free_pages((gfp_mask), 0)
#define get_dma_pages(gfp_mask, order) \
- ((void *)__get_free_pages((gfp_mask) | GFP_DMA, (order)))
+ get_free_pages((gfp_mask) | GFP_DMA, (order))
extern void __free_pages(struct page *page, unsigned int order);
extern void free_pages(const void *addr, unsigned int order);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a1aa8eb..9ab053f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3257,7 +3257,7 @@ EXPORT_SYMBOL(__alloc_pages_nodemask);
/*
* Common helper functions.
*/
-unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
+void *get_free_pages(gfp_t gfp_mask, unsigned int order)
{
struct page *page;
@@ -3269,10 +3269,10 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
page = alloc_pages(gfp_mask, order);
if (!page)
- return 0;
- return (unsigned long) page_address(page);
+ return NULL;
+ return page_address(page);
}
-EXPORT_SYMBOL(__get_free_pages);
+EXPORT_SYMBOL(get_free_pages);
void *get_zeroed_page(gfp_t gfp_mask)
{
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists