Received: from mnm [127.0.0.1] by localhost with POP3 (fetchmail-5.9.0) for akpm@localhost (single-drop); Fri, 25 Jul 2003 14:06:25 -0700 (PDT) Received: from digeo-e2k04.digeo.com ([192.168.2.24]) by pao-ex01.pao.digeo.com with Microsoft SMTPSVC(5.0.2195.5329); Fri, 25 Jul 2003 14:00:37 -0700 Received: from digeo-nav01.digeo.com ([192.168.1.233]) by digeo-e2k04.digeo.com with Microsoft SMTPSVC(5.0.2195.5329); Fri, 25 Jul 2003 14:00:34 -0700 Received: from packet.digeo.com ([192.168.17.15]) by digeo-nav01.digeo.com (SAVSMTP 3.1.1.32) with SMTP id M2003072514025614985 for ; Fri, 25 Jul 2003 14:02:56 -0700 Received: from zok.sgi.com (zok.sgi.com [204.94.215.101]) by packet.digeo.com (8.12.8/8.12.8) with ESMTP id h6PL0W9D009650 for ; Fri, 25 Jul 2003 14:00:33 -0700 (PDT) Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by zok.sgi.com (8.12.9/8.12.9/linux-outbound_gateway-1.1) with ESMTP id h6PL0Uq0028072; Fri, 25 Jul 2003 14:00:30 -0700 Received: from spamtin.engr.sgi.com (postfix@spamtin.engr.sgi.com [163.154.6.130]) by cthulhu.engr.sgi.com (SGI-8.12.5/8.12.5) with ESMTP id h6PL0T6B6258516; Fri, 25 Jul 2003 14:00:29 -0700 (PDT) Received: by spamtin.engr.sgi.com (Postfix, from userid 35197) id 639C02404066; Fri, 25 Jul 2003 14:00:29 -0700 (PDT) Date: Fri, 25 Jul 2003 14:00:29 -0700 To: linux-kernel@vger.kernel.org, akpm@digeo.com, mbligh@aracnet.com Subject: [PATCH] fix alloc_bootmem_low_pages Message-ID: <20030725210029.GA17016@sgi.com> Mail-Followup-To: linux-kernel@vger.kernel.org, akpm@digeo.com, mbligh@aracnet.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: jbarnes@sgi.com (Jesse Barnes) X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-OriginalArrivalTime: 25 Jul 2003 21:00:34.0040 (UTC) FILETIME=[CA409F80:01C352EF] X-Spam-Status: No, hits=-15.6 required=6.0 tests=BAYES_10,PATCH_UNIFIED_DIFF,USER_AGENT_MUTT autolearn=ham version=2.53 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.53 (1.174.2.15-2003-03-30-exp) This patch is needed for some discontig boxes since the memory maps may be built out-of-order. Jesse diff -Nru a/mm/bootmem.c b/mm/bootmem.c --- a/mm/bootmem.c Thu Jul 17 16:59:05 2003 +++ b/mm/bootmem.c Thu Jul 17 16:59:05 2003 @@ -48,8 +48,24 @@ bootmem_data_t *bdata = pgdat->bdata; unsigned long mapsize = ((end - start)+7)/8; - pgdat->pgdat_next = pgdat_list; - pgdat_list = pgdat; + + /* + * sort pgdat_list so that the lowest one comes first, + * which makes alloc_bootmem_low_pages work as desired. + */ + if (!pgdat_list || pgdat_list->node_start_pfn > pgdat->node_start_pfn) { + pgdat->pgdat_next = pgdat_list; + pgdat_list = pgdat; + } else { + pg_data_t *tmp = pgdat_list; + while (tmp->pgdat_next) { + if (tmp->pgdat_next->node_start_pfn > pgdat->node_start_pfn) + break; + tmp = tmp->pgdat_next; + } + pgdat->pgdat_next = tmp->pgdat_next; + tmp->pgdat_next = pgdat; + } mapsize = (mapsize + (sizeof(long) - 1UL)) & ~(sizeof(long) - 1UL); bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT);