git: kernel - Optimize idle thread halt

Matthew Dillon dillon at
Sun Dec 19 11:24:01 PST 2010

commit be71787bd3c8d2d199af9bb30ffb6df730c6b858
Author: Matthew Dillon <dillon at>
Date:   Sun Dec 19 11:17:36 2010 -0800

    kernel - Optimize idle thread halt
    * Count the number of times the idle thread is entered on a cpu without
      switching to a non-idle thread.  Use the fast-halt (non-ACPI) until the
      count exceeds a reasonable machdep.cpu_idle_repeat.
      This improves the default performance to levels closer to cpu_idle_hlt
      mode 1 but still gives us the power savings from mode 3.  Performanced is
      improved significantly because many threads on SMP boxes are event
      or pipe oriented and only sleep for short periods of time or ping-pong
      back and forth.  For example, a cc -pipe, or typical kernel threads
      blocking on tokens or locks for short periods of time.
    * Adjust machdep.cpu_idle_hlt modes:
        0	Never halt, the idle thread just spins.
        1	Always use a fast HLT/MONITOR/MWAIT
        2	Hybrid approach use (1) up to a certain point, then use (3).
    	(this is the default)
        3	Always use the ACPI halt

Summary of changes:
 sys/kern/lwkt_thread.c             |    4 ++
 sys/platform/pc32/i386/machdep.c   |   55 ++++++++++++++++++++++++++++++-----
 sys/platform/pc64/x86_64/machdep.c |   47 ++++++++++++++++++++++++++----
 sys/sys/globaldata.h               |    5 ++-
 4 files changed, 96 insertions(+), 15 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list