tech-kern archive

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

pmap vmlocking patch for m68k ports...



Hi

Attempting to boot a 4.99.50 DIAGNOSTIC/DEBUG/LOCKDEBUG kernel 
on a hp300 box resulted in the following panic:

...
init: copying out path `/sbin/init' 11
panic: kernel diagnostic assertion "obj == NULL || 
mutex_owned(&obj->vmobjlock)" failed: file 
"/u1/builds/build17/src/sys/uvm/uvm_page.c", line 1076
Stopped in pid 1.1 (init) at   netbsd:cpu_Debugger+0x6: unlk a6

with a traceback of:

cpu_Debugger()
panic()
__kernassert()
uvm_pageallocstrat()
pmap_enter_ptpage()
pmap_enter()
uvm_fault_internal()
trap()
copyout()
lwp_trampoline()

Digging a bit further, it seems that pmap_motorola.c for m68k archs 
hasn't been updated to the New World vmlocking.  With help from 
bjs@, I have the following patch which gets me over the above 
diagnostic panic...  

Any comments on these patches?  

Thanks.

Later...

Greg Oster
Index: include/pmap_motorola.h
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/include/pmap_motorola.h,v
retrieving revision 1.16
diff -c -r1.16 pmap_motorola.h
*** include/pmap_motorola.h     6 Jan 2008 13:25:22 -0000       1.16
--- include/pmap_motorola.h     28 Jan 2008 02:50:29 -0000
***************
*** 79,84 ****
--- 79,85 ----
  #include <sys/simplelock.h>
  #include <machine/cpu.h>
  #include <machine/pte.h>
+ #include <sys/mutex.h>
  
  #define M68K_SEG_SIZE NBSEG
  
***************
*** 92,98 ****
        st_entry_t              *pm_stpa;       /* 040: ST phys addr */
        uint16_t                pm_sref;        /* segment table ref count */
        uint16_t                pm_count;       /* pmap reference count */
!       struct simplelock       pm_lock;        /* lock on pmap */
        struct pmap_statistics  pm_stats;       /* pmap statistics */
        int                     pm_ptpages;     /* more stats: PT pages */
  };
--- 93,99 ----
        st_entry_t              *pm_stpa;       /* 040: ST phys addr */
        uint16_t                pm_sref;        /* segment table ref count */
        uint16_t                pm_count;       /* pmap reference count */
!       kmutex_t                pm_lock;        /* lock on pmap */
        struct pmap_statistics  pm_stats;       /* pmap statistics */
        int                     pm_ptpages;     /* more stats: PT pages */
  };
Index: m68k/pmap_motorola.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/pmap_motorola.c,v
retrieving revision 1.35
diff -c -r1.35 pmap_motorola.c
*** m68k/pmap_motorola.c        31 Dec 2007 13:38:51 -0000      1.35
--- m68k/pmap_motorola.c        28 Jan 2008 02:50:30 -0000
***************
*** 740,746 ****
                pmap->pm_stfree = protostfree;
  #endif
        pmap->pm_count = 1;
!       simple_lock_init(&pmap->pm_lock);
  }
  
  /*
--- 740,746 ----
                pmap->pm_stfree = protostfree;
  #endif
        pmap->pm_count = 1;
!       mutex_init(&pmap->pm_lock, MUTEX_DEFAULT, IPL_NONE);
  }
  
  /*
***************
*** 756,764 ****
  
        PMAP_DPRINTF(PDB_FOLLOW, ("pmap_destroy(%p)\n", pmap));
  
!       simple_lock(&pmap->pm_lock);
        count = --pmap->pm_count;
!       simple_unlock(&pmap->pm_lock);
        if (count == 0) {
                pmap_release(pmap);
                pool_put(&pmap_pmap_pool, pmap);
--- 756,764 ----
  
        PMAP_DPRINTF(PDB_FOLLOW, ("pmap_destroy(%p)\n", pmap));
  
!       mutex_enter(&pmap->pm_lock);
        count = --pmap->pm_count;
!       mutex_exit(&pmap->pm_lock);
        if (count == 0) {
                pmap_release(pmap);
                pool_put(&pmap_pmap_pool, pmap);
***************
*** 780,786 ****
  
  #ifdef notdef /* DIAGNOSTIC */
        /* count would be 0 from pmap_destroy... */
!       simple_lock(&pmap->pm_lock);
        if (pmap->pm_count != 1)
                panic("pmap_release count");
  #endif
--- 780,786 ----
  
  #ifdef notdef /* DIAGNOSTIC */
        /* count would be 0 from pmap_destroy... */
!       mutex_enter(&pmap->pm_lock);
        if (pmap->pm_count != 1)
                panic("pmap_release count");
  #endif
***************
*** 806,814 ****
  {
        PMAP_DPRINTF(PDB_FOLLOW, ("pmap_reference(%p)\n", pmap));
  
!       simple_lock(&pmap->pm_lock);
        pmap->pm_count++;
!       simple_unlock(&pmap->pm_lock);
  }
  
  /*
--- 806,814 ----
  {
        PMAP_DPRINTF(PDB_FOLLOW, ("pmap_reference(%p)\n", pmap));
  
!       mutex_enter(&pmap->pm_lock);
        pmap->pm_count++;
!       mutex_exit(&pmap->pm_lock);
  }
  
  /*
***************
*** 2186,2194 ****
  #endif
                        pmap_remove_mapping(pmap_kernel(), ptpva,
                            NULL, PRM_TFLUSH|PRM_CFLUSH);
!                       simple_lock(&uvm_kernel_object->vmobjlock);
                        uvm_pagefree(PHYS_TO_VM_PAGE(ptppa));
!                       simple_unlock(&uvm_kernel_object->vmobjlock);
                        PMAP_DPRINTF(PDB_REMOVE|PDB_PTPAGE,
                            ("remove: PT page 0x%lx (0x%lx) freed\n",
                            ptpva, ptppa));
--- 2186,2194 ----
  #endif
                        pmap_remove_mapping(pmap_kernel(), ptpva,
                            NULL, PRM_TFLUSH|PRM_CFLUSH);
!                       mutex_enter(&uvm_kernel_object->vmobjlock);
                        uvm_pagefree(PHYS_TO_VM_PAGE(ptppa));
!                       mutex_exit(&uvm_kernel_object->vmobjlock);
                        PMAP_DPRINTF(PDB_REMOVE|PDB_PTPAGE,
                            ("remove: PT page 0x%lx (0x%lx) freed\n",
                            ptpva, ptppa));
***************
*** 2648,2662 ****
                pmap->pm_sref++;
                PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE,
                    ("enter: about to alloc UPT pg at %lx\n", va));
!               simple_lock(&uvm_kernel_object->vmobjlock);
                while ((pg = uvm_pagealloc(uvm_kernel_object,
                                           va - vm_map_min(kernel_map),
                                           NULL, UVM_PGA_ZERO)) == NULL) {
!                       simple_unlock(&uvm_kernel_object->vmobjlock);
                        uvm_wait("ptpage");
!                       simple_lock(&uvm_kernel_object->vmobjlock);
                }
!               simple_unlock(&uvm_kernel_object->vmobjlock);
                pg->flags &= ~(PG_BUSY|PG_FAKE);
                UVM_PAGE_OWN(pg, NULL);
                ptpa = VM_PAGE_TO_PHYS(pg);
--- 2648,2662 ----
                pmap->pm_sref++;
                PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE,
                    ("enter: about to alloc UPT pg at %lx\n", va));
!               mutex_enter(&uvm_kernel_object->vmobjlock);
                while ((pg = uvm_pagealloc(uvm_kernel_object,
                                           va - vm_map_min(kernel_map),
                                           NULL, UVM_PGA_ZERO)) == NULL) {
!                       mutex_exit(&uvm_kernel_object->vmobjlock);
                        uvm_wait("ptpage");
!                       mutex_enter(&uvm_kernel_object->vmobjlock);
                }
!               mutex_exit(&uvm_kernel_object->vmobjlock);
                pg->flags &= ~(PG_BUSY|PG_FAKE);
                UVM_PAGE_OWN(pg, NULL);
                ptpa = VM_PAGE_TO_PHYS(pg);
***************
*** 2764,2776 ****
  {
        struct vm_page *pg;
  
!       simple_lock(&uvm_kernel_object->vmobjlock);
        pg = uvm_pagelookup(uvm_kernel_object, ptpva - vm_map_min(kernel_map));
        pg->wire_count++;
        PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE|PDB_SEGTAB,
            ("ptpage addref: pg %p now %d\n",
             pg, pg->wire_count));
!       simple_unlock(&uvm_kernel_object->vmobjlock);
  }
  
  /*
--- 2764,2776 ----
  {
        struct vm_page *pg;
  
!       mutex_enter(&uvm_kernel_object->vmobjlock);
        pg = uvm_pagelookup(uvm_kernel_object, ptpva - vm_map_min(kernel_map));
        pg->wire_count++;
        PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE|PDB_SEGTAB,
            ("ptpage addref: pg %p now %d\n",
             pg, pg->wire_count));
!       mutex_exit(&uvm_kernel_object->vmobjlock);
  }
  
  /*
***************
*** 2784,2796 ****
        struct vm_page *pg;
        int rv;
  
!       simple_lock(&uvm_kernel_object->vmobjlock);
        pg = uvm_pagelookup(uvm_kernel_object, ptpva - vm_map_min(kernel_map));
        rv = --pg->wire_count;
        PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE|PDB_SEGTAB,
            ("ptpage delref: pg %p now %d\n",
             pg, pg->wire_count));
!       simple_unlock(&uvm_kernel_object->vmobjlock);
        return rv;
  }
  
--- 2784,2796 ----
        struct vm_page *pg;
        int rv;
  
!       mutex_enter(&uvm_kernel_object->vmobjlock);
        pg = uvm_pagelookup(uvm_kernel_object, ptpva - vm_map_min(kernel_map));
        rv = --pg->wire_count;
        PMAP_DPRINTF(PDB_ENTER|PDB_PTPAGE|PDB_SEGTAB,
            ("ptpage delref: pg %p now %d\n",
             pg, pg->wire_count));
!       mutex_exit(&uvm_kernel_object->vmobjlock);
        return rv;
  }
  


Home | Main Index | Thread Index | Old Index