Commit 4ab688c51226188f2d4ad4f789032c107944ef89
Committed by
Linus Torvalds
1 parent
5bc98594d5
Exists in
master
and in
7 other branches
slob: fix page order calculation on not 4KB page
SLOB doesn't calculate correct page order when page size is not 4KB. This patch fixes it with using get_order() instead of find_order() which is SLOB version of get_order(). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Matt Mackall <mpm@selenic.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 3 additions and 12 deletions Side-by-side Diff
mm/slob.c
... | ... | @@ -150,15 +150,6 @@ |
150 | 150 | spin_unlock_irqrestore(&slob_lock, flags); |
151 | 151 | } |
152 | 152 | |
153 | -static int FASTCALL(find_order(int size)); | |
154 | -static int fastcall find_order(int size) | |
155 | -{ | |
156 | - int order = 0; | |
157 | - for ( ; size > 4096 ; size >>=1) | |
158 | - order++; | |
159 | - return order; | |
160 | -} | |
161 | - | |
162 | 153 | void *__kmalloc(size_t size, gfp_t gfp) |
163 | 154 | { |
164 | 155 | slob_t *m; |
... | ... | @@ -174,7 +165,7 @@ |
174 | 165 | if (!bb) |
175 | 166 | return 0; |
176 | 167 | |
177 | - bb->order = find_order(size); | |
168 | + bb->order = get_order(size); | |
178 | 169 | bb->pages = (void *)__get_free_pages(gfp, bb->order); |
179 | 170 | |
180 | 171 | if (bb->pages) { |
... | ... | @@ -318,7 +309,7 @@ |
318 | 309 | if (c->size < PAGE_SIZE) |
319 | 310 | b = slob_alloc(c->size, flags, c->align); |
320 | 311 | else |
321 | - b = (void *)__get_free_pages(flags, find_order(c->size)); | |
312 | + b = (void *)__get_free_pages(flags, get_order(c->size)); | |
322 | 313 | |
323 | 314 | if (c->ctor) |
324 | 315 | c->ctor(b, c, SLAB_CTOR_CONSTRUCTOR); |
... | ... | @@ -345,7 +336,7 @@ |
345 | 336 | if (c->size < PAGE_SIZE) |
346 | 337 | slob_free(b, c->size); |
347 | 338 | else |
348 | - free_pages((unsigned long)b, find_order(c->size)); | |
339 | + free_pages((unsigned long)b, get_order(c->size)); | |
349 | 340 | } |
350 | 341 | EXPORT_SYMBOL(kmem_cache_free); |
351 | 342 |