* mm/page_alloc.c: remove hand-coded get_order()
@ 2008-04-15 9:23 Pavel Machek
2008-04-15 9:35 ` Andrew Morton
2008-04-15 10:39 ` Andi Kleen
0 siblings, 2 replies; 5+ messages in thread
From: Pavel Machek @ 2008-04-15 9:23 UTC (permalink / raw)
To: Andrew Morton, kernel list
__get_free_pages() is strange interface:
It has underscores, yet get_free_pages() does not exists.
It returns long when most people need pointer.
(And it takes order, when many people want to pass size).
What about creating void *get_free_pages(flags, order) version, then
slowly converting users to it?
Pavel
---
Remove hand-coded get_order() from page_alloc.c.
Signed-off-by: Pavel Machek <pavel@suse.cz>
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 402a504..c48aa45 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4339,9 +4339,7 @@ void *__init alloc_large_system_hash(con
else if (hashdist)
table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
else {
- unsigned long order;
- for (order = 0; ((1UL << order) << PAGE_SHIFT) < size; order++)
- ;
+ unsigned long order = get_order(size);
table = (void*) __get_free_pages(GFP_ATOMIC, order);
/*
* If bucketsize is not a power-of-two, we may free
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: mm/page_alloc.c: remove hand-coded get_order()
2008-04-15 9:23 mm/page_alloc.c: remove hand-coded get_order() Pavel Machek
@ 2008-04-15 9:35 ` Andrew Morton
2008-04-15 9:38 ` Andrew Morton
2008-04-15 10:39 ` Andi Kleen
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-04-15 9:35 UTC (permalink / raw)
To: Pavel Machek; +Cc: kernel list
On Tue, 15 Apr 2008 11:23:27 +0200 Pavel Machek <pavel@ucw.cz> wrote:
>
> __get_free_pages() is strange interface:
>
> It has underscores, yet get_free_pages() does not exists.
>
> It returns long when most people need pointer.
It is a bit odd.
> (And it takes order, when many people want to pass size).
>
> What about creating void *get_free_pages(flags, order) version,
Sounds sensible. It matches free_pages().
> then slowly converting users to it?
alas, poor me.
>
> ---
>
> Remove hand-coded get_order() from page_alloc.c.
>
> Signed-off-by: Pavel Machek <pavel@suse.cz>
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 402a504..c48aa45 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -4339,9 +4339,7 @@ void *__init alloc_large_system_hash(con
> else if (hashdist)
> table = __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL);
> else {
> - unsigned long order;
> - for (order = 0; ((1UL << order) << PAGE_SHIFT) < size; order++)
> - ;
> + unsigned long order = get_order(size);
> table = (void*) __get_free_pages(GFP_ATOMIC, order);
> /*
> * If bucketsize is not a power-of-two, we may free
>
OK. get_order() does round up, doesn't it? We seem to have forgotten to
document that rather important detail.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mm/page_alloc.c: remove hand-coded get_order()
2008-04-15 9:35 ` Andrew Morton
@ 2008-04-15 9:38 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2008-04-15 9:38 UTC (permalink / raw)
To: Pavel Machek, kernel list
On Tue, 15 Apr 2008 02:35:05 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
> > What about creating void *get_free_pages(flags, order) version,
>
> Sounds sensible. It matches free_pages().
No it doesn't. free_pages() takes unsigned long.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mm/page_alloc.c: remove hand-coded get_order()
2008-04-15 9:23 mm/page_alloc.c: remove hand-coded get_order() Pavel Machek
2008-04-15 9:35 ` Andrew Morton
@ 2008-04-15 10:39 ` Andi Kleen
2008-04-16 19:18 ` Christoph Lameter
1 sibling, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2008-04-15 10:39 UTC (permalink / raw)
To: Pavel Machek; +Cc: Andrew Morton, kernel list
Pavel Machek <pavel@ucw.cz> writes:
>
> What about creating void *get_free_pages(flags, order) version, then
> slowly converting users to it?
Then we would also need a free_pages() that takes void *, but unfortunately
free_pages() already has other semantics.
-Andi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mm/page_alloc.c: remove hand-coded get_order()
2008-04-15 10:39 ` Andi Kleen
@ 2008-04-16 19:18 ` Christoph Lameter
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Lameter @ 2008-04-16 19:18 UTC (permalink / raw)
To: Andi Kleen; +Cc: Pavel Machek, Andrew Morton, kernel list
On Tue, 15 Apr 2008, Andi Kleen wrote:
> Pavel Machek <pavel@ucw.cz> writes:
> >
> > What about creating void *get_free_pages(flags, order) version, then
> > slowly converting users to it?
>
> Then we would also need a free_pages() that takes void *, but unfortunately
> free_pages() already has other semantics.
But it would be more consistent.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-04-16 19:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 9:23 mm/page_alloc.c: remove hand-coded get_order() Pavel Machek
2008-04-15 9:35 ` Andrew Morton
2008-04-15 9:38 ` Andrew Morton
2008-04-15 10:39 ` Andi Kleen
2008-04-16 19:18 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox