Commit Graph

219 Commits

Author SHA1 Message Date
ad
727b89a296 Add a preemption counter to lwpctl_t, to allow user threads to detect that
they have been preempted.
2008-03-12 11:00:43 +00:00
ad
a108a15f5d Make context switch + syscall counters optionally per-CPU and accumulate
in schedclock() at "about 16 hz".
2008-03-11 02:24:43 +00:00
ad
60c1b8843d Make schedstate_percpu::spc_lwplock an exernally allocated item. Remove
the hacks in sparc/cpu.c to reinitialize it. This should be in its own
cache line but that's another change.
2008-02-14 14:26:57 +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
0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
ad
4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
ad
0ed5b8dd38 sched_pstats: need proclist_mutex to send signals. 2007-12-27 22:13:19 +00:00
yamt
949e16d902 use binuptime for l_stime/l_rtime. 2007-12-22 01:14:53 +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
ad
901f9ae9f6 cv_init(&lbolt, "lbolt"); 2007-11-29 15:41:07 +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
ad
9892c881ed Put back equivalent change to rev 1.189 which was lost:
setrunnable: adjust to slightly different locking strategy post
yamt-idlewlp. Should fix kern/36398. Untested due to connectivity issues.
2007-11-10 17:45:10 +00:00
ad
d5622dbb85 Fix merge error. Spotted by rmind@. 2007-11-06 17:57:46 +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
7c0340a739 - Migrate all threads when the state of CPU is changed to offline;
- Fix inverted logic with r_mcount in M2;
- setrunnable: perform sched_takecpu() when making the LWP runnable;
- setrunnable: l_mutex cannot be spc_mutex here;

This makes cpuctl(8) work with SCHED_M2.

OK by <ad>.
2007-11-04 11:43:07 +00:00
yamt
94c0a71eb1 reduce dependencies on opt_sched.h. 2007-10-29 12:16:54 +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
36a1712707 Merge run time accounting changes from the vmlocking branch. These make
the LWP "start time" per-thread instead of per-CPU.
2007-10-08 20:06:17 +00:00
ad
b30dffc0e4 - sched_yield: When yielding, drop the priority to MAXPRI ensuring that the
calling thread really does yield. The scheduler will adjust it back to a
  reasonable level within 1 second. This contradicts POSIX, which specifies
  that sched_yield() put the thread onto the back of its current runqueue.
  However, POSIX doesn't really have any business specifying what should
  happen for SCHED_OTHER (i.e.  a timesharing scheduler like ours), and
  Java, MySQL and libpthread rely on sched_yield() doing something useful.

- mi_switch: adjust spc_curpriority and newl->l_priority if we avoided
  the runqueues and are doing a direct switch. Since nothing currently
  does that, there should be no functional change.
2007-10-03 11:20:09 +00:00
ad
f10a4e3b61 Fix assertion that broke debug kernels. 2007-10-02 13:17:16 +00:00
ad
b58e305699 Enter mi_switch() from the idle loop if ci_want_resched is set. If there
are no jobs to run it will clear it while under lock. Should fix idle.
2007-10-01 22:14:23 +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
yamt
954298e279 suspendsched: reduce #ifdef. 2007-08-06 11:48:23 +00:00
ad
18af8ee9bd Add cpuctl(8). For now this is not much more than a toy for debugging and
benchmarking that allows taking CPUs online/offline.
2007-08-04 11:02: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
ad
fe1b7cd1f7 Ressurect cv_wakeup() and use it on lbolt. Should fix PR kern/36714.
(background/foreground signal lossage in -current with various programs).
2007-08-01 23:21:14 +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
ad
057666ad0c setrunnable: adjust to slightly different locking strategy post yamt-idlewlp.
Should fix kern/36398. Untested due to connectivity issues.
2007-05-31 22:06:09 +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
9a92ddadc8 Put back mtsleep() temporarily. Converting everything over to condvars
at once will take too much time..
2007-03-11 21:36:48 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
yamt
c574bfa378 typedef pri_t and use it instead of int and u_char. 2007-02-27 15:07:28 +00:00
yamt
e781af39bd implement priority inheritance. 2007-02-26 09:20:52 +00:00
ad
9501d652a0 setrunnable(): don't require that sleeps be interruptable. This breaks
smbfs. Fixes PR/35787.
2007-02-23 16:51:47 +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
dsl
1736f4ea10 Revert 'optimisation' added in rev 1.179.
On i386 (at least) gcc manages two generate two forwards branches which are not
usually taken for the old code, and one forwards branch that is usually taken
for my 'improved version'.  Since (IIRC) both athlon and P4 will predict
forwards branches 'not taken' the old code is likely to be faster :-(
Faster variants exist, especially ones using the cmov instruction.
2007-02-19 22:14:15 +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
dsl
ff6d800c8f Optimise canonicalisation of l_rtime for the case when the start and stop
times are in the same second.
2007-02-18 16:03:06 +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
d91014721f Add uvm_kick_scheduler() (MP safe) to replace wakeup(&proc0). 2007-02-15 20:21:13 +00:00
yamt
997a2a3c4f remove function prototypes of sa_awaken. 2007-02-10 14:02:01 +00:00
christos
1735b4d5c0 avoid using struct proc in the perfctrs case, where the variable might
not be used.
2007-02-10 02:55:18 +00:00
ad
b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
ad
5bfcdd68c1 - ltsleep(): for now, stay at splsched() when releasing sched_lock, or we
may allow wakeup() to occur before switching away.  PR/32962.
- mi_switch(): don't inspect p->p_cred or send signals without holding the
  kernel lock.
2006-11-03 20:46:00 +00:00
yamt
4d91d6d252 ltsleep: fix a race with wakeup(). 2006-11-02 16:26:25 +00:00
yamt
1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
yamt
caa14e011b kill signal "dolock" hacks.
related to PR/32962 and PR/34895.  reviewed by matthew green.
2006-11-01 09:46:14 +00:00