Patch to optimize "bare" critical sections

Peter Grehan grehan at freebsd.org
Tue Nov 30 01:03:24 PST 2004


 > Ahem, http://www.FreeBSD.org/~jhb/patches/spinlock.patch

  Seems to work OK on PowerPC. I left cpufunc.h unchanged - I don't
think the mod to intr_restore() is required, and with the following
slight mods. The saved msr was incorrect: the forked process would
be resumed without address translation enabled :)

later,

Peter.

 > lcvs diff -u powerpc/vm_machdep.c include/psl.h
Index: powerpc/vm_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/powerpc/powerpc/vm_machdep.c,v
retrieving revision 1.105
diff -u -r1.105 vm_machdep.c
--- powerpc/vm_machdep.c        27 Nov 2004 06:51:38 -0000      1.105
+++ powerpc/vm_machdep.c        30 Nov 2004 08:08:10 -0000
@@ -154,6 +154,10 @@
         pcb->pcb_lr = (register_t)fork_trampoline;
         pcb->pcb_usr = kernel_pmap->pm_sr[USER_SR];

+       /* Setup to release sched_lock in fork_exit(). */
+       td2->td_md.md_spinlock_count = 1;
+       td2->td_md.md_saved_msr = PSL_KERNSET;
+
         /*
          * Now cpu_switch() can schedule the new process.
          */
@@ -329,6 +333,10 @@
         pcb2->pcb_sp = (register_t)cf;
         pcb2->pcb_lr = (register_t)fork_trampoline;
         pcb2->pcb_usr = kernel_pmap->pm_sr[USER_SR];
+
+       /* Setup to release sched_lock in fork_exit(). */
+       td->td_md.md_spinlock_count = 1;
+       td->td_md.md_saved_msr = PSL_KERNSET;
  }

  void
Index: include/psl.h
===================================================================
RCS file: /home/ncvs/src/sys/powerpc/include/psl.h,v
retrieving revision 1.2
diff -u -r1.2 psl.h
--- include/psl.h       19 May 2002 04:03:11 -0000      1.2
+++ include/psl.h       30 Nov 2004 09:03:56 -0000
@@ -78,7 +78,8 @@
  #define        PSL_MBO         0
  #define        PSL_MBZ         0

-#define        PSL_USERSET     (PSL_EE | PSL_PR | PSL_ME | PSL_IR | 
PSL_DR | PSL_RI)
+#define        PSL_KERNSET     (PSL_EE | PSL_ME | PSL_IR | PSL_DR | PSL_RI)
+#define        PSL_USERSET     (PSL_KERNSET | PSL_PR)

  #define        PSL_USERSTATIC  (PSL_USERSET | PSL_IP | 0x87c0008c)





More information about the freebsd-ppc mailing list