git: DragonFly_RELEASE_4_6 kernel - Disable lwp->lwp optimization in thread switcher

Matthew Dillon dillon at
Tue Jul 26 17:21:44 PDT 2016

commit 38d8acb8eea2ddd5388322d3ef399687299f727d
Author: Matthew Dillon <dillon at>
Date:   Tue Jul 26 16:24:14 2016 -0700

    kernel - Disable lwp->lwp optimization in thread switcher
    * Put #ifdef around the existing lwp->lwp switch optimization and then
      disable it.  This optimizations tries to avoid reloading %cr3 and avoid
      pmap->pm_active atomic ops when switching to a lwp that shares the same
      This optimization is no longer applicable on multi-core systems as such
      switches are very rare.  LWPs are usually distributed across multiple cores
      so rarely does one switch to another on the same core (and in cpu-bound
      situations, the scheduler will already be in batch mode).  The conditionals
      in the optimization, on the other hand, did measurably (just slightly)
      reduce performance for normal switches.  So turn it off.
    * Implement an optimization for interrupt preemptions, but disable it for
      now.  I want to keep the code handy but so far my tests show no improvement
      in performance with huge interrupt rates (from nvme devices), so it is
      #undef'd for now.

Summary of changes:
 sys/platform/pc64/x86_64/swtch.s | 132 ++++++++++++++++++++++++++++++++-------
 1 file changed, 111 insertions(+), 21 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list