★ wanayoo — archive 1999 http://kernelnotes.org/patch/21-p0209.htmlNouvelle recherche | Portail wanayoo

i386 Kernel Stack Fix

Ingo Molnar (mingo@pc5829.hil.siemens.at)
Mon Jan 27 18:30:00 1997

[Home] [Linux 2.0] [Linux 2.1] [Information] [Software] [Distributions] [Links]

21-kern-stack.patch
This patch unifies kernel stack pages and 'struct task_struct'. Effectively this moves all information about a thread onto one page. The memory layout is something like this [ascending addresses]:

kernel_stack_page
...
   [kernel stack_area]
...
kernel_stack_page + 4096 - sizeof(struct struct_task)
...
   [struct task_struct]
...
kernel_stack_page + 4096

This saves us a kmalloc in fork(), a kfree() in exit(), moves critical data closer to each other (thus cuts a bit down on TLB misses on platforms where this is an issue).

the dark side: it's ugly. The stack gets a bit smaller. There is a 'chicken and eggs' problem in exit(), which is now worked around. Not really critical, but we'd like to have fault statistics really accurate i guess.

but the most important plus IMHO, if this method is cool enough, it opens up a new set of possibilities to further optimize entry.S. 'current' can now be calculated based on the kernel ESP value, ie. without any memory load operation. And Intel SMP can now avoid a few APIC reads to get the cpuid.

[ is there anything i've missed? i'd like to know the bad news before putting work into entry.S :))) ]

i'm just posting from a kernel with this patch, but be careful anyways. The patch is against vanila 2.1.22.




[Home] [Up] [Search] [FeedBack]

Copyleft © The LinuxHQ Project. Licensed under the GNU Public License.