freebsd-skq/sys/sparc64
jhb 696704716d Implement preemption of kernel threads natively in the scheduler rather
than as one-off hacks in various other parts of the kernel:
- Add a function maybe_preempt() that is called from sched_add() to
  determine if a thread about to be added to a run queue should be
  preempted to directly.  If it is not safe to preempt or if the new
  thread does not have a high enough priority, then the function returns
  false and sched_add() adds the thread to the run queue.  If the thread
  should be preempted to but the current thread is in a nested critical
  section, then the flag TDF_OWEPREEMPT is set and the thread is added
  to the run queue.  Otherwise, mi_switch() is called immediately and the
  thread is never added to the run queue since it is switch to directly.
  When exiting an outermost critical section, if TDF_OWEPREEMPT is set,
  then clear it and call mi_switch() to perform the deferred preemption.
- Remove explicit preemption from ithread_schedule() as calling
  setrunqueue() now does all the correct work.  This also removes the
  do_switch argument from ithread_schedule().
- Do not use the manual preemption code in mtx_unlock if the architecture
  supports native preemption.
- Don't call mi_switch() in a loop during shutdown to give ithreads a
  chance to run if the architecture supports native preemption since
  the ithreads will just preempt DELAY().
- Don't call mi_switch() from the page zeroing idle thread for
  architectures that support native preemption as it is unnecessary.
- Native preemption is enabled on the same archs that supported ithread
  preemption, namely alpha, i386, and amd64.

This change should largely be a NOP for the default case as committed
except that we will do fewer context switches in a few cases and will
avoid the run queues completely when preempting.

Approved by:	scottl (with his re@ hat)
2004-07-02 20:21:44 +00:00
..
central Add missing <sys/module.h> instances which were shadowed by the nested 2004-06-03 05:58:30 +00:00
compile
conf Better OFW console support on Sun Ultra2 machines. 2004-06-24 02:57:11 +00:00
creator Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
ebus These need __RMAN_RESOURCE_VISIBLE, too. 2004-06-30 23:21:07 +00:00
fhc These need __RMAN_RESOURCE_VISIBLE, too. 2004-06-30 23:21:07 +00:00
include Retire BUS_DMAMAP_NSEGS for sparc64 2004-06-28 04:04:43 +00:00
isa - Remove the old sparc64 OFW PCI code (as opposed to the former 2004-05-08 13:53:47 +00:00
pci These need __RMAN_RESOURCE_VISIBLE, too. 2004-06-30 23:21:07 +00:00
sbus These need __RMAN_RESOURCE_VISIBLE, too. 2004-06-30 23:21:07 +00:00
sparc64 Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00