to keep the sparc 64 pmap up with the others..
I had a look at a couple of thread related points.

Here's a possible diff (1 bug found I think)

any sparc64 people care to comment?
(cat-n-pasted patch)

The last addition is I think needed to not leak KV space.
The first changes are because the conditional is not needed.
This function is only ever called for uninitialised (new)
thread structures now..

Index: pmap.c
===================================================================
RCS file: /home/ncvs/src/sys/sparc64/sparc64/pmap.c,v
retrieving revision 1.58
diff -u -r1.58 pmap.c
--- pmap.c      29 May 2002 06:12:13 -0000      1.58
+++ pmap.c      4 Jul 2002 01:44:34 -0000
@@ -962,27 +962,21 @@
        /*
         * Allocate object for the kstack,
         */
-       ksobj = td->td_kstack_obj;
-       if (ksobj == NULL) {
-               ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES);
-               td->td_kstack_obj = ksobj;
-       }
+       ksobj = vm_object_allocate(OBJT_DEFAULT, KSTACK_PAGES);
+       td->td_kstack_obj = ksobj;
 
        /*
         * Get a kernel virtual address for the kstack for this thread.
         */
-       ks = td->td_kstack;
-       if (ks == 0) {
-               ks = kmem_alloc_nofault(kernel_map,
-                  (KSTACK_PAGES + KSTACK_GUARD_PAGES) * PAGE_SIZE);
-               if (ks == 0)
-                       panic("pmap_new_thread: kstack allocation
failed");
-               if (KSTACK_GUARD_PAGES != 0) {
-                       tlb_page_demap(TLB_DTLB, kernel_pmap, ks);
-                       ks += KSTACK_GUARD_PAGES * PAGE_SIZE;
-               }
-               td->td_kstack = ks;
+       ks = kmem_alloc_nofault(kernel_map,
+          (KSTACK_PAGES + KSTACK_GUARD_PAGES) * PAGE_SIZE);
+       if (ks == 0)
+               panic("pmap_new_thread: kstack allocation failed");
+       if (KSTACK_GUARD_PAGES != 0) {
+               tlb_page_demap(TLB_DTLB, kernel_pmap, ks);
+               ks += KSTACK_GUARD_PAGES * PAGE_SIZE;
        }
+       td->td_kstack = ks;
 
        for (i = 0; i < KSTACK_PAGES; i++) {
                /*
@@ -1042,6 +1036,13 @@
                td->td_kstack_obj = NULL;
                vm_object_deallocate(ksobj);
        }
+       /*
+        * don't forget to free the kmem space we were using.
+        * (including guard pages).
+        */
+       ks -= KSTACK_GUARD_PAGES * PAGE_SIZE;
+       kmem_free(kernel_map, ks,
+           (KSTACK_PAGES + KSTACK_GUARD_PAGES) * PAGE_SIZE);
 }
 
 /*



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to