* [i386] Use page allocator to allocate threadinfo structure
@ 2007-04-05 0:40 Christoph Lameter
2007-04-05 8:30 ` William Lee Irwin III
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Lameter @ 2007-04-05 0:40 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel
i386 uses kmalloc to allocate the threadinfo structure assuming that the
allocations result in a page sized aligned allocation. That has worked so
far because SLAB exempts page sized slabs from debugging and aligns them
in special ways that goes beyond the restrictions imposed by
KMALLOC_ARCH_MINALIGN valid for other slabs in the kmalloc array.
SLUB also works fine without debugging since page sized allocations neatly
align at page boundaries. However, if debugging is switched on then SLUB
will extend the slab with debug information. The resulting slab is not
longer of page size. It will only be aligned following the requirements
imposed by KMALLOC_ARCH_MINALIGN. As a result the threadinfo
structure may not be page aligned which makes i386 fail to boot with
SLUB debug on.
Replace the calls to kmalloc with calls into the page allocator.
An alternate solution may be to create a custom slab cache where the
alignment is set to PAGE_SIZE. That would allow slub debugging to be
applied to the threadinfo structure.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.21-rc5-mm4/include/asm-i386/thread_info.h
===================================================================
--- linux-2.6.21-rc5-mm4.orig/include/asm-i386/thread_info.h 2007-04-03 23:48:34.000000000 -0700
+++ linux-2.6.21-rc5-mm4/include/asm-i386/thread_info.h 2007-04-04 17:33:41.000000000 -0700
@@ -95,12 +95,14 @@ static inline struct thread_info *curren
/* thread information allocation */
#ifdef CONFIG_DEBUG_STACK_USAGE
-#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
+#define alloc_thread_info(tsk) ((struct thread_info *) \
+ __get_free_pages(GFP_KERNEL| __GFP_ZERO, get_order(THREAD_SIZE)))
#else
-#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
+#define alloc_thread_info(tsk) ((struct thread_info *) \
+ __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE)))
#endif
-#define free_thread_info(info) kfree(info)
+#define free_thread_info(info) free_pages((unsigned long)(info), get_order(THREAD_SIZE))
#else /* !__ASSEMBLY__ */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [i386] Use page allocator to allocate threadinfo structure
2007-04-05 0:40 [i386] Use page allocator to allocate threadinfo structure Christoph Lameter
@ 2007-04-05 8:30 ` William Lee Irwin III
2007-04-05 18:15 ` Christoph Lameter
0 siblings, 1 reply; 3+ messages in thread
From: William Lee Irwin III @ 2007-04-05 8:30 UTC (permalink / raw)
To: Christoph Lameter; +Cc: akpm, linux-kernel
On Wed, Apr 04, 2007 at 05:40:31PM -0700, Christoph Lameter wrote:
> Replace the calls to kmalloc with calls into the page allocator.
> An alternate solution may be to create a custom slab cache where the
> alignment is set to PAGE_SIZE. That would allow slub debugging to be
> applied to the threadinfo structure.
> Signed-off-by: Christoph Lameter <clameter@sgi.com>
This was originally made a slab allocation as a preparatory cleanup
for things that were never merged, and are never likely to be. One
might as well revert it, though it does make stack space usage
slightly more difficult to account for.
-- wli
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [i386] Use page allocator to allocate threadinfo structure
2007-04-05 8:30 ` William Lee Irwin III
@ 2007-04-05 18:15 ` Christoph Lameter
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Lameter @ 2007-04-05 18:15 UTC (permalink / raw)
To: William Lee Irwin III; +Cc: akpm, linux-kernel
On Thu, 5 Apr 2007, William Lee Irwin III wrote:
> On Wed, Apr 04, 2007 at 05:40:31PM -0700, Christoph Lameter wrote:
> > Replace the calls to kmalloc with calls into the page allocator.
> > An alternate solution may be to create a custom slab cache where the
> > alignment is set to PAGE_SIZE. That would allow slub debugging to be
> > applied to the threadinfo structure.
> > Signed-off-by: Christoph Lameter <clameter@sgi.com>
>
> This was originally made a slab allocation as a preparatory cleanup
> for things that were never merged, and are never likely to be. One
> might as well revert it, though it does make stack space usage
> slightly more difficult to account for.
No other platform does account for kernel stack space though. And you got
two pages per process. Pretty straightforward.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-05 18:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-05 0:40 [i386] Use page allocator to allocate threadinfo structure Christoph Lameter
2007-04-05 8:30 ` William Lee Irwin III
2007-04-05 18:15 ` Christoph Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox