lkml.org 
[lkml]   [1998]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] fork failures on ix86
Date
Recent 2.1 kernels suffer memory fragmentation, eventually requests >4kB
start failing. Among these are the requests made by fork for an 8kB kernel
stack.

This little hack changes fork to use the vmalloc service, so that the 8kB
fork request can be satisfied with 2 non-contiguous 4kB pages.

This patch is for ix86 only; something similar may work on other platforms.

The patch is against 2.1.108, but should apply to earlier 2.1.x kernels,
within reason.

===============================================================================

diff -ur /user/linux/linux-2.1.108/include/asm-i386/processor.h /usr/src/linux/include/asm-i386/processor.h
--- /user/linux/linux-2.1.108/include/asm-i386/processor.h Tue Jul 7 10:54:58 1998
+++ /usr/src/linux/include/asm-i386/processor.h Tue Jul 7 13:37:37 1998
@@ -218,8 +218,8 @@
* NOTE! The task struct and the stack go together
*/
#define alloc_task_struct() \
- ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
-#define free_task_struct(p) free_pages((unsigned long)(p),1)
+ ((struct task_struct *) vmalloc(8192))
+#define free_task_struct(p) vfree(p)

#define init_task (init_task_union.task)
#define init_stack (init_task_union.stack)
diff -ur /user/linux/linux-2.1.108/kernel/exit.c /usr/src/linux/kernel/exit.c
--- /user/linux/linux-2.1.108/kernel/exit.c Fri May 15 15:26:11 1998
+++ /usr/src/linux/kernel/exit.c Tue Jul 7 13:15:03 1998
@@ -23,6 +23,7 @@
#ifdef CONFIG_BSD_PROCESS_ACCT
#include <linux/acct.h>
#endif
+#include <linux/vmalloc.h>

#include <asm/uaccess.h>
#include <asm/pgtable.h>
diff -ur /user/linux/linux-2.1.108/kernel/fork.c /usr/src/linux/kernel/fork.c
--- /user/linux/linux-2.1.108/kernel/fork.c Tue Jul 7 10:47:02 1998
+++ /usr/src/linux/kernel/fork.c Tue Jul 7 13:14:40 1998
@@ -23,6 +23,7 @@
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/module.h>
+#include <linux/vmalloc.h>

#include <asm/system.h>
#include <asm/pgtable.h>
diff -ur /user/linux/linux-2.1.108/mm/vmalloc.c /usr/src/linux/mm/vmalloc.c
--- /user/linux/linux-2.1.108/mm/vmalloc.c Sat Jul 4 21:32:01 1998
+++ /usr/src/linux/mm/vmalloc.c Tue Jul 7 19:50:42 1998
@@ -159,10 +159,13 @@
if (!area)
return NULL;
addr = (void *) VMALLOC_START;
+ if ((unsigned long)addr & PAGE_SIZE) addr += PAGE_SIZE;
for (p = &vmlist; (tmp = *p) ; p = &tmp->next) {
if (size + (unsigned long) addr < (unsigned long) tmp->addr)
break;
addr = (void *) (tmp->size + (unsigned long) tmp->addr);
+ /* ugly hack to allocate kernel stacks on 8k boundaries */
+ if ((unsigned long)addr & PAGE_SIZE) addr += PAGE_SIZE;
}
area->addr = addr;
area->size = size + PAGE_SIZE;
=========== end of patch
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.059 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site