rename alloc_pages_exact()
Subsystems (5)
RFC PATCH 1/2 rename alloc_pages_exact()
alloc_pages_exact() returns a virtual address. But, alloc_pages() returns a 'struct page *'. That makes for very confused kernel hackers.
__get_free_pages(), on the other hand, returns virtual addresses. That makes alloc_pages_exact() a much closer match to __get_free_pages(), so rename it to get_free_pages_exact().
Note that alloc_pages_exact()'s partner, free_pages_exact() already matches free_pages(), so we do not have to touch the free side of things.
---
linux-2.6.git-dave/drivers/video/fsl-diu-fb.c | 2 +- linux-2.6.git-dave/drivers/video/pxafb.c | 4 ++-- linux-2.6.git-dave/drivers/virtio/virtio_pci.c | 2 +- linux-2.6.git-dave/include/linux/gfp.h | 2 +- linux-2.6.git-dave/kernel/profile.c | 2 +- linux-2.6.git-dave/mm/page_alloc.c | 22 +++++++++++----------- 6 files changed, 17 insertions(+), 17 deletions(-)
drivers/video/fsl-diu-fb.c renamed from drivers/video/fsl-diu-fb.c~change-alloc_pages_exact-name +1 -1
@@ -294,7 +294,7 @@ static void *fsl_diu_alloc(size_t size,pr_debug ("size=%zu\n" , size); - virt =alloc_pages_exact (size,GFP_DMA | __GFP_ZERO); + virt =get_free_pages_exact (size,GFP_DMA | __GFP_ZERO);if (virt) { *phys =virt_to_phys (virt); pr_debug("virt=%p phys=%llx\n", virt,
drivers/video/pxafb.c renamed from drivers/video/pxafb.c~change-alloc_pages_exact-name +2 -2
@@ -820,7 +820,7 @@ static int overlayfb_map_video_memory(stfree_pages_exact (ofb->video_mem, ofb->video_mem_size); } - ofb->video_mem =alloc_pages_exact (size,GFP_KERNEL | __GFP_ZERO); + ofb->video_mem =get_free_pages_exact (size,GFP_KERNEL | __GFP_ZERO);if (ofb->video_mem ==NULL )return -ENOMEM ;
@@ -1678,7 +1678,7 @@ static int __devinit pxafb_init_video_me {int size =PAGE_ALIGN (fbi->video_mem_size); - fbi->video_mem =alloc_pages_exact (size,GFP_KERNEL | __GFP_ZERO); + fbi->video_mem =get_free_pages_exact (size,GFP_KERNEL | __GFP_ZERO);if (fbi->video_mem ==NULL )return -ENOMEM ;
drivers/virtio/virtio_pci.c renamed from drivers/virtio/virtio_pci.c~change-alloc_pages_exact-name +1 -1
@@ -385,7 +385,7 @@ static struct virtqueue *setup_vq(struct info->msix_vector = msix_vec; size =PAGE_ALIGN (vring_size (num,VIRTIO_PCI_VRING_ALIGN )); - info->queue =alloc_pages_exact (size,GFP_KERNEL |__GFP_ZERO); + info->queue =get_free_pages_exact (size,GFP_KERNEL |__GFP_ZERO);if (info->queue ==NULL ) { err = -ENOMEM ; goto out_info;
include/linux/gfp.h renamed from include/linux/gfp.h~change-alloc_pages_exact-name +1 -1
@@ -346,7 +346,7 @@ extern struct page *alloc_pages_vma(gfp_extern unsigned long __get_free_pages (gfp_t gfp_mask,unsigned int order);extern unsigned long get_zeroed_page (gfp_t gfp_mask); -void *alloc_pages_exact (size_t size,gfp_t gfp_mask); +void *get_free_pages_exact (size_t size,gfp_t gfp_mask);void free_pages_exact (void *virt,size_t size);#define __get_free_page (gfp_mask) \
kernel/profile.c renamed from kernel/profile.c~change-alloc_pages_exact-name +1 -1
@@ -121,7 +121,7 @@ int __ref profile_init(void)if (prof_buffer)return 0 ; - prof_buffer =alloc_pages_exact (buffer_bytes, + prof_buffer =get_free_pages_exact (buffer_bytes,GFP_KERNEL |__GFP_ZERO|__GFP_NOWARN);if (prof_buffer)return 0 ;
mm/page_alloc.c renamed from mm/page_alloc.c~change-alloc_pages_exact-name +11 -11
@@ -2284,19 +2284,19 @@ void free_pages(unsigned long addr, unsiEXPORT_SYMBOL (free_pages);/** -* alloc_pages_exact - allocate an exact number physically-contiguous pages. +* get_free_pages_exact - allocate an exact number physically-contiguous pages. * @size: the number of bytes to allocate * @gfp_mask: GFP flags for the allocation * -* This function is similar to alloc_pages(), except that it allocates the -* minimum number of pages to satisfy the request. alloc_pages() can only +* This function is similar to __get_free_pages(), except that it allocates the +* minimum number of pages to satisfy the request. get_free_pages() can only * allocate memory in power-of-two pages. * * This function is also limited by MAX_ORDER. * * Memory allocated by this function must be released by free_pages_exact(). */ -void *alloc_pages_exact (size_t size,gfp_t gfp_mask) +void *get_free_pages_exact (size_t size,gfp_t gfp_mask) {unsigned int order =get_order (size);unsigned long addr;
@@ -2315,14 +2315,14 @@ void *alloc_pages_exact(size_t size, gfpreturn (void *)addr; } -EXPORT_SYMBOL (alloc_pages_exact); +EXPORT_SYMBOL (get_free_pages_exact);/** -* free_pages_exact - release memory allocated via alloc_pages_exact() -* @virt: the value returned by alloc_pages_exact. -* @size: size of allocation, same value as passed to alloc_pages_exact(). +* free_pages_exact - release memory allocated via get_free_pages_exact() +* @virt: the value returned by get_free_pages_exact(). +* @size: size of allocation, same value as passed to get_free_pages_exact(). * -* Release the memory allocated by a previous call to alloc_pages_exact. +* Release the memory allocated by a previous call to get_free_pages_exact(). */ void free_pages_exact (void *virt,size_t size) {
@@ -5247,10 +5247,10 @@ void *__init alloc_large_system_hash(con/* * If bucketsize is not a power-of-two, we may free * some pages at the end of hash table which -* alloc_pages_exact() automatically does +* get_free_pages_exact() automatically does */ if (get_order (size) <MAX_ORDER ) { - table =alloc_pages_exact (size,GFP_ATOMIC ); + table =get_free_pages_exact (size,GFP_ATOMIC );kmemleak_alloc (table, size,1 ,GFP_ATOMIC ); } }
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RFC PATCH 2/2 make new alloc_pages_exact()
What I really wanted in the end was a highmem-capable alloc_pages_exact(), so here it is.
It's a bit unfortunate that we have __free_pages_exact() and free_pages_exact(), but that mess already exists with __free_pages() vs. free_pages_exact(). So, at worst, this mirrors the mess that we already have.
I'm also a bit worried that I've not put in something named alloc_pages_exact(), but that behaves differently. I got all of the in-tree cases, but I'm a bit worried about stragglers elsewheree
Note that the __get_free_pages() has a !GFP_HIGHMEM check. Now that we're not using it, we had to add a new check to get_free_pages_exact().
---
linux-2.6.git-dave/include/linux/gfp.h | 4 + linux-2.6.git-dave/mm/page_alloc.c | 81 ++++++++++++++++++++++++--------- 2 files changed, 65 insertions(+), 20 deletions(-)
include/linux/gfp.h renamed from include/linux/gfp.h~make_new_alloc_pages_exact +4 -0
@@ -346,6 +346,10 @@ extern struct page *alloc_pages_vma(gfp_extern unsigned long __get_free_pages (gfp_t gfp_mask,unsigned int order);extern unsigned long get_zeroed_page (gfp_t gfp_mask); +/* 'struct page' version */ +struct page *alloc_pages_exact (gfp_t gfp_mask,size_t ); +void __free_pages_exact (struct page *page,size_t size); +/* virtual address version */ void *get_free_pages_exact (size_t size,gfp_t gfp_mask);void free_pages_exact (void *virt,size_t size);
mm/page_alloc.c renamed from mm/page_alloc.c~make_new_alloc_pages_exact +61 -20
110 lines not on this page · raw message
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [RFC][PATCH 2/2] make new alloc_pages_exact()
mm/page_alloc.c void free_pages(unsigned long addr, unsi · line 2314
Quoted 7 lines · Dave Hansen
while (used < alloc_end) {mm/page_alloc.c renamed from mm/page_alloc.c~make_new_alloc_pages_exact +2
-2-free_page (used); - used +=PAGE_SIZE ; +__free_page (page); + used++; }
Please note that I'm a dummy and put "page" in there instead of "used". I'll repost these with a proper inclusion request soon.
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Dave Hansen
alloc_pages_exact()returns a virtual address. But,alloc_pages()returns a 'struct page *'. That makes for very confused kernel hackers.
__get_free_pages(), on the other hand, returns virtual addresses. That makesalloc_pages_exact()a much closer match to__get_free_pages(), so rename it toget_free_pages_exact().Note that alloc_pages_exact()'s partner,
free_pages_exact()already matchesfree_pages(), so we do not have to touch the free side of things.
Yes, that was wrong from the start. Thanks for fixing.
-Andi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>