Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/uebayasi-xip]: src/sys Fix thinko; make vm_physseg ptr swap really work.



details:   https://anonhg.NetBSD.org/src/rev/8740e81e7403
branches:  uebayasi-xip
changeset: 751848:8740e81e7403
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Wed Nov 10 08:59:12 2010 +0000

description:
Fix thinko; make vm_physseg ptr swap really work.

diffstat:

 sys/arch/alpha/alpha/pmap.c    |   6 +++---
 sys/arch/amd64/amd64/machdep.c |   6 +++---
 sys/arch/arm/arm32/pmap.c      |   8 ++++----
 sys/arch/i386/i386/machdep.c   |   6 +++---
 sys/arch/ia64/ia64/pmap.c      |   8 ++++----
 sys/arch/mips/mips/pmap.c      |   6 +++---
 sys/arch/sh3/sh3/pmap.c        |  12 ++++++++----
 sys/uvm/uvm_page.h             |   6 +++++-
 8 files changed, 33 insertions(+), 25 deletions(-)

diffs (237 lines):

diff -r 240bceb7512e -r 8740e81e7403 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.252.2.8 2010/11/10 08:04:59 uebayasi Exp $ */
+/* $NetBSD: pmap.c,v 1.252.2.9 2010/11/10 08:59:12 uebayasi Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008 The NetBSD Foundation, Inc.
@@ -140,7 +140,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.252.2.8 2010/11/10 08:04:59 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.252.2.9 2010/11/10 08:59:12 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1063,7 +1063,7 @@
                        vm_nphysseg--;
                        for (x = bank; x < vm_nphysseg; x++) {
                                /* structure copy */
-                               *VM_PHYSMEM_PTR(x) = *VM_PHYSMEM_PTR(x + 1);
+                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
                        }
                }
 
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.141.2.6 2010/11/10 03:36:26 uebayasi Exp $       */
+/*     $NetBSD: machdep.c,v 1.141.2.7 2010/11/10 08:59:12 uebayasi Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -107,7 +107,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.141.2.6 2010/11/10 03:36:26 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.141.2.7 2010/11/10 08:59:12 uebayasi Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1182,7 +1182,7 @@
        /* Remove the last segment if it now has no pages. */
        if (vps->start == vps->end) {
                for (vm_nphysseg--; x < vm_nphysseg; x++)
-                       *VM_PHYSMEM_PTR(x) = *VM_PHYSMEM_PTR(x + 1);
+                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
        }
 
        /* Now find where the new avail_end is. */
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/arm/arm32/pmap.c Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.211.2.21 2010/11/10 08:04:59 uebayasi Exp $ */
+/*     $NetBSD: pmap.c,v 1.211.2.22 2010/11/10 08:59:13 uebayasi Exp $ */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -211,7 +211,7 @@
 #include <machine/param.h>
 #include <arm/arm32/katelib.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.21 2010/11/10 08:04:59 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.211.2.22 2010/11/10 08:59:13 uebayasi Exp $");
 
 #define        VM_PAGE_TO_MD(pg)       (&(pg)->mdpage)
 
@@ -6666,8 +6666,8 @@
                         * If we consumed the entire physseg, remove it.
                         */
                        if (ps->avail_start == ps->avail_end) {
-                               for (--vm_nphysseg; i < vm_nphysseg; i++, ps++)
-                                       *(ps[0]) = *(ps[1]);
+                               for (--vm_nphysseg; i < vm_nphysseg; i++)
+                                       VM_PHYSMEM_PTR_SWAP(i, i + 1);
                        }
                        memset((void *)rpv->pv_va, 0, rpv->pv_size);
                        return;
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/i386/i386/machdep.c      Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.681.2.6 2010/11/10 03:36:27 uebayasi Exp $       */
+/*     $NetBSD: machdep.c,v 1.681.2.7 2010/11/10 08:59:13 uebayasi Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.681.2.6 2010/11/10 03:36:27 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.681.2.7 2010/11/10 08:59:13 uebayasi Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -1209,7 +1209,7 @@
        /* Remove the last segment if it now has no pages. */
        if (vps->start == vps->end) {
                for (--vm_nphysseg; x < vm_nphysseg; x++)
-                       *VM_PHYSMEM_PTR(x) = *VM_PHYSMEM_PTR(x + 1);
+                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
        }
 
        /* Now find where the new avail_end is. */
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/ia64/ia64/pmap.c
--- a/sys/arch/ia64/ia64/pmap.c Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/ia64/ia64/pmap.c Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.24.2.7 2010/11/10 08:37:45 uebayasi Exp $ */
+/* $NetBSD: pmap.c,v 1.24.2.8 2010/11/10 08:59:13 uebayasi Exp $ */
 
 
 /*-
@@ -85,7 +85,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.24.2.7 2010/11/10 08:37:45 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.24.2.8 2010/11/10 08:59:13 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -374,7 +374,7 @@
                        vm_nphysseg--;
                        for (x = lcv; x < vm_nphysseg; x++) {
                                /* structure copy */
-                               *VM_PHYSMEM_PTR(x) = *VM_PHYSMEM_PTR(x + 1);
+                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
                        }
                }
 
@@ -471,7 +471,7 @@
                //              physmem -= end2 - start1;
                for (x = lcv; x < vm_nphysseg; x++) {
                        /* structure copy */
-                       vm_physmem_ptrs[x] = vm_physmem_ptrs[x + 1];
+                       VM_PHYSMEM_PTR_SWAP(x, x + 1);
                }
 
                /* Case 2: Perfect fit - skip segment reload. */
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/mips/mips/pmap.c
--- a/sys/arch/mips/mips/pmap.c Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/mips/mips/pmap.c Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.188.2.10 2010/11/10 03:36:28 uebayasi Exp $ */
+/*     $NetBSD: pmap.c,v 1.188.2.11 2010/11/10 08:59:13 uebayasi Exp $ */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.188.2.10 2010/11/10 03:36:28 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.188.2.11 2010/11/10 08:59:13 uebayasi Exp $");
 
 /*
  *     Manages physical address maps.
@@ -478,7 +478,7 @@
                        vm_nphysseg--;
                        for (x = bank; x < vm_nphysseg; x++) {
                                /* structure copy */
-                               *VM_PHYSMEM_PTR(x) = VM_PHYSMEM_PTR(x + 1);
+                               VM_PHYSMEM_PTR_SWAP(x, x + 1);
                        }
                }
 
diff -r 240bceb7512e -r 8740e81e7403 sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c   Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/arch/sh3/sh3/pmap.c   Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.74.2.7 2010/11/10 03:36:28 uebayasi Exp $   */
+/*     $NetBSD: pmap.c,v 1.74.2.8 2010/11/10 08:59:14 uebayasi Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74.2.7 2010/11/10 03:36:28 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74.2.8 2010/11/10 08:59:14 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -138,10 +138,14 @@
        size = round_page(size);
        npage = atop(size);
 
-       for (i = 0, bank = VM_PHYSMEM_PTR(i); i < vm_nphysseg; i++, bank++)
+       bank = NULL;
+       for (i = 0; i < vm_nphysseg; i++) {
+               bank = VM_PHYSMEM_PTR(i);
                if (npage <= bank->avail_end - bank->avail_start)
                        break;
+       }
        KDASSERT(i != vm_nphysseg);
+       KDASSERT(bank != NULL);
 
        /* Steal pages */
        pa = ptoa(bank->avail_start);
@@ -154,7 +158,7 @@
                vm_nphysseg--;
                KDASSERT(vm_nphysseg > 0);
                for (j = i; i < vm_nphysseg; j++)
-                       *VM_PHYSMEM_PTR(j) = *VM_PHYSMEM_PTR(j + 1);
+                       VM_PHYSMEM_PTR_SWAP(j, j + 1);
        }
 
        va = SH3_PHYS_TO_P1SEG(pa);
diff -r 240bceb7512e -r 8740e81e7403 sys/uvm/uvm_page.h
--- a/sys/uvm/uvm_page.h        Wed Nov 10 08:37:45 2010 +0000
+++ b/sys/uvm/uvm_page.h        Wed Nov 10 08:59:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.h,v 1.59.2.33 2010/11/04 08:47:38 uebayasi Exp $      */
+/*     $NetBSD: uvm_page.h,v 1.59.2.34 2010/11/10 08:59:12 uebayasi Exp $      */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -265,7 +265,11 @@
  */
 
 #define        VM_PHYSMEM_PTR(i)       (vm_physmem_ptrs[i])
+#define        VM_PHYSMEM_PTR_SWAP(i, j) \
+       do { VM_PHYSMEM_PTR(i) = VM_PHYSMEM_PTR(j); } while (0)
 #define        VM_PHYSDEV_PTR(i)       (vm_physdev_ptrs[i])
+#define        VM_PHYSDEV_PTR_SWAP(i, j) \
+       do { VM_PHYSDEV_PTR(i) = VM_PHYSDEV_PTR(j); } while (0)
 
 extern struct vm_physseg *vm_physmem_ptrs[VM_PHYSSEG_MAX];
 extern int vm_nphysmem;



Home | Main Index | Thread Index | Old Index