[BUG FIX] [PATCH] fork_init() max_low_pfn fixes potential OOM bugon big highmem machine

From: Coywolf Qi Hunt
Date: Mon Jun 28 2004 - 10:57:22 EST


<http://localhost/lxr/ident?i=start_kernel>Hello all,

On machine with 16G(or 8G if 4k stacks) or more memory, high max_threads could let system run out of low memory.
This patch decides max_threads by the amount of low memory instead of the total physical memory.
Systems without high memory would not be affected.

Coywolf

=====================================================================
diff -rup linux-2.6.7/init/main.c linux-2.6.7-cy/init/main.c
--- linux-2.6.7/init/main.c Wed Jun 9 00:07:40 2004
+++ linux-2.6.7-cy/init/main.c Thu Jun 17 04:55:54 2004
@@ -467,7 +467,7 @@ asmlinkage void __init start_kernel(void
if (efi_enabled)
efi_enter_virtual_mode();
#endif
- fork_init(num_physpages);
+ fork_init(max_low_pfn);
proc_caches_init();
buffer_init();
unnamed_dev_init();
diff -rup linux-2.6.7/kernel/fork.c linux-2.6.7-cy/kernel/fork.c
--- linux-2.6.7/kernel/fork.c Wed Jun 9 00:07:40 2004
+++ linux-2.6.7-cy/kernel/fork.c Mon Jun 28 22:55:50 2004
@@ -224,8 +224,8 @@ void __init fork_init(unsigned long memp

/*
* The default maximum number of threads is set to a safe
- * value: the thread structures can take up at most half
- * of memory.
+ * value: the thread structures can take up at most 1/8
+ * of low memory.
*/
max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8;
/*

--
Coywolf Qi Hunt
Admin of http://GreatCN.org and http://LoveCN.org

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/