Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jul 2002 18:50:01 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        FreeBSD current users <current@freebsd.org>
Subject:   sparc64 patch for testing.
Message-ID:  <Pine.BSF.4.21.0207031845140.3993-100000@InterJet.elischer.org>

next in thread | raw e-mail | index | archive | help

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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0207031845140.3993-100000>