linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@chiara.csoma.elte.hu>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.rutgers.edu, "Stephen C. Tweedie" <sct@redhat.com>
Subject: [patch] zoned-2.3.27-E0
Date: Fri, 12 Nov 1999 15:02:31 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.10.9911121502120.7240-200000@chiara.csoma.elte.hu> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 225 bytes --]


Stephen noticed that 2.3.27 doesnt boot on <=16MB boxes due to the zoned
allocator changes. The attached patch should fix this. Unfortunately i
found no way to prevent introducing the runtime 'nr_zones' variable.

-- mingo


[-- Attachment #2: Type: TEXT/PLAIN, Size: 3559 bytes --]

--- linux/mm/page_alloc.c.orig	Fri Nov 12 01:34:46 1999
+++ linux/mm/page_alloc.c	Fri Nov 12 02:27:22 1999
@@ -51,11 +51,13 @@
 
 #ifdef CONFIG_HIGHMEM
 # define ZONE_HIGHMEM		2
-# define NR_ZONES		3
+# define MAX_NR_ZONES		3
 #else
-# define NR_ZONES		2
+# define MAX_NR_ZONES		2
 #endif
 
+int nr_zones = MAX_NR_ZONES;
+
 typedef struct zone_struct {
 	spinlock_t lock;
 	unsigned long offset;
@@ -68,7 +70,7 @@
 	char * name;
 } zone_t;
 
-static zone_t zones[NR_ZONES] =
+static zone_t zones[MAX_NR_ZONES] =
 	{
 		{ name: "DMA" },
 		{ name: "Normal" },
@@ -120,12 +122,12 @@
 	/*
 	 * Which zone is this page belonging to.
 	 *
-	 * (NR_ZONES is low, and we do not want (yet) to introduce
+	 * (nr_zones is low, and we do not want (yet) to introduce
 	 * put page->zone, it increases the size of mem_map[]
 	 * unnecesserily. This small loop is basically equivalent
 	 * to the previous #ifdef jungle, speed-wise.)
 	 */
-	i = NR_ZONES-1;
+	i = nr_zones-1;
 	zone = zones + i;
 	for ( ; i >= 0; i--, zone--)
 		if (map_nr >= zone->offset)
@@ -345,7 +347,7 @@
 
 static inline zone_t * gfp_mask_to_zone (int gfp_mask)
 {
-	zone_t *zone;
+	zone_t *zone, *limit;
 
 #if CONFIG_HIGHMEM
 	if (gfp_mask & __GFP_HIGHMEM)
@@ -356,6 +358,9 @@
 			zone = zones + ZONE_DMA;
 		else
 			zone = zones + ZONE_NORMAL;
+	limit = zones + nr_zones-1;
+	if (zone > limit)
+		zone = limit;
 	return zone;
 }
 
@@ -383,7 +388,7 @@
 	zone_t *zone;
 
 	sum = 0;
-	for (zone = zones; zone < zones+NR_ZONES; zone++)
+	for (zone = zones; zone < zones+nr_zones; zone++)
 		sum += zone->free_pages;
 	return sum;
 }
@@ -429,7 +434,7 @@
 		freepages.low,
 		freepages.high);
 
-	for (type = 0; type < NR_ZONES; type++) {
+	for (type = 0; type < nr_zones; type++) {
 		zone_t *zone = zones + type;
  		unsigned long total = 0;
 
@@ -466,12 +471,12 @@
 void __init free_area_init(unsigned int *zones_size)
 {
 	mem_map_t * p;
-	unsigned long i, j;
+	int i, j;
 	unsigned long map_size;
 	unsigned int totalpages, offset;
 
 	totalpages = 0;
-	for (i = 0; i < NR_ZONES; i++)
+	for (i = 0; i < nr_zones; i++)
 		totalpages += zones_size[i];
 	printk("totalpages: %08x\n", totalpages);
 
@@ -514,12 +519,18 @@
 	}
 
 	offset = 0;	
-	for (j = 0; j < NR_ZONES; j++) {
+	for (j = 0; j < MAX_NR_ZONES; j++) {
 		zone_t *zone = zones + j;
 		unsigned long mask = -1;
 		unsigned long size;
 
 		size = zones_size[j];
+		printk("zone %d, size %08lx\n", j, size);
+		if (!size) {
+			printk("setting nr_zones to %d\n", nr_zones);
+			nr_zones = j;
+			break;
+		}
 		zone->size = size;
 		zone->offset = offset;
 		zone->pages_low = freepages.low;
--- linux/arch/i386/mm/init.c.orig	Fri Nov 12 01:42:51 1999
+++ linux/arch/i386/mm/init.c	Fri Nov 12 01:45:14 1999
@@ -448,12 +448,18 @@
 	kmap_init();
 #endif
 	{
-		unsigned int zones_size[3];
+		unsigned int max_dma_pfn;
+		unsigned int zones_size[3] = { 0, 0, 0 };
 
-		zones_size[0] = virt_to_phys((char *)MAX_DMA_ADDRESS)
-					 >> PAGE_SHIFT;
-		zones_size[1] = max_low_pfn - zones_size[0];
-		zones_size[2] = highend_pfn - zones_size[0] - zones_size[1];
+ 		max_dma_pfn = virt_to_phys((char *)MAX_DMA_ADDRESS)>>PAGE_SHIFT;
+		if (max_low_pfn < max_dma_pfn)
+			zones_size[0] = max_low_pfn;
+		else {
+			zones_size[0] = max_dma_pfn;
+			zones_size[1] = max_low_pfn - zones_size[0];
+			zones_size[2] = highend_pfn - zones_size[0]
+							 - zones_size[1];
+		}
 
 		free_area_init(zones_size);
 	}

             reply	other threads:[~1999-11-12 13:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-12 14:02 Ingo Molnar [this message]
1999-11-12 17:33 ` [patch] zoned-2.3.27-E0 Stephen C. Tweedie
1999-11-12 18:49   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.10.9911121502120.7240-200000@chiara.csoma.elte.hu \
    --to=mingo@chiara.csoma.elte.hu \
    --cc=linux-kernel@vger.rutgers.edu \
    --cc=sct@redhat.com \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).