freebsd-dev/sys
John Baldwin 0c0b25ae91 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
..
alpha Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
amd64 Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
arm Remove unused includes. 2004-06-28 11:35:05 +00:00
boot When building a kernel or the loader, let the hostname be overridden 2004-07-01 06:40:12 +00:00
cam Revert rev 1.140, it was a bit pre-mature. 2004-06-21 19:01:55 +00:00
coda Second half of the dev_t cleanup. 2004-06-17 17:16:53 +00:00
compat Implement SNDCTL_DSP_SETDUPLEX. This may fix sound apps which want to 2004-07-02 15:31:44 +00:00
conf Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
contrib Local change: Allow access to the field if it is within the region 2004-07-02 08:38:55 +00:00
crypto Use __FBSDID(). 2004-06-14 00:38:54 +00:00
ddb
dev Remove duplicate FreeBSD id. 2004-07-02 20:15:53 +00:00
fs Remove spls from portal_open(). Acquire socket lock while sleeping 2004-06-24 00:47:23 +00:00
geom Introduce GEOM_LABEL class. 2004-07-02 19:40:36 +00:00
gnu Fixed misformatting of code and breaking of a comment in previous commit. 2004-06-20 03:36:31 +00:00
i4b Be BURN_BRIDGES compliant 2004-06-21 21:59:00 +00:00
i386 Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
ia64 Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
isa Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
isofs/cd9660 Second half of the dev_t cleanup. 2004-06-17 17:16:53 +00:00
kern Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
libkern
modules Introduce GEOM_LABEL class. 2004-07-02 19:40:36 +00:00
net Don't announce the ethernet address when it's 00:00:00:00:00:00. It's 2004-07-02 19:44:59 +00:00
net80211 Link ALTQ to the build and break with ABI for struct ifnet. Please recompile 2004-06-13 17:29:10 +00:00
netatalk Socket MAC labels so_label and so_peerlabel are now protected by 2004-06-13 02:50:07 +00:00
netatm The socket field so_state is used to hold a variety of socket related 2004-06-14 18:16:22 +00:00
netgraph Remove the home-grown metadata facility in favour of the now generic 2004-06-30 22:51:29 +00:00
netinet On receiving 3 duplicate acknowledgements, SACK recovery was not being entered correctly. 2004-07-01 23:34:06 +00:00
netinet6 Link ALTQ to the build and break with ABI for struct ifnet. Please recompile 2004-06-13 17:29:10 +00:00
netipsec Add required includes for post-sorwakeup() change to fix FAST_IPSEC 2004-06-23 01:58:22 +00:00
netipx Acquire the receive socket buffer lock when modifying out-of-band 2004-06-24 04:29:53 +00:00
netkey Merge next step in socket buffer locking: 2004-06-21 00:20:43 +00:00
netnatm Constify send and receive space constants in natm. 2004-06-24 03:11:29 +00:00
netncp Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
netsmb Merge additional socket buffer locking from rwatson_netperf: 2004-06-17 22:48:11 +00:00
nfs
nfs4client Second half of the dev_t cleanup. 2004-06-17 17:16:53 +00:00
nfsclient When updating sb_flags, acquire the socket buffer lock to prevent 2004-06-24 03:12:13 +00:00
nfsserver Merge additional socket buffer locking from rwatson_netperf: 2004-06-17 22:48:11 +00:00
opencrypto Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
pc98 MFi386: revision 1.1163 2004-07-01 09:34:15 +00:00
pccard Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
pci Bring in the first chunk of altq driver modifications. This covers the 2004-07-02 12:16:02 +00:00
posix4
powerpc Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
rpc
security Introduce a temporary mutex, mac_ifnet_mtx, to lock MAC labels on 2004-06-24 03:34:46 +00:00
sparc64 Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
sys Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
tools Complete quirk handling script by matching the in-kernel table format. 2004-06-30 04:40:20 +00:00
ufs Annotate that we don't check the returned data length from ufs_readdir() 2004-06-24 18:31:23 +00:00
vm Implement preemption of kernel threads natively in the scheduler rather 2004-07-02 20:21:44 +00:00
Makefile