Commit Graph

73 Commits

Author SHA1 Message Date
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
thorpej 42951eac01 Upon further reflection, make lwp_{get,set}specific() operate only on
curlwp.  Things that need to operate on "other" LWPs will get a very
special (and very private) API for their needs.
2006-10-11 03:46:42 +00:00
martin fadbb60986 Remove unused variables. 2006-10-09 00:39:06 +00:00
christos 057b918239 add {proc,lwp}_initspecific and use them to init proc0 and lwp0. 2006-10-08 22:57:11 +00:00
thorpej 04e486d9f8 Add specificdata support to procs and lwps, each providing their own
wrappers around the speicificdata subroutines.  Also:
- Call the new lwpinit() function from main() after calling procinit().
- Move some pool initialization out of kern_proc.c and into files that
  are directly related to the pools in question (kern_lwp.c and kern_ras.c).
- Convert uipc_sem.c to proc_{get,set}specific(), and eliminate the p_ksems
  member from struct proc.
2006-10-08 04:28:44 +00:00
ad 87dd042f7a sys__lwp_create: put newuc back to the pool on failure. 2006-08-14 14:11:21 +00:00
ad a0c8510a86 Single-thread updates to the process credential. 2006-07-30 21:58:11 +00:00
ad fe65535924 Try again.. Move l_cred into the startzero section, and fix the define.
Doesn't change the layout of struct lwp.
2006-07-20 00:17:10 +00:00
ad 2b79369c7e - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
2006-07-19 21:11:37 +00:00
yamt 1075c99d89 introduce macros, UAREA_TO_USER and USER_TO_UAREA,
to convert uarea VA into a pointer to struct user and vice versa,
so that MD code can change the layout in uarea.
2006-05-22 13:43:54 +00:00
yamt a0e5478237 lwp_suspend: don't forget to decrement p_nrlwps when suspending ourselves.
fix PR/33287 from Gregory McGarry.
2006-04-26 11:44:39 +00:00
cube 699fe710fb Rework the _lwp* and sa_* families of syscalls so some details can be
handled differently depending on the emulation.  This paves the way for
COMPAT_NETBSD32 support of our pthread system.
2006-03-29 23:02:31 +00:00
chs 6c854a4076 disallow non-SA LWP syscalls for SA processes. they add no value
in this context, only headaches.
2005-11-12 02:28:31 +00:00
yamt d6d16da423 remove a redundant assignment in the previous. 2005-10-05 15:46:00 +00:00
yamt f615d37667 simplify lwp exit code. 2005-10-01 06:12:44 +00:00
yamt 9020ca379a protect p_nrlwps by sched_lock. no objection on tech-kern@. PR/29652. 2005-08-28 14:57:18 +00:00
fvdl 7b10f1cabc Don't panic when lwp_suspend finds an LWP on another CPU, just return
EINVAL for now.
2005-02-12 21:39:00 +00:00
skrll d42dfb7727 Correct arg name in comment. 2004-10-06 08:55:27 +00:00
matt 617ba1df60 In proc_representative_lwp, if there is an outstanding trap signal, return
the lwp that had the trap.
2004-05-12 21:10:09 +00:00
junyoung 103afd6ebf lwp_exit2(): set lwp state to SZOMB at more appropriate point. 2004-03-05 11:17:41 +00:00
yamt 471ef5f249 once exit1() releases big kernel lock, the struct proc can be freed and
re-used by another cpu immediately.  in that case, lwp_exit2() will
access freed memory.  to fix this:

- remove curlwp from p_lwps in exit1() rather than letting lwp_exit2() do so.
- add assertions to ensure freed proc has no lwps.

kern/24329 from me and kern/24574 from Havard Eidnes.
2004-03-02 09:15:26 +00:00