Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Apr 2003 19:20:04 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 29038 for review
Message-ID:  <200304160220.h3G2K4xk080500@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29038

Change 29038 by marcel@marcel_nfs on 2003/04/15 19:19:30

	Stop using contigmalloc() for allocating thread stacks. Use
	malloc() instead. Cursory testing didn't cause nested TLB
	faults yet, so it isn't immediately breaking anything. Once
	we have the syscall path worked out more, we should be able
	to cause a nested TLB fault. This will be used to write the
	exception handling code and see if we can make it work at
	all...

Affected files ...

.. //depot/projects/ia64_epc/sys/ia64/ia64/mp_machdep.c#5 edit
.. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#4 edit
.. //depot/projects/ia64_epc/sys/ia64/include/proc.h#2 edit

Differences ...

==== //depot/projects/ia64_epc/sys/ia64/ia64/mp_machdep.c#5 (text+ko) ====

@@ -214,22 +214,8 @@
 		pc->pc_current_pmap = kernel_pmap;
 		pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask;
 		if (pc->pc_cpuid > 0) {
-			void *ks;
-
-			/*
-			 * Use contigmalloc for stack so that we can
-			 * use a region 7 address for it which makes
-			 * it impossible to accidentally lose when
-			 * recording a trapframe.
-			 */
-			ks = contigmalloc(KSTACK_PAGES * PAGE_SIZE, M_TEMP,
-					  M_WAITOK,
-					  0ul,
-					  256*1024*1024 - 1,
-					  PAGE_SIZE,
-					  256*1024*1024);
-
-			ap_stack = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)ks));
+			ap_stack = malloc(KSTACK_PAGES * PAGE_SIZE, M_PMAP,
+			    M_WAITOK);
 			ap_pcpu = pc;
 			ap_delay = 2000;
 			ap_awake = 0;

==== //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#4 (text+ko) ====

@@ -127,6 +127,10 @@
 
 MALLOC_DEFINE(M_PMAP, "PMAP", "PMAP Structures");
 
+#ifndef KSTACK_MAX_PAGES
+#define KSTACK_MAX_PAGES 32
+#endif
+
 #ifndef PMAP_SHPGPERPROC
 #define PMAP_SHPGPERPROC 200
 #endif
@@ -727,10 +731,6 @@
 		return 0;
 }
 
-#ifndef KSTACK_MAX_PAGES
-#define KSTACK_MAX_PAGES 32
-#endif
-
 /*
  * Create the KSTACK for a new thread.
  * This routine directly affects the fork perf for a process/thread.
@@ -738,27 +738,14 @@
 void
 pmap_new_thread(struct thread *td, int pages)
 {
-	vm_offset_t *ks;
 
 	/* Bounds check */
 	if (pages <= 1)
 		pages = KSTACK_PAGES;
 	else if (pages > KSTACK_MAX_PAGES)
 		pages = KSTACK_MAX_PAGES;
-
-	/*
-	 * Use contigmalloc for user area so that we can use a region
-	 * 7 address for it which makes it impossible to accidentally
-	 * lose when recording a trapframe.
-	 */
-	ks = contigmalloc(pages * PAGE_SIZE, M_PMAP, M_WAITOK, 0ul,
-	    256*1024*1024 - 1, PAGE_SIZE, 256*1024*1024);
-	if (ks == NULL)
-		panic("pmap_new_thread: could not contigmalloc %d pages\n",
-		    pages);
-
-	td->td_md.md_kstackvirt = ks;
-	td->td_kstack = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)ks));
+	td->td_kstack = (vm_offset_t)malloc(pages * PAGE_SIZE, M_PMAP,
+	    M_WAITOK);
 	td->td_kstack_pages = pages;
 }
 
@@ -769,12 +756,10 @@
 void
 pmap_dispose_thread(struct thread *td)
 {
-	int pages;
 
-	pages = td->td_kstack_pages;
-	contigfree(td->td_md.md_kstackvirt, pages * PAGE_SIZE, M_PMAP);
-	td->td_md.md_kstackvirt = NULL;
+	free((void*)td->td_kstack, M_PMAP);
 	td->td_kstack = 0;
+	td->td_kstack_pages = 0;
 }
 
 /*
@@ -784,16 +769,9 @@
 pmap_new_altkstack(struct thread *td, int pages)
 {
 
-	/*
-	 * Shuffle the original stack. Save the virtual kstack address
-	 * instead of the physical address because 1) we can derive the
-	 * physical address from the virtual address and 2) we need the
-	 * virtual address in pmap_dispose_thread.
-	 */
+	td->td_altkstack = td->td_kstack;
 	td->td_altkstack_obj = td->td_kstack_obj;
-	td->td_altkstack = (vm_offset_t)td->td_md.md_kstackvirt;
 	td->td_altkstack_pages = td->td_kstack_pages;
-
 	pmap_new_thread(td, pages);
 }
 
@@ -802,13 +780,7 @@
 {
 
 	pmap_dispose_thread(td);
-
-	/*
-	 * Restore the original kstack. Note that td_altkstack holds the
-	 * virtual kstack address of the previous kstack.
-	 */
-	td->td_md.md_kstackvirt = (void*)td->td_altkstack;
-	td->td_kstack = IA64_PHYS_TO_RR7(ia64_tpa(td->td_altkstack));
+	td->td_kstack = td->td_altkstack;
 	td->td_kstack_obj = td->td_altkstack_obj;
 	td->td_kstack_pages = td->td_altkstack_pages;
 	td->td_altkstack = 0;

==== //depot/projects/ia64_epc/sys/ia64/include/proc.h#2 (text+ko) ====

@@ -37,7 +37,6 @@
 
 struct mdthread {
 	u_long		md_flags;
-	void		*md_kstackvirt;	/* virtual address of td_kstack */
 	vm_offset_t	md_bspstore;	/* initial ar.bspstore */
 	register_t	md_savecrit;
 };
@@ -50,7 +49,7 @@
 #define MDP_UAC_MASK	(MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS)
 
 struct mdproc {
-	struct user	*md_uservirt;	/* virtual address of p_addr */
+	int		__dummy;	/* Avoid having an empty struct. */
 };
 
 #endif /* !_MACHINE_PROC_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304160220.h3G2K4xk080500>