DragonFly BSD
DragonFly commits List (threaded) for 2004-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/sys/conf options.i386 options.pc98 src/sys/i386/conf GENERIC src/sys/i386/i386 machdep.c mp_machdep.c


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Jan 2004 12:08:01 -0800 (PST)

    Exactly so.  The only reason we have any conditionalized code at all
    (TDF_IDLE_NOHLT) is to deal with BGL contention between cpus.  If cpu
    #1 owns the Big Giant Lock and cpu #2 has a runnable thread that needs
    the BGL, and no other runnable therads, cpu #2 will spin instead of 
    halt.

    That's the only special case in DFly.  All other cases are handled
    automatically due to our use of IPIs.

    Normally doing something like the BGL integration would not be desireable,
    but after much consideration I determined that the BGL was so critical to
    ongoing work that integrating it into the LWKT subsystem would provide
    far more benefit then detriment.

					-Matt
					Matthew Dillon 
					<dillon@xxxxxxxxxxxxx>

:>
:> I have no idea what he did, but from what I gather from various
:> resources is that with a lot of idleness you might want to halt the
:> respective cores a little bit more than usual to not contend too much
:> over the CPU core resources shared by both virtual CPUs.
:
:This has been taken care of already in DragonFly, and a lot easier
:because of LWKT already having the per-cpu scheduling we use an IPI
:message. Just take a look at the at cpu_idle function inside machdep.c
:
:void
:cpu_idle(void)
:{
:         struct thread *td = curthread;
:
:         crit_exit();
:         KKASSERT(td->td_pri < TDPRI_CRIT);
:         for (;;) {
:                 lwkt_switch();
:
:                 if (cpu_idle_hlt && !lwkt_runnable() &&
:                     (td->td_flags & TDF_IDLE_NOHLT) == 0) {
:                         /*
:                          * We must guarentee that hlt is exactly the 
:instruction
:                          * following the sti or we introduce a timing 
:window.
:                          */
:                         __asm __volatile("cli");
:                         splz();
:                         __asm __volatile("sti; hlt");
:                         ++cpu_idle_hltcnt;
:                 } else {
:                         td->td_flags &= ~TDF_IDLE_NOHLT;
:                         splz();
:                         __asm __volatile("sti");
:                         ++cpu_idle_spincnt;
:                 }
:         }
:}
:
:With this we when are able to have the scheduler wakeup a target cpu.
:So then if a thread wants to run on a particular cpu we just IPI that 
:cpu.
:This is why the idle loop changes don't apply here anymore, because
:we actually have fixed the performance issue with HLT'ing.
:
:-DR



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]