Hi Thomas,

Thomas De Schampheleire wrote:
> Hi,
>
> In uts/sun4u/os/mach_startup.c, there is a function
> mach_cpu_halt_idle() which is called from startup_end() in
> uts/sun4u/os/startup.c
>
> This function has the following contents:
>
>    385 void
>    386 mach_cpu_halt_idle()
>    387 {
>    388     if (enable_halt_idle_cpus) {
>    389         if (&cpu_halt_cpu) {
>    390             idle_cpu = cpu_halt;
>    391             disp_enq_thread = cpu_wakeup;
>    392         }
>    393     }
>    394 }
>
> The cpu_halt_cpu() function is only defined for some platforms, in
> sun4u the only one I find is "olympus".
>
> In my research project we are using a full system simulator in which
> OpenSolaris runs. I would like to make OpenSolaris believe that
> halting is possible by providing my own cpu_halt_cpu() function.
>
> If I provide such a function in a kernel module, can I then re-call
> mach_cpu_halt_idle() in order to overwrite the idle_cpu() and
> disp_enq_thread() pointers? Or will this result in panic or incorrect
> behavior?
To be safe you should pause_cpus() prior to modifying these pointers to 
ensure that nobody is in the dispatcher. While doing some 
testing/experimentation i've been only marginally successful with hot 
patching these function pointers on a live system. :) 
> If this is not possible from a module, I would like to statically add
> this cpu_halt_cpu() to the correct file in uts/sun4u/cpu/ so it is
> seen at startup. I don't know which one this would be however. I am
> simulating a serengeti machine, but there are no serengeti-specific
> files in this directory. Shall I then simply put the code in the
> us3_common files?
I would give it a shot from your module.
> Just to be sure: this halt_cpu mechanism will overwrite the idle loop
> so as to halt upon idling, and wakeup when some task has to run,
> right? This halting can enable energy savings.
It doesn't overwrite it. idle_cpu is a hook in the idle() loop that gets 
invoked when the idle thread isn't successful in finding useful work 
elsewhere in the system. That function pointer maps to either cpu_halt() 
(sun4u/sun4v) or cpu_idle() (x86), which does some last minute checking 
around and housekeeping before calling the halt instruction (or the 
platform specific equivalent). Generally, that instruction suspends the 
logical CPU, until it receives an interrupt. cpu_wakeup() is invoked on 
the dispatcher side and is responsible for checking if the CPU for which 
work just became available is halted so that it can send a cross call to 
awaken it.

Yes, halting idle CPUs generally does bring the CPU/processor into a 
state where it consumes less power, and there's the performance benefit 
too on threaded processor architectures...

Thanks,
-Eric

Reply via email to