Skip to contentSkip to conversation

adjust BAT mapping according to max_low_mem

PATCH In review Val Henson 2 participants 3 messages Feb 8, 2002 – Feb 9, 2002

lore
Share & tools
lore

Val Henson

author
#0 lore raw

PATCH 1/1 adjust BAT mapping according to max_low_mem

I'm testing highmem by setting max_low_mem to 64MB and using 256MB RAM total (this does not trigger my SCSI bug). I had to change a few things in adjust_total_lowmem to force it to _not_ BAT map of all the RAM. I think the printout of residual is wrong but I'm not sure.

-VAL

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux 2.4 for PowerPC development tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.201 -> 1.202
# arch/ppc/mm/pgtable.c 1.15 -> 1.16
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/02/08 [email protected] 1.202
# Fix bat calculations to take into account max_low_mem. This maps only the

# max_low_mem RAM with BATs, so you can test the highmem code on machines with
# less ram.  The printout of "residual" is probably wrong, since it now only
# lists the residual lowmem, rather than all residual mem.
# --------------------------------------------
#
diff -Nru a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
--- a/arch/ppc/mm/pgtable.c	Fri Feb  8 13:29:29 2002
+++ b/arch/ppc/mm/pgtable.c	Fri Feb  8 13:29:29 2002
@@ -205,7 +205,7 @@
 #ifdef HAVE_BATS
 	unsigned long bat_max = 0x10000000;
 	unsigned long align;
-	unsigned long ram = total_lowmem;
+	unsigned long ram;
 	int is601 = 0;

/* 601s have smaller BATs */
@@ -213,6 +213,16 @@
bat_max = 0x00800000;
is601 = 1;
}
+
+ /* adjust BAT block size to max_low_mem */
+ if (max_low_mem < bat_max)
+ bat_max = max_low_mem;
+
+ /* adjust lowmem size to max_low_mem */
+ if (max_low_mem < total_lowmem)
+ total_lowmem = max_low_mem;
+
+ ram = total_lowmem;

/* Make sure we don't map a block larger than the
smallest alignment of the physical address. */

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#1 lore raw
Quoted 4 lines · Val Henson

I'm testing highmem by setting max_low_mem to 64MB and using 256MB RAM total (this does not trigger my SCSI bug). I had to change a few things in adjust_total_lowmem to force it to _not_ BAT map of all the RAM. I think the printout of residual is wrong but I'm not sure.

If I'm reading all of the code right, residual at this point should be (total_lowmem (initial value) - ram mapped in BATs), so I think this:

Review

Quoted 9 lines
(quoted diff) +9 -0
+	/* adjust BAT block size to max_low_mem */
+	if (max_low_mem < bat_max)
+		bat_max = max_low_mem;
+
+	/* adjust lowmem size to max_low_mem */
+	if (max_low_mem < total_lowmem)
+		total_lowmem = max_low_mem;
+
+	ram = total_lowmem;

Should be:

	/* adjust BAT block size to max_low_mem */
	if (max_low_mem < bat_max)
		bat_max = max_low_mem;

	/* adjust lowmem size to max_low_mem */
	if (max_low_mem < total_lowmem)
		ram = max_low_mem;
	else
		ram = total_lowmem;
	...

	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb, "
		"residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
		(total_lowmem - ram) >> 20);

Does this sound right?

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 22 lines · Tom Rini
Quoted 4 lines · Val Henson

I'm testing highmem by setting max_low_mem to 64MB and using 256MB RAM total (this does not trigger my SCSI bug). I had to change a few things in adjust_total_lowmem to force it to _not_ BAT map of all the RAM. I think the printout of residual is wrong but I'm not sure.

If I'm reading all of the code right, residual at this point should be (total_lowmem (initial value) - ram mapped in BATs), so I think this:

Review

Quoted 9 lines
(quoted diff) +9 -0
+	/* adjust BAT block size to max_low_mem */
+	if (max_low_mem < bat_max)
+		bat_max = max_low_mem;
+
+	/* adjust lowmem size to max_low_mem */
+	if (max_low_mem < total_lowmem)
+		total_lowmem = max_low_mem;
+
+	ram = total_lowmem;

Should be:

Quoted 14 lines
	/* adjust BAT block size to max_low_mem */
	if (max_low_mem < bat_max)
		bat_max = max_low_mem;

	/* adjust lowmem size to max_low_mem */
	if (max_low_mem < total_lowmem)
		ram = max_low_mem;
	else
		ram = total_lowmem;
	...

	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb, "
		"residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
		(total_lowmem - ram) >> 20);

And after actually testing:

	printk(KERN_INFO "...
		(total_lowmem - (__bat2 + __bat3)) >> 20);

If someone else can confirm that the above thinking is right, I'll check in the following patch, which fixes this and the printk for more RAM than BATS && !CONFIG_HIGHMEM

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

===== arch/ppc/mm/pgtable.c 1.15 vs edited =====

arch/ppc/mm/pgtable.c +17 -5
@@ -205,7 +205,7 @@
 #ifdef HAVE_BATS
 	unsigned long bat_max = 0x10000000;
 	unsigned long align;
-	unsigned long ram = total_lowmem;
+	unsigned long ram;
 	int is601 = 0;
 
 	/* 601s have smaller BATs */
@@ -214,6 +214,16 @@
 		is601 = 1;
 	}
 
+	/* adjust BAT block size to max_low_mem */
+	if (max_low_mem < bat_max)
+		bat_max = max_low_mem;
+
+	/* adjust lowmem size to max_low_mem */
+	if (max_low_mem < total_lowmem)
+		ram = max_low_mem;
+	else
+		ram = total_lowmem;
+
 	/* Make sure we don't map a block larger than the
 	   smallest alignment of the physical address. */
 	/* alignment of PPC_MEMSTART */
@@ -234,8 +244,9 @@
 		ram -= __bat3;
 	}
 
-	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb, residual: %ldMb\n",
-		__bat2 >> 20, __bat3 >> 20, ram >> 20);
+	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb,"
+			" residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
+			(total_lowmem - (__bat2 - __bat3)) >> 20);
 
 	/* On SMP, we limit the lowmem to the area mapped with BATs.
 	 * We also assume nobody will do SMP with 601s
@@ -249,8 +260,9 @@
 	if (total_lowmem > max_low_mem) {
 		total_lowmem = max_low_mem;
 #ifndef CONFIG_HIGHMEM
-		printk(KERN_INFO "Warning, memory limited to %ld Mb, use CONFIG_HIGHMEM"
-			" to reach %ld Mb\n", max_low_mem >> 20, total_lowmem >> 20);
+		printk(KERN_INFO "Warning, memory limited to %ld Mb, use "
+				" CONFIG_HIGHMEM to reach %ld Mb\n",
+				max_low_mem >> 20, total_memory >> 20);
 		total_memory = total_lowmem;
 #endif /* CONFIG_HIGHMEM */
 	}

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/