Skip to contentSkip to conversation

mm/page_alloc.c: remove hand-coded get_order()

PATCH Pavel Machek 4 participants 5 messages Apr 15, 2008 – Apr 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

__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.

mm/page_alloc.c +1 -3
index 402a504..c48aa45 100644
@@ -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
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#1 lore raw
Quoted 6 lines · On Tue, 15 Apr 2008 11:23:27 +0200 Pavel Machek <[email protected]> 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.

Quoted 3 lines

(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().

Quoted 1 line

then slowly converting users to it?

alas, poor me.

Quoted 13 lines

---

Remove hand-coded get_order() from page_alloc.c.

mm/page_alloc.c +0 -0
index 402a504..c48aa45 100644

mm/page_alloc.c void *__init alloc_large_system_hash(con · line 4345

Quoted 10 lines
mm/page_alloc.c +1 -3
@@ -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.

maintainer
#2 lore raw
Quoted 3 lines · On Tue, 15 Apr 2008 02:35:05 -0700 Andrew Morton <[email protected]>…
Quoted 1 line

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.

#3 lore raw
In reply to Pavel Machek
Quoted 3 lines · Pavel Machek

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

#4 lore raw
Quoted 7 lines · Andi Kleen
Quoted 3 lines · Pavel Machek

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.