Linux MIPS Architecture development
 help / color / mirror / Atom feed
* pgd_init() Patch
@ 2002-01-28 13:36 Phil Thompson
  2002-01-28 19:53 ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Phil Thompson @ 2002-01-28 13:36 UTC (permalink / raw)
  To: linux-mips

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

While trying to understand the changes needed for discontiguous memory I
came across this...

In paging_init() there are two calls to pgd_init()...

        /* Initialize the entire pgd.  */
        pgd_init((unsigned long)swapper_pg_dir);
        pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);

...where the assumption seems to be that the PGD is one page and each
call initialises half of it. Most of the CPU implementations of
pgd_init() nearly do this because they initialise USER_PTRS_PER_PGD
entries. The problems with this are...

- pg-r3k.c and pg-r4k.S don't use USER_PTRS_PER_PGD and initialise a
page's worth each time. This means the second call to pgd_init()
initialises half a page's worth of memory after the end of
swapper_pg_dir.

- USER_PTRS_PER_PGD is defined as TASK_SIZE/PGDIR_SIZE. However,
because, TASK_SIZE is actually defined as one less that the maximum task
size there is a rounding error that means that USER_PTRS_PER_PGD works
out at 511 rather than 512. This means that entries 511 and 1023 of
swapper_pg_dir don't get initialised.

The corresponding mips64 code has only the first call to pgd_init() and
each implementation of pgd_init() initialises PTRS_PER_PGD entries,
where PTRS_PER_PGD is simple defined as 1024.

The attached patch applies the mips64 approach to the mips code.

Should USER_PTRS_PER_PGD be defined as (TASK_SIZE/PGDIR_SIZE) + 1?

Phil

[-- Attachment #2: mm.patch --]
[-- Type: text/plain, Size: 2116 bytes --]

diff -ruN mm.orig/c-sb1.c mm/c-sb1.c
--- mm.orig/c-sb1.c	Wed Dec 12 16:25:01 2001
+++ mm/c-sb1.c	Mon Jan 28 12:37:20 2002
@@ -44,7 +44,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for (i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/init.c mm/init.c
--- mm.orig/init.c	Fri Jan 25 14:17:12 2002
+++ mm/init.c	Mon Jan 28 12:37:36 2002
@@ -152,7 +152,6 @@
 
 	/* Initialize the entire pgd.  */
 	pgd_init((unsigned long)swapper_pg_dir);
-	pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);
 
 	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
 	low = max_low_pfn;
diff -ruN mm.orig/pg-mips32.c mm/pg-mips32.c
--- mm.orig/pg-mips32.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-mips32.c	Mon Jan 28 12:37:56 2002
@@ -127,7 +127,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for(i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for(i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/pg-r5432.c mm/pg-r5432.c
--- mm.orig/pg-r5432.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-r5432.c	Mon Jan 28 12:38:30 2002
@@ -104,7 +104,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for(i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for(i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/pg-rm7k.c mm/pg-rm7k.c
--- mm.orig/pg-rm7k.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-rm7k.c	Mon Jan 28 12:38:38 2002
@@ -107,7 +107,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for (i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-01-28 21:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-28 13:36 pgd_init() Patch Phil Thompson
2002-01-28 19:53 ` Geert Uytterhoeven
2002-01-28 20:03   ` Pete Popov
2002-01-28 20:04   ` Jun Sun
2002-01-28 20:26     ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox