Change 58299 by rwatson@rwatson_tislabs on 2004/07/27 14:52:18

	Add a 'td' argument to cpu_critical_{enter,exit}() -- this avoids
	needlessly dereferencing curthread again, given that critical_enter()
	and critical_exit() both already do that, and we're inlining.  This
	boosts transaction throughput for MySQL on UP by about 1.5% on my
	P4.

Affected files ...

... //depot/user/rwatson/netperf/sys/alpha/include/critical.h#5 edit
... //depot/user/rwatson/netperf/sys/amd64/include/critical.h#5 edit
... //depot/user/rwatson/netperf/sys/arm/include/critical.h#2 edit
... //depot/user/rwatson/netperf/sys/i386/include/critical.h#7 edit
... //depot/user/rwatson/netperf/sys/ia64/include/critical.h#5 edit
... //depot/user/rwatson/netperf/sys/kern/kern_switch.c#8 edit
... //depot/user/rwatson/netperf/sys/powerpc/include/critical.h#5 edit
... //depot/user/rwatson/netperf/sys/sparc64/include/critical.h#5 edit

Differences ...

==== //depot/user/rwatson/netperf/sys/alpha/include/critical.h#5 (text+ko) ====

@@ -55,11 +55,9 @@
  *	of td_critnest, prior to it being incremented to 1.
  */
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	struct thread *td;
 
-	td = curthread;
 	td->td_md.md_savecrit = intr_disable();
 }
 
@@ -71,18 +69,16 @@
  *	exiting the last critical section.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	struct thread *td;
 
-	td = curthread;
 	intr_restore(td->td_md.md_savecrit);
 }
 
 #else /* !__GNUC__ */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td);
+void cpu_critical_exit(struct thread *td);
 
 #endif	/* __GNUC__ */
 

==== //depot/user/rwatson/netperf/sys/amd64/include/critical.h#5 (text+ko) ====

@@ -55,9 +55,10 @@
  *	of td_critnest, prior to it being incremented to 1.
  */
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	curthread->td_md.md_savecrit = intr_disable();
+
+	td->td_md.md_savecrit = intr_disable();
 }
 
 /*
@@ -68,15 +69,15 @@
  *	exiting the last critical section.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	intr_restore(curthread->td_md.md_savecrit);
+	intr_restore(td->td_md.md_savecrit);
 }
 
 #else /* !__GNUC__ */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td);
+void cpu_critical_exit(struct thread *td);
 
 #endif	/* __GNUC__ */
 

==== //depot/user/rwatson/netperf/sys/arm/include/critical.h#2 (text+ko) ====

@@ -40,15 +40,15 @@
 #define MACHINE_CRITICAL_H
 void cpu_critical_fork_exit(void);
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	curthread->td_md.md_savecrit = disable_interrupts(I32_bit | F32_bit);
+	cd->td_md.md_savecrit = disable_interrupts(I32_bit | F32_bit);
 }
 
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	restore_interrupts(curthread->td_md.md_savecrit);
+	restore_interrupts(td->td_md.md_savecrit);
 }
 
 #endif

==== //depot/user/rwatson/netperf/sys/i386/include/critical.h#7 (text+ko) ====

@@ -59,9 +59,9 @@
  *	is non-zero will be deferred.
  */
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	curthread->td_md.md_savecrit = intr_disable();
+	td->td_md.md_savecrit = intr_disable();
 }
 
 /*
@@ -76,15 +76,15 @@
  *	code for us, so we do not have to do anything fancy.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	intr_restore(curthread->td_md.md_savecrit);
+	intr_restore(td->td_md.md_savecrit);
 }
 
 #else /* !(__GNUC__ || __INTEL_COMPILER) */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td);
+void cpu_critical_exit(struct thread *td);
 
 #endif        /* __GNUC__ || __INTEL_COMPILER */
 

==== //depot/user/rwatson/netperf/sys/ia64/include/critical.h#5 (text+ko) ====

@@ -55,11 +55,9 @@
  *	of td_critnest, prior to it being incremented to 1.
  */
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	struct thread *td;
 
-	td = curthread;
 	td->td_md.md_savecrit = intr_disable();
 }
 
@@ -71,19 +69,17 @@
  *	exiting the last critical section.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	struct thread *td;
 
-	td = curthread;
 	intr_restore(td->td_md.md_savecrit);
 }
 
 
 #else /* !__GNUC__ */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td)
+void cpu_critical_exit(struct thread *td)
 
 #endif	/* __GNUC__ */
 

==== //depot/user/rwatson/netperf/sys/kern/kern_switch.c#8 (text+ko) ====

@@ -437,7 +437,7 @@
 
 	td = curthread;
 	if (td->td_critnest == 0)
-		cpu_critical_enter();
+		cpu_critical_enter(td);
 	td->td_critnest++;
 }
 
@@ -459,7 +459,7 @@
 		}
 #endif
 		td->td_critnest = 0;
-		cpu_critical_exit();
+		cpu_critical_exit(td);
 	} else {
 		td->td_critnest--;
 	}

==== //depot/user/rwatson/netperf/sys/powerpc/include/critical.h#5 (text+ko) ====

@@ -56,10 +56,9 @@
  */
 
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
 	u_int           msr;
-	struct thread	*td = curthread;
 
 	msr = mfmsr();
 	td->td_md.md_savecrit = msr;
@@ -75,9 +74,8 @@
  *	exiting the last critical section.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	struct thread *td = curthread;
 
 	mtmsr(td->td_md.md_savecrit);
 }
@@ -85,8 +83,8 @@
 
 #else /* !__GNUC__ */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td);
+void cpu_critical_exit(struct thread *td);
 
 #endif	/* __GNUC__ */
 

==== //depot/user/rwatson/netperf/sys/sparc64/include/critical.h#5 (text+ko) ====

@@ -55,12 +55,10 @@
  *	of td_critnest, prior to it being incremented to 1.
  */
 static __inline void
-cpu_critical_enter(void)
+cpu_critical_enter(struct thread *td)
 {
-	struct thread *td;
 	critical_t pil;
 
-	td = curthread;
 	pil = rdpr(pil);
 	wrpr(pil, 0, 14);
 	td->td_md.md_savecrit = pil;
@@ -75,18 +73,16 @@
  *	exiting the last critical section.
  */
 static __inline void
-cpu_critical_exit(void)
+cpu_critical_exit(struct thread *td)
 {
-	struct thread *td;
 
-	td = curthread;
 	wrpr(pil, td->td_md.md_savecrit, 0);
 }
 
 #else /* !__GNUC__ */
 
-void cpu_critical_enter(void);
-void cpu_critical_exit(void);
+void cpu_critical_enter(struct thread *td);
+void cpu_critical_exit(struct thread *td);
 
 #endif	/* __GNUC__ */
 
