Commit Graph

93 Commits

Author SHA1 Message Date
rmind 9850c0557d sys__sched_getparam and sys__sched_getaffinity: Do not assume that LWP
with LID=1 exists, use LIST_FIRST(&p->p_lwps) instead.
Fixes PR/37987 by <yamt>.

While here, adjust license.
2008-02-22 22:32:49 +00:00
yamt 1a5be26b7e wrap a long line. 2008-01-28 12:23:42 +00:00
yamt 21832401a4 lwp_free: add assertions. 2008-01-28 10:24:45 +00:00
rmind 5c71a4d49f Implementation of processor-sets, affinity and POSIX real-time extensions.
Add schedctl(8) - a program to control scheduling of processes and threads.

Notes:
- This is supported only by SCHED_M2;
- Migration of LWP mechanism will be revisited;

Proposed on: <tech-kern>. Reviewed by: <ad>.
2008-01-15 03:37:10 +00:00
ad 79aa087ae2 - lwp_exit: if the LWP has a name, rename it to "(zombie)".
- lwp_free: don't leak l_name.
2008-01-12 18:06:40 +00:00
yamt 2e8a5bee68 lwp_ctl_alloc: fix error handling. 2008-01-07 11:41:29 +00:00
ad 4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
ad ea3f10f7e0 Merge more changes from vmlocking2, mainly:
- Locking improvements.
- Use pool_cache for more items.
2007-12-26 16:01:34 +00:00
yamt 949e16d902 use binuptime for l_stime/l_rtime. 2007-12-22 01:14:53 +00:00
yamt 555511ff96 include <sys/user.h>. 2007-12-13 05:25:03 +00:00
yamt 0c38201391 add ddb "whatis" command. inspired from solaris ::whatis dcmd. 2007-12-13 02:45:09 +00:00
ad 27f20ecf58 Soft interrupts can now take proclist_lock, so there is no need to
double-lock alllwp or allproc.
2007-12-03 20:26:24 +00:00
ad 9027344d32 For the slow path soft interrupts, arrange to have the priority of a
borrowed user LWP raised into the 'kernel RT' range if the LWP sleeps
(which is unlikely).
2007-12-03 17:14:59 +00:00
ad e2aaefb859 - mi_switch: adjust so that we don't have to hold the old LWP locked across
context switch, since cpu_switchto() can be slow under certain conditions.
  From rmind@ with adjustments by me.
- lwpctl: allow LWPs to reregister instead of returning EINVAL. Just return
  their existing lwpctl user address.
2007-12-02 14:55:32 +00:00
skrll 1587bff9f0 Explicitly include <uvm/uvm_object.h> 2007-11-13 11:38:35 +00:00
yamt a05590a3d6 lwp_ctl_alloc: fix a mutex_enter/exit mismatch. 2007-11-13 08:38:06 +00:00
ad b668a9a05f Add _lwp_ctl() system call: provides a bidirectional, per-LWP communication
area between processes and the kernel.
2007-11-12 23:11:58 +00:00
matt 11910619f7 Change some initialization of static queues to compile time.
(xxx_INIT to xxx_HEAD_INITIALIZER).  Drop code which inits
non-auto (global or static) variables to 0 since that's
already implied by being non-auto.  Init some static/global
cpu_simple_locks at compile time.
2007-11-11 23:22:23 +00:00
ad d18c6ca4de Merge from vmlocking:
- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
2007-11-07 00:23:13 +00:00
ad d831186d55 Merge scheduler changes from the vmlocking branch. All discussed on
tech-kern:

- Invert priority space so that zero is the lowest priority. Rearrange
  number and type of priority levels into bands. Add new bands like
  'kernel real time'.
- Ignore the priority level passed to tsleep. Compute priority for
  sleep dynamically.
- For SCHED_4BSD, make priority adjustment per-LWP, not per-process.
2007-11-06 00:42:39 +00:00
rmind 6673d94694 - Fix a comment: LSIDL is covered by spc_mutex, not spc_lwplock.
- mi_switch: Add a comment that spc_lwplock might not necessary be held.
2007-10-13 00:30:26 +00:00
rmind a21233e46b Import of SCHED_M2 - the implementation of new scheduler, which is based
on the original approach of SVR4 with some inspirations about balancing
and migration from Solaris.  It implements per-CPU runqueues, provides a
real-time (RT) and time-sharing (TS) queues, ready to support a POSIX
real-time extensions, and also prepared for the support of CPU affinity.

The following lines in the kernel config enables the SCHED_M2:

no options SCHED_4BSD
options SCHED_M2

The scheduler seems to be stable.  Further work will come soon.

http://mail-index.netbsd.org/tech-kern/2007/10/04/0001.html
http://www.netbsd.org/~rmind/m2/mysql_bench_ro_4x_local.png
Thanks <ad> for the benchmarks!
2007-10-09 19:00:13 +00:00
ad 0a0689eebd Merge from vmlocking: fix LWP reference counting problems. 2007-10-08 18:11:11 +00:00
ad e36f46b00e curlwp appears to be set by all active copies of cpu_switchto - remove
the MI assignments and assert that it's set in mi_switch().
2007-09-25 21:38:56 +00:00
ad 513227e941 - Fix sleepq_block() to return EINTR if the LWP is cancelled. Pointed out
by yamt@.

- Introduce SOBJ_SLEEPQ_LIFO, and use for LWPs sleeping via _lwp_park.
  libpthread enqueues most waiters in LIFO order to try and wake LWPs that
  ran recently, since their working set is more likely to be in cache.
  Matching the order of insertion reduces the time spent searching queues
  in the kernel.

- Do not boost the priority of LWPs sleeping in _lwp_park, just let them
  sleep at their user priority level. LWPs waiting for some I/O event in
  the kernel still wait with kernel priority and get woken more quickly.
  This needs more evaluation and is to be revisited, but the effect on a
  variety of benchmarks is positive.

- When waking LWPs, do not send an IPI to remote CPUs or arrange for the
  current LWP to be preempted unless (a) the thread being awoken has kernel
  priority and has higher priority than the currently running thread or (b)
  the remote CPU is idle.
2007-09-06 23:58:56 +00:00
rmind 00cdc8df70 sys__lwp_suspend: implement waiting for target LWP status changes (or
process exiting). Removes XXXLWP.

Reviewed by <ad> some time ago..
2007-08-02 01:48:44 +00:00
tnn 95342a9670 Fix previous; lwp status are states, not flags. 2007-07-31 09:56:31 +00:00
tnn 7a9d8e5613 proc_representative_lwp:
- Correct expression for checking if the lwp is running.
 - Remove dead code. Ok'd by Andrew Doran.
2007-07-31 00:52:04 +00:00
ad 46022e56e5 Update the blurb to match reality. 2007-07-28 00:12:26 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
yamt f03010953f merge yamt-idlelwp branch. asked by core@. some ports still needs work.
from doc/BRANCHES:

	idle lwp, and some changes depending on it.

	1. separate context switching and thread scheduling.
	   (cf. gmcgarry_ctxsw)
	2. implement idle lwp.
	3. clean up related MD/MI interfaces.
	4. make scheduler(s) modular.
2007-05-17 14:51:11 +00:00
ad fed1793605 Improvements to lwp_wait1(), for PR kern/35932:
- Better detect simple cycles of threads calling _lwp_wait and return
  EDEADLK. Does not handle deeper cycles like t1 -> t2 -> t3 -> t1.
- If there are multiple threads in _lwp_wait, then make sure that
  targeted waits take precedence over waits for any LWP to exit.
- When checking for deadlock, also count the number of zombies currently
  in the process as potentially reapable. Whenever a zombie is murdered,
  kick all waiters to make them check again for deadlock.
- Add more comments.

Also, while here:

- LOCK_ASSERT -> KASSERT in some places
- lwp_free: change boolean arguments to type 'bool'.
- proc_free: let lwp_free spin waiting for the last LWP to exit, there's
  no reason to do it here.
2007-03-21 18:25:59 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
ad 681b77eb72 lwp_userret: if the process is exiting, don't bother looking for signals. 2007-03-04 20:59:00 +00:00
yamt e781af39bd implement priority inheritance. 2007-02-26 09:20:52 +00:00
thorpej dd962f8680 Pick up some additional files that were missed before due to conflicts
with newlock2 merge:

Replace the Mach-derived boolean_t type with the C99 bool type.  A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 23:48:10 +00:00
ad 67323d2552 When sending signals, only boost the priority of the receiving LWP if
the process is being killed.
2007-02-20 17:47:03 +00:00
dsl d64834e4f1 Add code to support per-system call statistics:
option SYSCALL_STATS	counts the number of times each system call is made
option SYSCALL_TIMES	counts the amount of time spent in each system call
Currently the counting hooks have only been added to the i386 system call
handler, and the time spent in interrupts is not subtracted.
It ought also be possible to add the times to the processes profiling
counters in order to get a more accurate user/system/interrupt split.
The counts themselves are readable via the sysctl interface.
2007-02-18 16:58:15 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
ad a72414e44c lwp_free(): pass curlwp to KERNEL_LOCK(), not 'l'. 2007-02-16 00:35:45 +00:00
ad dc5c8ac21f Restore proc::p_userret in a limited way for Linux compat. XXX 2007-02-15 15:13:10 +00:00
yamt b8060d4382 newlwp: ensure not to assign lid 0. 2007-02-15 15:08:42 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
ad 384215762e lwp_update_creds(): acquire the kernel lock to avoid potential deadlock. 2006-12-23 08:39:47 +00:00
ad 0ff4104d82 lwp::l_acflag is no longer useful. 2006-12-22 08:04:01 +00:00
ad 1cffc415cb - issignal(): acquire the kernel lock before inspecting signal state
- lwp_exit2(): don't drop the kernel lock until after doing wakeup()
2006-11-03 19:46:03 +00:00
yamt 1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
hannken 8ea60a7f23 Remove specificdata_setspecific_nowait() as result of discussion on tech-kern.
Add _lwp_getspecific_by_lwp() to get lwp specific data from other lwp's.
Protected by #ifdef _LWP_API_PRIVATE.

Approved by: Jason Thorpe <thorpej@netbsd.org>
2006-10-24 10:05:45 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
thorpej 12e8bb915e Don't free specificdata in lwp_exit2(); it's not safe to block there.
Instead, free an LWP's specificdata from lwp_exit() (if it is not the
last LWP) or exit1() (if it is the last LWP).  For consistency, free the
proc's specificdata from exit1() as well.  Add lwp_finispecific() and
proc_finispecific() functions to make this more convenient.
2006-10-11 04:51:06 +00:00