Dumb kernel stacksize question

Dave Hansen haveblue at us.ibm.com
Wed Nov 26 06:01:13 EST 2003


On Tue, 2003-11-25 at 10:51, linas at austin.ibm.com wrote:
> Is there a guideline for the largest thing one should alloc on
> a kernel stack?   I want to have a temp buffer for a workspace,
> but doing a __get_free_page(GFP_KERNEL); free_page(); seems like
> a waste of time & resource If I can get a suitably large buffer
> on the stack.  But I fear overflowing the kernel stack, which,
> if I understand correctly, is limited to 2 pages (or something
> like that?)

Look for THREAD_SIZE or THREAD_ORDER, those are the stack size
definitions.

How much you allocate on the stack largely depends on context.  I tend
to be a lot more careful when I know I'm far down in a call path than
when I'm early in the system-call patch.

In any case, a page is way too much to allocate on the stack, even with
the 4 pages of stack on ppc64.  We have a very fast single-page
allocators, so your get/free overhead shouldn't really be a problem.
The other options are a slab or some statically allocated per-cpu
buffer.

We can thank Martin Bligh's hot and cold pages for the fast 0-order
allocations.
--
Dave Hansen
haveblue at us.ibm.com


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list