Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S266181AbUF3Knm (ORCPT ); Wed, 30 Jun 2004 06:43:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S266579AbUF3Knm (ORCPT ); Wed, 30 Jun 2004 06:43:42 -0400 Received: from everest.2mbit.com ([24.123.221.2]:30118 "EHLO mail.sosdg.org") by vger.kernel.org with ESMTP id S266181AbUF3Knj (ORCPT ); Wed, 30 Jun 2004 06:43:39 -0400 Message-ID: <40E29945.6080107@greatcn.org> Date: Wed, 30 Jun 2004 18:43:17 +0800 From: Coywolf Qi Hunt User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Coywolf Qi Hunt CC: linux-kernel@vger.kernel.org, akpm@osdl.org, rmk+lkml@arm.linux.org.uk References: <40E03F71.8010902@greatcn.org> In-Reply-To: <40E03F71.8010902@greatcn.org> X-Scan-Signature: 343c02c2eb63e9fdf8bb9e8b0a6769b7 X-SA-Exim-Connect-IP: 218.24.174.116 X-SA-Exim-Mail-From: coywolf@greatcn.org Subject: [BUG FIX] fork_init() OOM bug on big highmem machine Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Report: * -4.9 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * 3.0 RCVD_IN_AHBL_CNKR RBL: AHBL: sender is listed in the AHBL China/Korea blocks * [218.24.174.116 listed in cnkrbl.ahbl.org] X-SA-Exim-Version: 4.0 (built Wed, 05 May 2004 12:02:20 -0500) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1999 Lines: 58 Coywolf Qi Hunt wrote: > 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. This patch should be ok by taking ``max_low_pfn - min_low_pfn'' and also becomes more accurate. On those systems where physical RAM doesn't start at address 0, we should initialize min_low_pfn. Anyway min_low_pfn is already defined on all platforms. The bug of forgetting min_low_pfn initialization on those platforms isn't more severe than this bug. ==================================================================== 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 - min_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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/