Skip site navigation (1)Skip section navigation (2)

CVS log for src/sys/kern/sched_4bsd.c

[BACK] Up to [FreeBSD] / src / sys / kern

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.131.2.15: download - view: text, markup, annotated - select for diffs
Fri Jan 13 20:15:49 2012 UTC (3 weeks, 5 days ago) by jhb
Branches: RELENG_8
Diff to: previous 1.131.2.14: preferred, colored; branchpoint 1.131: preferred, colored; next MAIN 1.132: preferred, colored
Changes since revision 1.131.2.14: +2 -2 lines
SVN rev 230080 on 2012-01-13 20:15:49Z by jhb

MFC 229429:
Some small fixes to CPU accounting for threads:
- Only initialize the per-cpu switchticks and switchtime in sched_throw()
  for the very first context switch on APs during boot.  This avoids a
  small gap between the middle of thread_exit() and sched_throw() where
  time is not accounted to any thread.
- In thread_exit(), update the timestamp bookkeeping to track the changes
  to mi_switch() introduced by td_rux so that the code once again matches
  the comment claiming it is mimicing mi_switch().  Specifically, only
  update the per-thread stats directly and depend on ruxagg() to update
  p_rux rather than adjusting p_rux directly.  While here, move the
  timestamp bookkeeping as late in the function as possible.

Revision 1.158.2.2: download - view: text, markup, annotated - select for diffs
Fri Jan 13 20:15:27 2012 UTC (3 weeks, 5 days ago) by jhb
Branches: RELENG_9
Diff to: previous 1.158.2.1: preferred, colored; branchpoint 1.158: preferred, colored; next MAIN 1.159: preferred, colored
Changes since revision 1.158.2.1: +2 -2 lines
SVN rev 230079 on 2012-01-13 20:15:27Z by jhb

MFC 229429:
Some small fixes to CPU accounting for threads:
- Only initialize the per-cpu switchticks and switchtime in sched_throw()
  for the very first context switch on APs during boot.  This avoids a
  small gap between the middle of thread_exit() and sched_throw() where
  time is not accounted to any thread.
- In thread_exit(), update the timestamp bookkeeping to track the changes
  to mi_switch() introduced by td_rux so that the code once again matches
  the comment claiming it is mimicing mi_switch().  Specifically, only
  update the per-thread stats directly and depend on ruxagg() to update
  p_rux rather than adjusting p_rux directly.  While here, move the
  timestamp bookkeeping as late in the function as possible.

Revision 1.160: download - view: text, markup, annotated - select for diffs
Tue Jan 3 21:03:28 2012 UTC (5 weeks, 1 day ago) by jhb
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.159: preferred, colored
Changes since revision 1.159: +2 -2 lines
SVN rev 229429 on 2012-01-03 21:03:28Z by jhb

Some small fixes to CPU accounting for threads:
- Only initialize the per-cpu switchticks and switchtime in sched_throw()
  for the very first context switch on APs during boot.  This avoids a
  small gap between the middle of thread_exit() and sched_throw() where
  time is not accounted to any thread.
- In thread_exit(), update the timestamp bookkeeping to track the changes
  to mi_switch() introduced by td_rux so that the code once again matches
  the comment claiming it is mimicing mi_switch().  Specifically, only
  update the per-thread stats directly and depend on ruxagg() to update
  p_rux rather than adjusting p_rux directly.  While here, move the
  timestamp bookkeeping as late in the function as possible.

Reviewed by:	bde, kib
MFC after:	1 week

Revision 1.158.2.1.2.1: download - view: text, markup, annotated - select for diffs
Fri Nov 11 04:20:22 2011 UTC (2 months, 4 weeks ago) by kensmith
Branches: RELENG_9_0
CVS tags: RELENG_9_0_0_RELEASE
Diff to: previous 1.158.2.1: preferred, colored; next MAIN 1.158.2.2: preferred, colored
Changes since revision 1.158.2.1: +0 -0 lines
SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)

Revision 1.131.2.14: download - view: text, markup, annotated - select for diffs
Fri Nov 11 02:13:35 2011 UTC (2 months, 4 weeks ago) by rstone
Branches: RELENG_8
Diff to: previous 1.131.2.13: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.13: +21 -19 lines
SVN rev 227439 on 2011-11-11 02:13:35Z by rstone

MFC 221081:

 If the 4BSD scheduler tries to schedule a thread that has been pinned or
 bound to an AP before SMP has started, the system will panic when we try
 to touch per-CPU state for that AP because that state has not been
 initialized yet.  Fix this in the same way as ULE: place all threads in
 the global run queue before SMP has started.

Revision 1.159: download - view: text, markup, annotated - select for diffs
Mon Nov 7 15:43:11 2011 UTC (3 months ago) by ed
Branches: MAIN
Diff to: previous 1.158: preferred, colored
Changes since revision 1.158: +2 -1 lines
SVN rev 227309 on 2011-11-07 15:43:11Z by ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.

Revision 1.158.2.1: download - view: text, markup, annotated - select for diffs
Fri Sep 23 00:51:37 2011 UTC (4 months, 2 weeks ago) by kensmith
Branches: RELENG_9
CVS tags: RELENG_9_0_BP
Branch point for: RELENG_9_0
Diff to: previous 1.158: preferred, colored
Changes since revision 1.158: +0 -0 lines
SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)

Revision 1.131.2.13: download - view: text, markup, annotated - select for diffs
Fri Sep 9 01:39:19 2011 UTC (5 months ago) by delphij
Branches: RELENG_8
Diff to: previous 1.131.2.12: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.12: +2 -2 lines
SVN rev 225454 on 2011-09-09 01:39:19Z by delphij

MFC r225199:

Fix format strings for KTR_STATE in 4BSD ad ULE schedulers.

Submitted by:	Ivan Klymenko <fidaj@ukr.net>
PR:		kern/159904, kern/159905

Revision 1.158: download - view: text, markup, annotated - select for diffs
Fri Aug 26 18:00:07 2011 UTC (5 months, 2 weeks ago) by delphij
Branches: MAIN
CVS tags: RELENG_9_BP
Branch point for: RELENG_9
Diff to: previous 1.157: preferred, colored
Changes since revision 1.157: +2 -2 lines
SVN rev 225199 on 2011-08-26 18:00:07Z by delphij

Fix format strings for KTR_STATE in 4BSD ad ULE schedulers.

Submitted by:	Ivan Klymenko <fidaj@ukr.net>
PR:		kern/159904, kern/159905
MFC after:	2 weeks
Approved by:	re (kib)

Revision 1.157: download - view: text, markup, annotated - select for diffs
Mon Jul 4 12:04:52 2011 UTC (7 months ago) by attilio
Branches: MAIN
Diff to: previous 1.156: preferred, colored
Changes since revision 1.156: +24 -33 lines
SVN rev 223758 on 2011-07-04 12:04:52Z by attilio

With retirement of cpumask_t and usage of cpuset_t for representing a
mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.

Remove them and replace their usage with custom pc_cpuid magic (as,
atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and
pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))).

This change is not targeted for MFC because of struct pcpu members
removal and dependency by cpumask_t retirement.

MD review by:	marcel, marius, alc
Tested by:	pluknet
MD testing by:	marcel, marius, gonzo, andreast

Revision 1.131.2.12: download - view: text, markup, annotated - select for diffs
Wed Jun 8 19:58:20 2011 UTC (8 months ago) by jhb
Branches: RELENG_8
Diff to: previous 1.131.2.11: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.11: +4 -0 lines
SVN rev 222868 on 2011-06-08 19:58:20Z by jhb

MFC 220390:
Fix several places to ignore processes that are not yet fully constructed.

Revision 1.156: download - view: text, markup, annotated - select for diffs
Tue Jun 7 08:46:13 2011 UTC (8 months ago) by attilio
Branches: MAIN
Diff to: previous 1.155: preferred, colored
Changes since revision 1.155: +44 -22 lines
SVN rev 222813 on 2011-06-07 08:46:13Z by attilio

etire the cpumask_t type and replace it with cpuset_t usage.

This is intended to fix the bug where cpu mask objects are
capped to 32.  MAXCPU, then, can now arbitrarely bumped to whatever
value.  Anyway, as long as several structures in the kernel are
statically allocated and sized as MAXCPU, it is suggested to keep it
as low as possible for the time being.

Technical notes on this commit itself:
- More functions to handle with cpuset_t objects are introduced.
  The most notable are cpusetobj_ffs() (which calculates a ffs(3)
  for a cpuset_t object), cpusetobj_strprint() (which prepares a string
  representing a cpuset_t object) and cpusetobj_strscan() (which
  creates a valid cpuset_t starting from a string representation).
- pc_cpumask and pc_other_cpus are target to be removed soon.
  With the moving from cpumask_t to cpuset_t they are now inefficient
  and not really useful.  Anyway, for the time being, please note that
  access to pcpu datas is protected by sched_pin() in order to avoid
  migrating the CPU while reading more than one (possible) word
- Please note that size of cpuset_t objects may differ between kernel
  and userland.  While this is not directly related to the patch itself,
  it is good to understand that concept and possibly use the patch
  as a reference on how to deal with cpuset_t objects in userland, when
  accessing kernland members.
- KTR_CPUMASK is changed and now is represented through a string, to be
  set as the example reported in NOTES.

Please additively note that no MAXCPU is bumped in this patch, but
private testing has been done until to MAXCPU=128 on a real 8x8x2(htt)
machine (amd64).

Please note that the FreeBSD version is not yet bumped because of
the upcoming pcpu changes.  However, note that this patch is not
targeted for MFC.

People to thank for the time spent on this patch:
- sbruno, pluknet and Nicholas Esborn (nick AT desert DOT net) tested
  several revision of the patches and really helped in improving
  stability of this work.
- marius fixed several bugs in the sparc64 implementation and reviewed
  patches related to ktr.
- jeff and jhb discussed the basic approach followed.
- kib and marcel made targeted review on some specific part of the
  patch.
- marius, art, nwhitehorn and andreast reviewed MD specific part of
  the patch.
- marius, andreast, gonzo, nwhitehorn and jceel tested MD specific
  implementations of the patch.
- Other people have made contributions on other patches that have been
  already committed and have been listed separately.

Companies that should be mentioned for having participated at several
degrees:
- Yahoo! for having offered the machines used for testing on big
  count of CPUs.
- The FreeBSD Foundation for having sponsored my devsummit attendance,
  which has been instrumental.
- Sandvine for having offered offices and infrastructure during
  development.

(I really hope I didn't forget anyone, if it happened I apologize in
advance).

Revision 1.155: download - view: text, markup, annotated - select for diffs
Tue May 31 15:11:43 2011 UTC (8 months, 1 week ago) by nwhitehorn
Branches: MAIN
Diff to: previous 1.154: preferred, colored
Changes since revision 1.154: +2 -2 lines
SVN rev 222531 on 2011-05-31 15:11:43Z by nwhitehorn

On multi-core, multi-threaded PPC systems, it is important that the threads
be brought up in the order they are enumerated in the device tree (in
particular, that thread 0 on each core be brought up first). The SLIST
through which we loop to start the CPUs has all of its entries added with
SLIST_INSERT_HEAD(), which means it is in reverse order of enumeration
and so AP startup would always fail in such situations (causing a machine
check or RTAS failure). Fix this by changing the SLIST into an STAILQ,
and inserting new CPUs at the end.

Reviewed by:	jhb

Revision 1.154: download - view: text, markup, annotated - select for diffs
Tue May 17 22:14:00 2011 UTC (8 months, 3 weeks ago) by attilio
Branches: MAIN
Diff to: previous 1.153: preferred, colored
Changes since revision 1.153: +7 -31 lines
SVN rev 222040 on 2011-05-17 22:14:00Z by attilio

Merge r221285 from largeSMP project:
- Remove the following sysctl:
  kern.sched.ipiwakeup.onecpu
  kern.sched.ipiwakeup.htt2

  Because they are absolutely obsolete.  Probabilly the whole wakeup
  forward mechanism should be revisited for a better fitting in modern
  hw, in the future.
- As map2 variable is no longer used rename map3 to map2
- Fix a string by making more informative the msg and removing the
  arguments passing.

Reviewed by:	julian
Tested by:	several

Revision 1.153: download - view: text, markup, annotated - select for diffs
Mon May 16 23:20:12 2011 UTC (8 months, 3 weeks ago) by attilio
Branches: MAIN
Diff to: previous 1.152: preferred, colored
Changes since revision 1.152: +2 -0 lines
SVN rev 222001 on 2011-05-16 23:20:12Z by attilio

Merge r221278 from largeSMP project:
idle_cpus_mask is just used in sched_4bsd, thus make it private for it.

Tested by:	several

Revision 1.106.2.13: download - view: text, markup, annotated - select for diffs
Fri May 6 14:11:20 2011 UTC (9 months ago) by fabient
Branches: RELENG_7
Diff to: previous 1.106.2.12: preferred, colored; branchpoint 1.106: preferred, colored; next MAIN 1.107: preferred, colored
Changes since revision 1.106.2.12: +2 -6 lines
SVN rev 221532 on 2011-05-06 14:11:20Z by fabient

MFC r220198:
Clearing the flag when preempting will let the preempted thread run
too much time. This can finish in a scheduler deadlock with ping-pong
between two threads.

One sample of this is:
- device lapic (to have a preemption point on critical_exit())
- options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq)
- running a cpu intensive task (that does not enter the kernel)
- only one CPU on SMP or no SMP.

As requested by jhb@ 4BSD have received the same type of fix instead of
propagating the flag to the new thread.

Revision 1.131.2.11: download - view: text, markup, annotated - select for diffs
Fri May 6 14:05:32 2011 UTC (9 months ago) by fabient
Branches: RELENG_8
Diff to: previous 1.131.2.10: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.10: +2 -6 lines
SVN rev 221528 on 2011-05-06 14:05:32Z by fabient

MFC r220198:
Clearing the flag when preempting will let the preempted thread run
too much time. This can finish in a scheduler deadlock with ping-pong
between two threads.

One sample of this is:
 - device lapic (to have a preemption point on critical_exit())
 - options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq)
 - running a cpu intensive task (that does not enter the kernel)
 - only one CPU on SMP or no SMP.

As requested by jhb@ 4BSD have received the same type of fix instead of
propagating the flag to the new thread.

Revision 1.152: download - view: text, markup, annotated - select for diffs
Tue Apr 26 20:34:30 2011 UTC (9 months, 2 weeks ago) by rstone
Branches: MAIN
Diff to: previous 1.151: preferred, colored
Changes since revision 1.151: +21 -19 lines
SVN rev 221081 on 2011-04-26 20:34:30Z by rstone

If the 4BSD scheduler tries to schedule a thread that has been pinned or
bound to an AP before SMP has started, the system will panic when we try
to touch per-CPU state for that AP because that state has not been
initialized yet.  Fix this in the same way as ULE: place all threads in
the global run queue before SMP has started.

Reviewed by:	jhb
MFC after:	1 month

Revision 1.151: download - view: text, markup, annotated - select for diffs
Wed Apr 6 17:47:22 2011 UTC (10 months ago) by jhb
Branches: MAIN
Diff to: previous 1.150: preferred, colored
Changes since revision 1.150: +4 -0 lines
SVN rev 220390 on 2011-04-06 17:47:22Z by jhb

Fix several places to ignore processes that are not yet fully constructed.

MFC after:	1 week

Revision 1.150: download - view: text, markup, annotated - select for diffs
Thu Mar 31 13:59:47 2011 UTC (10 months, 1 week ago) by fabient
Branches: MAIN
Diff to: previous 1.149: preferred, colored
Changes since revision 1.149: +2 -6 lines
SVN rev 220198 on 2011-03-31 13:59:47Z by fabient

Clearing the flag when preempting will let the preempted thread run
too much time. This can finish in a scheduler deadlock with ping-pong
between two threads.

One sample of this is:
- device lapic (to have a preemption point on critical_exit())
- options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq)
- running a cpu intensive task (that does not enter the kernel)
- only one CPU on SMP or no SMP.

As requested by jhb@ 4BSD have received the same type of fix instead of
propagating the flag to the new thread.

Reviewed by:	jhb, jeff
MFC after:	1 month

Revision 1.131.2.10: download - view: text, markup, annotated - select for diffs
Sat Feb 5 21:50:23 2011 UTC (12 months ago) by kib
Branches: RELENG_8
Diff to: previous 1.131.2.9: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.9: +8 -8 lines
SVN rev 218352 on 2011-02-05 21:50:23Z by kib

MFC r198854 (by attilio):
Split P_NOLOAD into a per-thread flag (TDF_NOLOAD)

Approved by:	attilio

Revision 1.106.2.12: download - view: text, markup, annotated - select for diffs
Thu Jan 27 21:21:09 2011 UTC (12 months, 1 week ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.11: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.11: +1 -0 lines
SVN rev 217982 on 2011-01-27 21:21:09Z by jhb

MFC 217078,217079: Various priority fixes for creating new threads:
- Move sched_fork() later in fork() after the various sections of the new
  thread and proc have been copied and zeroed from the old thread and
  proc.  Otherwise attempts to modify thread or process data in sched_fork()
  could be undone.
- Don't copy td_{base,}_user_pri from the old thread to the new thread in
  sched_fork_thread() in ULE.  This is already done courtesy the bcopy()
  of the thread copy region.
- Always initialize the real priority (td_priority) of new threads to the
  new thread's base priority (td_base_pri) to avoid bogusly inheriting a
  borrowed priority from the parent thread.
- Properly initialize the base priority (td_base_pri) of thread0 to PVM
  to match the desired priority in td_priority.  Otherwise the first time
  thread0 used a borrowed priority it would drop down to PUSER instead of
  PVM.
- Explicitly initialize the starting priority of new kprocs to PVM to
  avoid inheriting some random priority from thread0.

Revision 1.131.2.9: download - view: text, markup, annotated - select for diffs
Thu Jan 27 21:16:23 2011 UTC (12 months, 1 week ago) by jhb
Branches: RELENG_8
Diff to: previous 1.131.2.8: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.8: +1 -0 lines
SVN rev 217981 on 2011-01-27 21:16:23Z by jhb

MFC 217078,217079: Various priority fixes for creating new threads:
- Move sched_fork() later in fork() after the various sections of the new
  thread and proc have been copied and zeroed from the old thread and
  proc.  Otherwise attempts to modify thread or process data in sched_fork()
  could be undone.
- Don't copy td_{base,}_user_pri from the old thread to the new thread in
  sched_fork_thread() in ULE.  This is already done courtesy the bcopy()
  of the thread copy region.
- Always initialize the real priority (td_priority) of new threads to the
  new thread's base priority (td_base_pri) to avoid bogusly inheriting a
  borrowed priority from the parent thread.
- Properly initialize the base priority (td_base_pri) of thread0 to PVM
  to match the desired priority in td_priority.  Otherwise the first time
  thread0 used a borrowed priority it would drop down to PUSER instead of
  PVM.
- Explicitly initialize the starting priority of new kprocs to PVM to
  avoid inheriting some random priority from thread0.

Revision 1.131.2.8: download - view: text, markup, annotated - select for diffs
Mon Jan 17 05:45:55 2011 UTC (12 months, 3 weeks ago) by lstewart
Branches: RELENG_8
Diff to: previous 1.131.2.7: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.7: +2 -6 lines
SVN rev 217500 on 2011-01-17 05:45:55Z by lstewart

MFC r209059 (originally committed by jhb):

Update several places that iterate over CPUs to use CPU_FOREACH().

Revision 1.149: download - view: text, markup, annotated - select for diffs
Fri Jan 14 17:06:54 2011 UTC (12 months, 3 weeks ago) by jhb
Branches: MAIN
Diff to: previous 1.148: preferred, colored
Changes since revision 1.148: +1 -1 lines
SVN rev 217410 on 2011-01-14 17:06:54Z by jhb

Rework realtime priority support:
- Move the realtime priority range up above kernel sleep priorities and
  just below interrupt thread priorities.
- Contract the interrupt and kernel sleep priority ranges a bit so that
  the timesharing priority band can be increased.  The new timeshare range
  is now slightly larger than the old realtime + timeshare ranges.
- Change the ULE scheduler to no longer use realtime priorities for
  interactive threads.  Instead, the larger timeshare range is now split
  into separate subranges for interactive and non-interactive ("batch")
  threads.  The end result is that interactive threads and non-interactive
  threads still use the same priority ranges as before, but realtime
  threads now have a separate, dedicated priority range.
- Do not modify the priority of non-timeshare threads in sched_sleep()
  or via cv_broadcastpri().  Realtime and idle priority threads will
  no longer have their priorities affected by sleeping in the kernel.

Reviewed by:	jeff

Revision 1.148: download - view: text, markup, annotated - select for diffs
Thu Jan 13 18:20:37 2011 UTC (12 months, 3 weeks ago) by mdf
Branches: MAIN
Diff to: previous 1.147: preferred, colored
Changes since revision 1.147: +1 -1 lines
SVN rev 217370 on 2011-01-13 18:20:37Z by mdf

One more sysctl(9) type-safety that I missed before.

Revision 1.147: download - view: text, markup, annotated - select for diffs
Thu Jan 6 22:24:00 2011 UTC (13 months ago) by jhb
Branches: MAIN
Diff to: previous 1.146: preferred, colored
Changes since revision 1.146: +1 -0 lines
SVN rev 217078 on 2011-01-06 22:24:00Z by jhb

- Move sched_fork() later in fork() after the various sections of the new
  thread and proc have been copied and zeroed from the old thread and
  proc.  Otherwise attempts to modify thread or process data in sched_fork()
  could be undone.
- Don't copy td_{base,}_user_pri from the old thread to the new thread in
  sched_fork_thread() in ULE.  This is already done courtesy the bcopy()
  of the thread copy region.
- Always initialize the real priority (td_priority) of new threads to the
  new thread's base priority (td_base_pri) to avoid bogusly inheriting a
  borrowed priority from the parent thread.

MFC after:	2 weeks

Revision 1.146: download - view: text, markup, annotated - select for diffs
Wed Dec 29 09:26:46 2010 UTC (13 months, 1 week ago) by davidxu
Branches: MAIN
Diff to: previous 1.145: preferred, colored
Changes since revision 1.145: +5 -17 lines
SVN rev 216791 on 2010-12-29 09:26:46Z by davidxu

- Follow r216313, the sched_unlend_user_prio is no longer needed, always
  use sched_lend_user_prio to set lent priority.
- Improve pthread priority-inherit mutex, when a contender's priority is
  lowered, repropagete priorities, this may cause mutex owner's priority
  to be lowerd, in old code, mutex owner's priority is rise-only.

Revision 1.106.2.11.2.1: download - view: text, markup, annotated - select for diffs
Tue Dec 21 17:10:29 2010 UTC (13 months, 2 weeks ago) by kensmith
Branches: RELENG_7_4
CVS tags: RELENG_7_4_0_RELEASE
Diff to: previous 1.106.2.11: preferred, colored; next MAIN 1.106.2.12: preferred, colored
Changes since revision 1.106.2.11: +0 -0 lines
SVN rev 216618 on 2010-12-21 17:10:29Z by kensmith

Copy stable/7 to releng/7.4 in preparation for FreeBSD-7.4 release.

Approved by:	re (implicit)

Revision 1.131.2.7.2.1: download - view: text, markup, annotated - select for diffs
Tue Dec 21 17:09:25 2010 UTC (13 months, 2 weeks ago) by kensmith
Branches: RELENG_8_2
CVS tags: RELENG_8_2_0_RELEASE
Diff to: previous 1.131.2.7: preferred, colored; next MAIN 1.131.2.8: preferred, colored
Changes since revision 1.131.2.7: +0 -0 lines
SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)

Revision 1.145: download - view: text, markup, annotated - select for diffs
Thu Dec 9 02:42:02 2010 UTC (14 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.144: preferred, colored
Changes since revision 1.144: +10 -13 lines
SVN rev 216313 on 2010-12-09 02:42:02Z by davidxu

MFp4:
It is possible a lower priority thread lending priority to higher priority
thread, in old code, it is ignored, however the lending should always be
recorded, add field td_lend_user_pri to fix the problem, if a thread does
not have borrowed priority, its value is PRI_MAX.

MFC after: 1 week

Revision 1.144: download - view: text, markup, annotated - select for diffs
Mon Nov 22 19:32:54 2010 UTC (14 months, 2 weeks ago) by dim
Branches: MAIN
Diff to: previous 1.143: preferred, colored
Changes since revision 1.143: +1 -1 lines
SVN rev 215701 on 2010-11-22 19:32:54Z by dim

After some off-list discussion, revert a number of changes to the
DPCPU_DEFINE and VNET_DEFINE macros, as these cause problems for various
people working on the affected files.  A better long-term solution is
still being considered.  This reversal may give some modules empty
set_pcpu or set_vnet sections, but these are harmless.

Changes reverted:

------------------------------------------------------------------------
r215318 | dim | 2010-11-14 21:40:55 +0100 (Sun, 14 Nov 2010) | 4 lines

Instead of unconditionally emitting .globl's for the __start_set_xxx and
__stop_set_xxx symbols, only emit them when the set_vnet or set_pcpu
sections are actually defined.

------------------------------------------------------------------------
r215317 | dim | 2010-11-14 21:38:11 +0100 (Sun, 14 Nov 2010) | 3 lines

Apply the STATIC_VNET_DEFINE and STATIC_DPCPU_DEFINE macros throughout
the tree.

------------------------------------------------------------------------
r215316 | dim | 2010-11-14 21:23:02 +0100 (Sun, 14 Nov 2010) | 2 lines

Add macros to define static instances of VNET_DEFINE and DPCPU_DEFINE.

Revision 1.143: download - view: text, markup, annotated - select for diffs
Sun Nov 14 20:38:11 2010 UTC (14 months, 3 weeks ago) by dim
Branches: MAIN
Diff to: previous 1.142: preferred, colored
Changes since revision 1.142: +1 -1 lines
SVN rev 215317 on 2010-11-14 20:38:11Z by dim

Apply the STATIC_VNET_DEFINE and STATIC_DPCPU_DEFINE macros throughout
the tree.

Revision 1.131.2.7: download - view: text, markup, annotated - select for diffs
Tue Nov 9 20:00:23 2010 UTC (15 months ago) by jhb
Branches: RELENG_8
CVS tags: RELENG_8_2_BP
Branch point for: RELENG_8_2
Diff to: previous 1.131.2.6: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.6: +4 -4 lines
SVN rev 215050 on 2010-11-09 20:00:23Z by jhb

MFC 210939:
Add a new ipi_cpu() function to the MI IPI API that can be used to send an
IPI to a specific CPU by its cpuid.  Replace calls to ipi_selected() that
constructed a mask for a single CPU with calls to ipi_cpu() instead.

Revision 1.142: download - view: text, markup, annotated - select for diffs
Mon Sep 13 07:25:35 2010 UTC (16 months, 3 weeks ago) by mav
Branches: MAIN
Diff to: previous 1.141: preferred, colored
Changes since revision 1.141: +1 -1 lines
SVN rev 212541 on 2010-09-13 07:25:35Z by mav

Refactor timer management code with priority to one-shot operation mode.
The main goal of this is to generate timer interrupts only when there is
some work to do. When CPU is busy interrupts are generating at full rate
of hz + stathz to fullfill scheduler and timekeeping requirements. But
when CPU is idle, only minimum set of interrupts (down to 8 interrupts per
second per CPU now), needed to handle scheduled callouts is executed.
This allows significantly increase idle CPU sleep time, increasing effect
of static power-saving technologies. Also it should reduce host CPU load
on virtualized systems, when guest system is idle.

There is set of tunables, also available as writable sysctls, allowing to
control wanted event timer subsystem behavior:
  kern.eventtimer.timer - allows to choose event timer hardware to use.
On x86 there is up to 4 different kinds of timers. Depending on whether
chosen timer is per-CPU, behavior of other options slightly differs.
  kern.eventtimer.periodic - allows to choose periodic and one-shot
operation mode. In periodic mode, current timer hardware taken as the only
source of time for time events. This mode is quite alike to previous kernel
behavior. One-shot mode instead uses currently selected time counter
hardware to schedule all needed events one by one and program timer to
generate interrupt exactly in specified time. Default value depends of
chosen timer capabilities, but one-shot mode is preferred, until other is
forced by user or hardware.
  kern.eventtimer.singlemul - in periodic mode specifies how much times
higher timer frequency should be, to not strictly alias hardclock() and
statclock() events. Default values are 2 and 4, but could be reduced to 1
if extra interrupts are unwanted.
  kern.eventtimer.idletick - makes each CPU to receive every timer interrupt
independently of whether they busy or not. By default this options is
disabled. If chosen timer is per-CPU and runs in periodic mode, this option
has no effect - all interrupts are generating.

As soon as this patch modifies cpu_idle() on some platforms, I have also
refactored one on x86. Now it makes use of MONITOR/MWAIT instrunctions
(if supported) under high sleep/wakeup rate, as fast alternative to other
methods. It allows SMP scheduler to wake up sleeping CPUs much faster
without using IPI, significantly increasing performance on some highly
task-switching loads.

Tested by:	many (on i386, amd64, sparc64 and powerc)
H/W donated by:	Gheorghe Ardelean
Sponsored by:	iXsystems, Inc.

Revision 1.141: download - view: text, markup, annotated - select for diffs
Sat Sep 11 07:08:22 2010 UTC (16 months, 4 weeks ago) by mav
Branches: MAIN
Diff to: previous 1.140: preferred, colored
Changes since revision 1.140: +28 -4 lines
SVN rev 212455 on 2010-09-11 07:08:22Z by mav

Merge some SCHED_ULE features to SCHED_4BSD:
- Teach SCHED_4BSD to inform cpu_idle() about high sleep/wakeup rate to
choose optimized handler. In case of x86 it is MONITOR/MWAIT. Also it
will be needed to bypass forthcoming idle tick skipping logic to not
consume resources on events rescheduling when it won't give any benefits.
- Teach SCHED_4BSD to wake up idle CPUs without using IPI. In case of x86,
when MONITOR/MWAIT is active, it require just single memory write. This
doubles performance on some heavily switching test loads.

Revision 1.140: download - view: text, markup, annotated - select for diffs
Fri Aug 6 15:36:59 2010 UTC (18 months ago) by jhb
Branches: MAIN
Diff to: previous 1.139: preferred, colored
Changes since revision 1.139: +4 -4 lines
SVN rev 210939 on 2010-08-06 15:36:59Z by jhb

Add a new ipi_cpu() function to the MI IPI API that can be used to send an
IPI to a specific CPU by its cpuid.  Replace calls to ipi_selected() that
constructed a mask for a single CPU with calls to ipi_cpu() instead.  This
will matter more in the future when we transition from cpumask_t to
cpuset_t for CPU masks in which case building a CPU mask is more expensive.

Submitted by:	peter, sbruno
Reviewed by:	rookie
Obtained from:	Yahoo! (x86)
MFC after:	1 month

Revision 1.106.2.11: download - view: text, markup, annotated - select for diffs
Wed Jul 14 19:01:08 2010 UTC (18 months, 3 weeks ago) by jhb
Branches: RELENG_7
CVS tags: RELENG_7_4_BP
Branch point for: RELENG_7_4
Diff to: previous 1.106.2.10: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.10: +1 -0 lines
SVN rev 210073 on 2010-07-14 19:01:08Z by jhb

MFC 208787:
Assert that the thread lock is held in sched_pctcpu() instead of
recursively acquiring it.  All of the current callers already hold the
lock.

Revision 1.131.2.6: download - view: text, markup, annotated - select for diffs
Wed Jul 14 19:00:44 2010 UTC (18 months, 3 weeks ago) by jhb
Branches: RELENG_8
Diff to: previous 1.131.2.5: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.5: +1 -0 lines
SVN rev 210072 on 2010-07-14 19:00:44Z by jhb

MFC 208787:
Assert that the thread lock is held in sched_pctcpu() instead of
recursively acquiring it.  All of the current callers already hold the
lock.

Revision 1.106.2.10: download - view: text, markup, annotated - select for diffs
Thu Jun 24 12:09:12 2010 UTC (19 months, 2 weeks ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.9: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.9: +3 -3 lines
SVN rev 209504 on 2010-06-24 12:09:12Z by jhb

MFC 208391:
Assert that the thread passed to sched_bind() and sched_unbind() is
curthread as those routines are only supported for curthread currently.

Revision 1.131.2.5: download - view: text, markup, annotated - select for diffs
Thu Jun 24 12:08:50 2010 UTC (19 months, 2 weeks ago) by jhb
Branches: RELENG_8
Diff to: previous 1.131.2.4: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.4: +3 -3 lines
SVN rev 209503 on 2010-06-24 12:08:50Z by jhb

MFC 208391:
Assert that the thread passed to sched_bind() and sched_unbind() is
curthread as those routines are only supported for curthread currently.

Revision 1.131.2.4.2.1: download - view: text, markup, annotated - select for diffs
Mon Jun 14 02:09:06 2010 UTC (19 months, 3 weeks ago) by kensmith
Branches: RELENG_8_1
CVS tags: RELENG_8_1_0_RELEASE
Diff to: previous 1.131.2.4: preferred, colored; next MAIN 1.131.2.5: preferred, colored
Changes since revision 1.131.2.4: +0 -0 lines
SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)

Revision 1.139: download - view: text, markup, annotated - select for diffs
Fri Jun 11 18:46:34 2010 UTC (19 months, 4 weeks ago) by jhb
Branches: MAIN
Diff to: previous 1.138: preferred, colored
Changes since revision 1.138: +2 -6 lines
SVN rev 209059 on 2010-06-11 18:46:34Z by jhb

Update several places that iterate over CPUs to use CPU_FOREACH().

Revision 1.138: download - view: text, markup, annotated - select for diffs
Thu Jun 3 16:02:11 2010 UTC (20 months, 1 week ago) by jhb
Branches: MAIN
Diff to: previous 1.137: preferred, colored
Changes since revision 1.137: +1 -0 lines
SVN rev 208787 on 2010-06-03 16:02:11Z by jhb

Assert that the thread lock is held in sched_pctcpu() instead of
recursively acquiring it.  All of the current callers already hold the
lock.

MFC after:	1 month

Revision 1.137: download - view: text, markup, annotated - select for diffs
Fri May 21 17:15:56 2010 UTC (20 months, 2 weeks ago) by jhb
Branches: MAIN
Diff to: previous 1.136: preferred, colored
Changes since revision 1.136: +3 -3 lines
SVN rev 208391 on 2010-05-21 17:15:56Z by jhb

Assert that the thread passed to sched_bind() and sched_unbind() is
curthread as those routines are only supported for curthread currently.

MFC after:	1 month

Revision 1.106.2.9.2.1: download - view: text, markup, annotated - select for diffs
Wed Feb 10 00:26:20 2010 UTC (23 months, 4 weeks ago) by kensmith
Branches: RELENG_7_3
CVS tags: RELENG_7_3_0_RELEASE
Diff to: previous 1.106.2.9: preferred, colored; next MAIN 1.106.2.10: preferred, colored
Changes since revision 1.106.2.9: +0 -0 lines
SVN rev 203736 on 2010-02-10 00:26:20Z by kensmith

Copy stable/7 to releng/7.3 as part of the 7.3-RELEASE process.

Approved by:	re (implicit)

Revision 1.106.2.9: download - view: text, markup, annotated - select for diffs
Tue Feb 9 14:56:10 2010 UTC (23 months, 4 weeks ago) by attilio
Branches: RELENG_7
CVS tags: RELENG_7_3_BP
Branch point for: RELENG_7_3
Diff to: previous 1.106.2.8: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.8: +9 -4 lines
SVN rev 203704 on 2010-02-09 14:56:10Z by attilio

MFC r202889, r202940:
- Fix a race in sched_switch() of sched_4bsd.
  Block the td_lock when acquiring explicitly sched_lock in order to prevent
  races with other td_lock contenders.
- Merge the ULE's internal function thread_block_switch() into the global
  thread_lock_block() and make the former semantic as the default for
  thread_lock_block().
- Split out an invariant in order to have better checks.

Tested by:	Giovanni Trematerra
		<giovanni dot trematerra at gmail dot com>
Approved by:	re (kib)

Revision 1.131.2.4: download - view: text, markup, annotated - select for diffs
Mon Feb 8 14:08:52 2010 UTC (2 years ago) by attilio
Branches: RELENG_8
CVS tags: RELENG_8_1_BP
Branch point for: RELENG_8_1
Diff to: previous 1.131.2.3: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.3: +9 -4 lines
SVN rev 203662 on 2010-02-08 14:08:52Z by attilio

MC r202889, r202940:
- Fix a race in sched_switch() of sched_4bsd.
  Block the td_lock when acquiring explicitly sched_lock in order to prevent
  races with other td_lock contenders.
- Merge the ULE's internal function thread_block_switch() into the global
  thread_lock_block() and make the former semantic as the default for
  thread_lock_block().
- Split out an invariant in order to have better checks.

Revision 1.131.2.3: download - view: text, markup, annotated - select for diffs
Mon Jan 25 11:56:53 2010 UTC (2 years ago) by attilio
Branches: RELENG_8
Diff to: previous 1.131.2.2: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.2: +1 -1 lines
SVN rev 202965 on 2010-01-25 11:56:53Z by attilio

MFC r201790:
- Set td_slptick to 0 when moving threads out of sleepqueues.
- Move td_slptick from u_int to int in order to follow 'ticks' signedness
  and wrap up accordingly.

Sponsored by:	Sandvine Incorporated

Revision 1.136: download - view: text, markup, annotated - select for diffs
Sun Jan 24 18:16:38 2010 UTC (2 years ago) by attilio
Branches: MAIN
Diff to: previous 1.135: preferred, colored
Changes since revision 1.135: +4 -2 lines
SVN rev 202940 on 2010-01-24 18:16:38Z by attilio

Split out an invariant in order to better check that newtd, when
provided, must be on a runqueue.

Tested by:	Giovanni Trematerra
		<giovanni dot trematerra at gmail dot com>
MFC:		2 weeks
X-MFC:		r202889

Revision 1.135: download - view: text, markup, annotated - select for diffs
Sat Jan 23 15:54:21 2010 UTC (2 years ago) by attilio
Branches: MAIN
Diff to: previous 1.134: preferred, colored
Changes since revision 1.134: +5 -2 lines
SVN rev 202889 on 2010-01-23 15:54:21Z by attilio

- Fix a race in sched_switch() of sched_4bsd.
  In the case of the thread being on a sleepqueue or a turnstile, the
  sched_lock was acquired (without the aid of the td_lock interface) and
  the td_lock was dropped. This was going to break locking rules on other
  threads willing to access to the thread (via the td_lock interface) and
  modify his flags (allowed as long as the container lock was different
  by the one used in sched_switch).
  In order to prevent this situation, while sched_lock is acquired there
  the td_lock gets blocked. [0]
- Merge the ULE's internal function thread_block_switch() into the global
  thread_lock_block() and make the former semantic as the default for
  thread_lock_block(). This means that thread_lock_block() will not
  disable interrupts when called (and consequently thread_unlock_block()
  will not re-enabled them when called). This should be done manually
  when necessary.
  Note, however, that ULE's thread_unblock_switch() is not reaped
  because it does reflect a difference in semantic due in ULE (the
  td_lock may not be necessarilly still blocked_lock when calling this).
  While asymmetric, it does describe a remarkable difference in semantic
  that is good to keep in mind.

[0] Reported by:	Kohji Okuno
			<okuno dot kohji at jp dot panasonic dot com>
Tested by:		Giovanni Trematerra
			<giovanni dot trematerra at gmail dot com>
MFC:			2 weeks

Revision 1.134: download - view: text, markup, annotated - select for diffs
Fri Jan 8 14:55:11 2010 UTC (2 years, 1 month ago) by attilio
Branches: MAIN
Diff to: previous 1.133: preferred, colored
Changes since revision 1.133: +1 -1 lines
SVN rev 201790 on 2010-01-08 14:55:11Z by attilio

- Fix a bug in sched_4bsd where the timestamp for the sleeping operation
  is not cleaned up on the wakeup but reset.
  This is harmless mostly because td_slptick (and ki_slptime from
  userland) should be analyzed only with the assumption that the thread
  is actually sleeping (thus while the td_slptick is correctly set) but
  without this invariant the number is nomore consistent.
- Move td_slptick from u_int to int in order to follow 'ticks' signedness
  and wrap up accordingly [0]

[0] Submitted by:	emaste
Sponsored by:		Sandvine Incorporated
MFC			1 week

Revision 1.131.2.2: download - view: text, markup, annotated - select for diffs
Thu Jan 7 11:41:47 2010 UTC (2 years, 1 month ago) by kib
Branches: RELENG_8
Diff to: previous 1.131.2.1: preferred, colored; branchpoint 1.131: preferred, colored
Changes since revision 1.131.2.1: +1 -1 lines
SVN rev 201738 on 2010-01-07 11:41:47Z by kib

MFC r201347:
Allow swap out of the kernel stack for the thread with priority greater
or equial then PSOCK, not less or equial.

Revision 1.133: download - view: text, markup, annotated - select for diffs
Thu Dec 31 18:52:58 2009 UTC (2 years, 1 month ago) by kib
Branches: MAIN
Diff to: previous 1.132: preferred, colored
Changes since revision 1.132: +1 -1 lines
SVN rev 201347 on 2009-12-31 18:52:58Z by kib

Allow swap out of the kernel stack for the thread with priority greater
or equial then PSOCK, not less or equial. Higher priority has lesser
numerical value.

Existing test does not allow for swapout of the thread waiting for
advisory lock, for exiting child or sleeping for timeout. On the other
hand, high-priority waiters of VFS/VM events can be swapped out.

Tested by:	pho
Reviewed by:	jhb
MFC after:	1 week

Revision 1.132: download - view: text, markup, annotated - select for diffs
Tue Nov 3 16:46:52 2009 UTC (2 years, 3 months ago) by attilio
Branches: MAIN
Diff to: previous 1.131: preferred, colored
Changes since revision 1.131: +8 -8 lines
SVN rev 198854 on 2009-11-03 16:46:52Z by attilio

Split P_NOLOAD into a per-thread flag (TDF_NOLOAD).
This improvements aims for avoiding further cache-misses in scheduler
specific functions which need to keep track of average thread running
time and further locking in places setting for this flag.

Reported by:	jeff (originally), kris (currently)
Reviewed by:	jhb
Tested by:	Giuseppe Cocomazzi <sbudella at email dot it>

Revision 1.131.2.1.2.1: download - view: text, markup, annotated - select for diffs
Sun Oct 25 01:10:29 2009 UTC (2 years, 3 months ago) by kensmith
Branches: RELENG_8_0
CVS tags: RELENG_8_0_0_RELEASE
Diff to: previous 1.131.2.1: preferred, colored; next MAIN 1.131.2.2: preferred, colored
Changes since revision 1.131.2.1: +0 -0 lines
SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)

Revision 1.131.2.1: download - view: text, markup, annotated - select for diffs
Mon Aug 3 08:13:06 2009 UTC (2 years, 6 months ago) by kensmith
Branches: RELENG_8
CVS tags: RELENG_8_0_BP
Branch point for: RELENG_8_0
Diff to: previous 1.131: preferred, colored
Changes since revision 1.131: +0 -0 lines
SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)

Revision 1.106.2.8.4.1: download - view: text, markup, annotated - select for diffs
Wed Apr 15 03:14:26 2009 UTC (2 years, 9 months ago) by kensmith
Branches: RELENG_7_2
CVS tags: RELENG_7_2_0_RELEASE
Diff to: previous 1.106.2.8: preferred, colored; next MAIN 1.106.2.9: preferred, colored
Changes since revision 1.106.2.8: +0 -0 lines
SVN rev 191087 on 2009-04-15 03:14:26Z by kensmith

Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.

Approved by:	re (implicit)

Revision 1.131: download - view: text, markup, annotated - select for diffs
Sun Jan 25 07:35:10 2009 UTC (3 years ago) by jeff
Branches: MAIN
CVS tags: RELENG_8_BP
Branch point for: RELENG_8
Diff to: previous 1.130: preferred, colored
Changes since revision 1.130: +1 -1 lines
SVN rev 187679 on 2009-01-25 07:35:10Z by jeff

 - Use __XSTRING where I want the define to be expanded.  This resulted in
   sizeof("MAXCPU") being used to calculate a string length rather than
   something more reasonable such as sizeof("32").  This shouldn't have
   caused any ill effect until we run on machines with 1000000 or more
   cpus.

Revision 1.130: download - view: text, markup, annotated - select for diffs
Sat Jan 17 07:17:57 2009 UTC (3 years ago) by jeff
Branches: MAIN
Diff to: previous 1.129: preferred, colored
Changes since revision 1.129: +54 -18 lines
SVN rev 187357 on 2009-01-17 07:17:57Z by jeff

 - Implement generic macros for producing KTR records that are compatible
   with src/tools/sched/schedgraph.py.  This allows developers to quickly
   create a graphical view of ktr data for any resource in the system.
 - Add sched_tdname() and the pcpu field 'name' for quickly and uniformly
   identifying records associated with a thread or cpu.
 - Reimplement the KTR_SCHED traces using the new generic facility.

Obtained from:	attilio
Discussed with:	jhb
Sponsored by:	Nokia

Revision 1.106.2.8.2.1: download - view: text, markup, annotated - select for diffs
Tue Nov 25 02:59:29 2008 UTC (3 years, 2 months ago) by kensmith
Branches: RELENG_7_1
CVS tags: RELENG_7_1_0_RELEASE
Diff to: previous 1.106.2.8: preferred, colored; next MAIN 1.106.2.9: preferred, colored
Changes since revision 1.106.2.8: +0 -0 lines
SVN rev 185281 on 2008-11-25 02:59:29Z by kensmith

Create releng/7.1 in preparation for moving into RC phase of 7.1 release
cycle.

Approved by:	re (implicit)

Revision 1.77.2.2.2.1: download - view: text, markup, annotated - select for diffs
Thu Oct 2 02:57:24 2008 UTC (3 years, 4 months ago) by kensmith
Branches: RELENG_6_4
CVS tags: RELENG_6_4_0_RELEASE
Diff to: previous 1.77.2.2: preferred, colored; next MAIN 1.78: preferred, colored
Changes since revision 1.77.2.2: +0 -0 lines
SVN rev 183531 on 2008-10-02 02:57:24Z by kensmith

Create releng/6.4 from stable/6 in preparation for 6.4-RC1.

Approved by:	re (implicit)

Revision 1.106.2.8: download - view: text, markup, annotated - select for diffs
Wed Aug 27 04:41:15 2008 UTC (3 years, 5 months ago) by jb
Branches: RELENG_7
CVS tags: RELENG_7_2_BP, RELENG_7_1_BP
Branch point for: RELENG_7_2, RELENG_7_1
Diff to: previous 1.106.2.7: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.7: +16 -0 lines
SVN rev 182231 on 2008-08-27 04:41:15Z by jb

MFC

DTrace support.

Note that this defaults the 'make buildkernel' to build with CTF data so
that the release kernel and modules are DTrace-able.

Revision 1.106.2.7: download - view: text, markup, annotated - select for diffs
Thu Aug 14 22:04:52 2008 UTC (3 years, 5 months ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.6: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.6: +119 -0 lines
SVN rev 181742 on 2008-08-14 22:04:52Z by jhb

MFC: Add support for cpusets to the 4BSD scheduler.

Committed from:	my iPhone

Revision 1.106.2.6: download - view: text, markup, annotated - select for diffs
Thu Aug 14 19:27:47 2008 UTC (3 years, 5 months ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.5: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.5: +75 -73 lines
SVN rev 181737 on 2008-08-14 19:27:47Z by jhb

MFC: Various and sundry whitespace fixes.

Revision 1.106.2.5: download - view: text, markup, annotated - select for diffs
Thu Aug 14 18:51:19 2008 UTC (3 years, 5 months ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.4: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.4: +11 -17 lines
SVN rev 181736 on 2008-08-14 18:51:19Z by jhb

MFC: Retire the odd ts_flags #define that caused us to often go from the
thread to the td_sched back to the thread to find flags.

Revision 1.129: download - view: text, markup, annotated - select for diffs
Mon Jul 28 20:39:21 2008 UTC (3 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.128: preferred, colored
Changes since revision 1.128: +4 -1 lines
SVN rev 180937 on 2008-07-28 20:39:21Z by jhb

When choosing a CPU for a thread in a cpuset, prefer the last CPU that the
thread ran on if there are no other CPUs in the set with a shorter per-CPU
runqueue.

Revision 1.128: download - view: text, markup, annotated - select for diffs
Mon Jul 28 17:25:24 2008 UTC (3 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.127: preferred, colored
Changes since revision 1.127: +116 -0 lines
SVN rev 180923 on 2008-07-28 17:25:24Z by jhb

Implement support for cpusets in the 4BSD scheduler.
- When a cpuset is applied to a thread, walk the cpuset to see if it is a
  "full" cpuset (includes all available CPUs).  If not, set a new
  TDS_AFFINITY flag to indicate that this thread can't run on all CPUs.
  When inheriting a cpuset from another thread during thread creation, the
  new thread also inherits this flag.  It is in a new ts_flags field in
  td_sched rather than using one of the TDF_SCHEDx flags because fork()
  clears td_flags after invoking sched_fork().
- When placing a thread on a runqueue via sched_add(), if the thread is not
  pinned or bound but has the TDS_AFFINITY flag set, then invoke a new
  routine (sched_pickcpu()) to pick a CPU for the thread to run on next.
  sched_pickcpu() walks the cpuset and picks the CPU with the shortest
  per-CPU runqueue length.  Note that the reason for the TDS_AFFINITY flag
  is to avoid having to walk the cpuset and examine runq lengths in the
  common case.
- To avoid walking the per-CPU runqueues in sched_pickcpu(), add an array
  of counters to hold the length of the per-CPU runqueues and update them
  when adding and removing threads to per-CPU runqueues.

MFC after:	2 weeks

Revision 1.127: download - view: text, markup, annotated - select for diffs
Mon Jul 28 15:52:02 2008 UTC (3 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.126: preferred, colored
Changes since revision 1.126: +74 -74 lines
SVN rev 180879 on 2008-07-28 15:52:02Z by jhb

Various and sundry style and whitespace fixes.

Revision 1.106.2.4: download - view: text, markup, annotated - select for diffs
Fri Jul 25 17:46:01 2008 UTC (3 years, 6 months ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.3: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.3: +7 -0 lines
SVN rev 180808 on 2008-07-25 17:46:01Z by jhb

MFC: Add cpuset, an api for thread to cpu binding and cpu resource grouping
and assignment.  This is mostly synched up with what is in HEAD with the
following exceptions:
- I didn't MFC any of the interrupt binding stuff as it requires other
  changes and I figured this change was large enough as it is.
- The sched_affinity() implementation for ULE in HEAD depends on the newer
  CPU topology stuff as well as other changes in ULE.  Rather than
  backport all of that, I implemented sched_affinity() using the existing
  CPU topology and ULE code in 7.x.  Thus, any bugs in the ULE affinity
  stuff in 7 are purely my fault and not Jeff's.

Note that, just as in HEAD, cpusets currently don't work on SCHED_4BSD (the
syscalls will succeed, but they don't have any effect).

Tested by:	brooks, ps

Revision 1.106.2.3: download - view: text, markup, annotated - select for diffs
Tue Jul 22 14:27:47 2008 UTC (3 years, 6 months ago) by rwatson
Branches: RELENG_7
Diff to: previous 1.106.2.2: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.2: +3 -2 lines
SVN rev 180695 on 2008-07-22 14:27:47Z by rwatson

Merge r177253, r177255 from head to stable/7:

  In keeping with style(9)'s recommendations on macros, use a ';'
  after each SYSINIT() macro invocation.  This makes a number of
  lightweight C parsers much happier with the FreeBSD kernel
  source, including cflow's prcc and lxr.

  Discussed with: imp, rink

The requirement to place a ; after each SYSINIT definition has not been
MFC'd, as this might break the compile third-party modules, but merging
the actual ; additions reduces diffs against 8.x making it easier to
merge other changes.

Revision 1.77.2.2: download - view: text, markup, annotated - select for diffs
Tue Jun 24 19:55:22 2008 UTC (3 years, 7 months ago) by jhb
Branches: RELENG_6
CVS tags: RELENG_6_4_BP
Branch point for: RELENG_6_4
Diff to: previous 1.77.2.1: preferred, colored; branchpoint 1.77: preferred, colored; next MAIN 1.78: preferred, colored
Changes since revision 1.77.2.1: +8 -29 lines
SVN rev 179975 on 2008-06-24 19:55:22Z by jhb

MFC: Change the roundrobin implementation in the 4BSD scheduler to trigger a
userland preemption directly from hardclock() via sched_clock().

Revision 1.106.2.2: download - view: text, markup, annotated - select for diffs
Tue Jun 24 19:36:33 2008 UTC (3 years, 7 months ago) by jhb
Branches: RELENG_7
Diff to: previous 1.106.2.1: preferred, colored; branchpoint 1.106: preferred, colored
Changes since revision 1.106.2.1: +8 -29 lines
SVN rev 179974 on 2008-06-24 19:36:33Z by jhb

MFC: Change the roundrobin implementation in the 4BSD scheduler to trigger a
userland preemption directly from hardclock() via sched_clock().

Revision 1.126: download - view: text, markup, annotated - select for diffs
Sun May 25 01:44:58 2008 UTC (3 years, 8 months ago) by jb
Branches: MAIN
Diff to: previous 1.125: preferred, colored
Changes since revision 1.125: +17 -0 lines
Add the vtime (virtual time) hooks for DTrace.

Revision 1.125: download - view: text, markup, annotated - select for diffs
Fri Apr 25 05:18:49 2008 UTC (3 years, 9 months ago) by jeff
Branches: MAIN
Diff to: previous 1.124: preferred, colored
Changes since revision 1.124: +1 -1 lines
 - Add an integer argument to idle to indicate how likely we are to wake
   from idle over the next tick.
 - Add a new MD routine, cpu_wake_idle() to wakeup idle threads who are
   suspended in cpu specific states.  This function can fail and cause the
   scheduler to fall back to another mechanism (ipi).
 - Implement support for mwait in cpu_idle() on i386/amd64 machines that
   support it.  mwait is a higher performance way to synchronize cpus
   as compared to hlt & ipis.
 - Allow selecting the idle routine by name via sysctl machdep.idle.  This
   replaces machdep.cpu_idle_hlt.  Only idle routines supported by the
   current machine are permitted.

Sponsored by:	Nokia

Revision 1.124: download - view: text, markup, annotated - select for diffs
Thu Apr 17 04:20:10 2008 UTC (3 years, 9 months ago) by jeff
Branches: MAIN
Diff to: previous 1.123: preferred, colored
Changes since revision 1.123: +4 -6 lines
 - Make SCHED_STATS more generic by adding a wrapper to create the
   variables and sysctl nodes.
 - In reset walk the children of kern_sched_stats and reset the counters
   via the oid_arg1 pointer.  This allows us to add arbitrary counters to
   the tree and still reset them properly.
 - Define a set of switch types to be passed with flags to mi_switch().
   These types are named SWT_*.  These types correspond to SCHED_STATS
   counters and are automatically handled in this way.
 - Make the new SWT_ types more specific than the older switch stats.
   There are now stats for idle switches, remote idle wakeups, remote
   preemption ithreads idling, etc.
 - Add switch statistics for ULE's pickcpu algorithm.  These stats include
   how much migration there is, how often affinity was successful, how
   often threads were migrated to the local cpu on wakeup, etc.

Sponsored by:	Nokia

Revision 1.123: download - view: text, markup, annotated - select for diffs
Thu Mar 20 05:51:16 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.122: preferred, colored
Changes since revision 1.122: +30 -47 lines
 - Restore runq to manipulating threads directly by putting runq links and
   rqindex back in struct thread.
 - Compile kern_switch.c independently again and stop #include'ing it from
   schedulers.
 - Remove the ts_thread backpointers and convert most code to go from
   struct thread to struct td_sched.
 - Cleanup the ts_flags #define garbage that was causing us to sometimes
   do things that expanded to td->td_sched->ts_thread->td_flags in 4BSD.
 - Export the kern.sched sysctl node in sysctl.h

Revision 1.122: download - view: text, markup, annotated - select for diffs
Thu Mar 20 03:06:33 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.121: preferred, colored
Changes since revision 1.121: +5 -1 lines
 - ULE and 4BSD share only one line of code from sched_newthread() so implement
   the required pieces in sched_fork_thread().  The td_sched pointer is already
   setup by thread_init anyway.

Revision 1.121: download - view: text, markup, annotated - select for diffs
Thu Mar 20 02:14:02 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.120: preferred, colored
Changes since revision 1.120: +89 -1 lines
 - Move maybe_preempt() from kern_switch.c to sched_4bsd.c.  This is function
   is only used by 4bsd.
 - Create a new runq_choose_fuzz() function rather than polluting runq_choose()
   with 4BSD specific code.
 - Move the fuzz sysctl into sched_4bsd.c
 - Remove some dead code from kern_switch.c

Revision 1.120: download - view: text, markup, annotated - select for diffs
Thu Mar 20 01:32:48 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.119: preferred, colored
Changes since revision 1.119: +1 -0 lines
 - Directly include opt_sched.h in sched_4bsd.

Revision 1.119: download - view: text, markup, annotated - select for diffs
Wed Mar 19 06:19:00 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.118: preferred, colored
Changes since revision 1.118: +3 -4 lines
 - Relax requirements for p_numthreads, p_threads, p_swtick, and p_nice from
   requiring the per-process spinlock to only requiring the process lock.
 - Reflect these changes in the proc.h documentation and consumers throughout
   the kernel.  This is a substantial reduction in locking cost for these
   fields and was made possible by recent changes to threading support.

Revision 1.118: download - view: text, markup, annotated - select for diffs
Sun Mar 16 10:58:05 2008 UTC (3 years, 10 months ago) by rwatson
Branches: MAIN
Diff to: previous 1.117: preferred, colored
Changes since revision 1.117: +3 -2 lines
In keeping with style(9)'s recommendations on macros, use a ';'
after each SYSINIT() macro invocation.  This makes a number of
lightweight C parsers much happier with the FreeBSD kernel
source, including cflow's prcc and lxr.

MFC after:	1 month
Discussed with:	imp, rink

Revision 1.117: download - view: text, markup, annotated - select for diffs
Wed Mar 12 10:11:59 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.116: preferred, colored
Changes since revision 1.116: +0 -2 lines
Remove kernel support for M:N threading.

While the KSE project was quite successful in bringing threading to
FreeBSD, the M:N approach taken by the kse library was never developed
to its full potential.  Backwards compatibility will be provided via
libmap.conf for dynamically linked binaries and static binaries will
be broken.

Revision 1.116: download - view: text, markup, annotated - select for diffs
Wed Mar 12 06:31:06 2008 UTC (3 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.115: preferred, colored
Changes since revision 1.115: +6 -1 lines
 - Pass the priority argument from *sleep() into sleepq and down into
   sched_sleep().  This removes extra thread_lock() acquisition and
   allows the scheduler to decide what to do with the static boost.
 - Change the priority arguments to cv_* to match sleepq/msleep/etc.
   where 0 means no priority change.  Catch -1 in cv_broadcastpri() and
   convert it to 0 for now.
 - Set a flag when sleeping in a way that is compatible with swapping
   since direct priority comparisons are meaningless now.
 - Add a sysctl to ule, kern.sched.static_boost, that defaults to on which
   controls the boost behavior.  Turning it off gives better performance
   in some workloads but needs more investigation.
 - While we're modifying sleepq, change signal and broadcast to both
   return with the lock held as the lock was held on enter.

Reviewed by:	jhb, peter

Revision 1.115: download - view: text, markup, annotated - select for diffs
Mon Mar 10 01:30:35 2008 UTC (3 years, 11 months ago) by jeff
Branches: MAIN
Diff to: previous 1.114: preferred, colored
Changes since revision 1.114: +11 -0 lines
 - Add a sched_preempt() routine to be called by md code after IPI_PREEMPT is
   delivered.
 - Add a simple implementation to 4bsd.

Revision 1.114: download - view: text, markup, annotated - select for diffs
Sun Mar 2 21:34:57 2008 UTC (3 years, 11 months ago) by marcel
Branches: MAIN
Diff to: previous 1.113: preferred, colored
Changes since revision 1.113: +2 -0 lines
Unbreak after cpuset: initialize td_cpuset in sched_fork_thread().

Revision 1.113: download - view: text, markup, annotated - select for diffs
Sun Mar 2 07:19:35 2008 UTC (3 years, 11 months ago) by jeff
Branches: MAIN
Diff to: previous 1.112: preferred, colored
Changes since revision 1.112: +5 -0 lines
 - Add a new sched_affinity() api to be used in the upcoming cpuset
   implementation.
 - Add empty implementations of sched_affinity() to 4BSD and ULE.

Sponsored by:	Nokia

Revision 1.106.2.1: download - view: text, markup, annotated - select for diffs
Thu Dec 20 07:15:40 2007 UTC (4 years, 1 month ago) by davidxu
Branches: RELENG_7
CVS tags: RELENG_7_0_BP, RELENG_7_0_0_RELEASE, RELENG_7_0
Diff to: previous 1.106: preferred, colored
Changes since revision 1.106: +5 -7 lines
MFC:
    Fix LOR of thread lock and umtx's priority propagation mutex due
    to the reworking of scheduler lock.

Approved by: re (kensmith)

Revision 1.112: download - view: text, markup, annotated - select for diffs
Sat Dec 15 23:13:31 2007 UTC (4 years, 1 month ago) by jeff
Branches: MAIN
Diff to: previous 1.111: preferred, colored
Changes since revision 1.111: +6 -1 lines
 - Re-implement lock profiling in such a way that it no longer breaks
   the ABI when enabled.  There is no longer an embedded lock_profile_object
   in each lock.  Instead a list of lock_profile_objects is kept per-thread
   for each lock it may own.  The cnt_hold statistic is now always 0 to
   facilitate this.
 - Support shared locking by tracking individual lock instances and
   statistics in the per-thread per-instance lock_profile_object.
 - Make the lock profiling hash table a per-cpu singly linked list with a
   per-cpu static lock_prof allocator.  This removes the need for an array
   of spinlocks and reduces cache contention between cores.
 - Use a seperate hash for spinlocks and other locks so that only a
   critical_enter() is required and not a spinlock_enter() to modify the
   per-cpu tables.
 - Count time spent spinning in the lock statistics.
 - Remove the LOCK_PROFILE_SHARED option as it is always supported now.
 - Specifically drop and release the scheduler locks in both schedulers
   since we track owners now.

In collaboration with:	Kip Macy
Sponsored by:	Nokia

Revision 1.111: download - view: text, markup, annotated - select for diffs
Tue Dec 11 08:25:36 2007 UTC (4 years, 2 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.110: preferred, colored
Changes since revision 1.110: +5 -8 lines
Fix LOR of thread lock and umtx's priority propagation mutex due
to the reworking of scheduler lock.

MFC: after 3 days

Revision 1.110: download - view: text, markup, annotated - select for diffs
Wed Nov 14 06:21:22 2007 UTC (4 years, 2 months ago) by julian
Branches: MAIN
Diff to: previous 1.109: preferred, colored
Changes since revision 1.109: +10 -10 lines
generally we are interested in what thread did something as
opposed to what process. Since threads by default have teh name of the
process unless over-written with more useful information, just print the
thread name instead.

Revision 1.109: download - view: text, markup, annotated - select for diffs
Mon Nov 5 12:01:12 2007 UTC (4 years, 3 months ago) by rwatson
Branches: MAIN
Diff to: previous 1.108: preferred, colored
Changes since revision 1.108: +0 -2 lines
Remove unused variable td from sched_idletd().

MFC after:	3 days
Found with:	Coverity Prevent(tm)
CID:		3561

Revision 1.108: download - view: text, markup, annotated - select for diffs
Sat Oct 27 22:07:40 2007 UTC (4 years, 3 months ago) by jhb
Branches: MAIN
Diff to: previous 1.107: preferred, colored
Changes since revision 1.107: +8 -29 lines
Change the roundrobin implementation in the 4BSD scheduler to trigger a
userland preemption directly from hardclock() via sched_clock() when a
thread uses up a full quantum instead of using a periodic timeout to cause
a userland preemption every so often.  This fixes a potential deadlock
when IPI_PREEMPTION isn't enabled where softclock blocks on a lock held
by a thread pinned or bound to another CPU.  The current thread on that
CPU will never be preempted while softclock is blocked.

Note that ULE already drives its round-robin userland preemption from
sched_clock() as well and always enables IPI_PREEMPT.

MFC after:	1 week

Revision 1.107: download - view: text, markup, annotated - select for diffs
Fri Oct 26 08:00:41 2007 UTC (4 years, 3 months ago) by julian
Branches: MAIN
Diff to: previous 1.106: preferred, colored
Changes since revision 1.106: +0 -2 lines
Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create()
plus a pointer to a process structure, and adds a kernel thread
to that process.

kproc_kthread_add() takes the parameters for kthread_add,
plus a process name and a pointer to a pointer to a process instead of just
a pointer, and if the proc * is NULL, it creates the process to the
specifications required, before adding the thread to it.

All other old kthread_xxx() calls return, but act on (struct thread *)
instead of (struct proc *). One reason to change the name is so that
any old kernel modules that are lying around and expect kthread_create()
to make a process will not just accidentally link.

fix top to show  kernel threads by their thread name in -SH mode
add a tdnam formatting option to ps to show thread names.

make all idle threads actual kthreads and put them into their own idled process.
make all interrupt threads kthreads and put them in an interd process
(mainly for aesthetic and accounting reasons)
rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper'

man page fixes to follow.

Revision 1.106: download - view: text, markup, annotated - select for diffs
Mon Oct 8 23:45:24 2007 UTC (4 years, 4 months ago) by jeff
Branches: MAIN
CVS tags: RELENG_7_BP
Branch point for: RELENG_7
Diff to: previous 1.105: preferred, colored
Changes since revision 1.105: +0 -2 lines
 - Restore historical sched_yield() behavior by changing sched_relinquish()
   to simply switch rather than lowering priority and switching.  This allows
   threads of equal priority to run but not lesser priority.

Discussed with:	davidxu
Reported by:	NIIMI Satoshi <sa2c@sa2c.net>
Approved by:	re

Revision 1.105: download - view: text, markup, annotated - select for diffs
Fri Sep 21 04:10:23 2007 UTC (4 years, 4 months ago) by jeff
Branches: MAIN
Diff to: previous 1.104: preferred, colored
Changes since revision 1.104: +20 -17 lines
 - Redefine p_swtime and td_slptime as p_swtick and td_slptick.  This
   changes the units from seconds to the value of 'ticks' when swapped
   in/out.  ULE does not have a periodic timer that scans all threads in
   the system and as such maintaining a per-second counter is difficult.
 - Change computations requiring the unit in seconds to subtract ticks
   and divide by hz.  This does make the wraparound condition hz times
   more frequent but this is still in the range of several months to
   years and the adverse effects are minimal.

Approved by:	re

Revision 1.104: download - view: text, markup, annotated - select for diffs
Mon Sep 17 05:27:20 2007 UTC (4 years, 4 months ago) by jeff
Branches: MAIN
Diff to: previous 1.103: preferred, colored
Changes since revision 1.103: +8 -8 lines
 - Move all of the PS_ flags into either p_flag or td_flags.
 - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or
   previously the sched_lock.  These bugs have existed for some time.
 - Allow swapout to try each thread in a process individually and then
   swapin the whole process if any of these fail.  This allows us to move
   most scheduler related swap flags into td_flags.
 - Keep ki_sflag for backwards compat but change all in source tools to
   use the new and more correct location of P_INMEM.

Reported by:	pho
Reviewed by:	attilio, kib
Approved by:	re (kensmith)

Revision 1.103: download - view: text, markup, annotated - select for diffs
Wed Jul 18 20:46:05 2007 UTC (4 years, 6 months ago) by jeff
Branches: MAIN
Diff to: previous 1.102: preferred, colored
Changes since revision 1.102: +2 -0 lines
 - Remove the global definition of sched_lock in mutex.h to break
   new code and third party modules which try to depend on it.
 - Initialize sched_lock in sched_4bsd.c.
 - Declare sched_lock in sparc64 pmap.c and assert that we're compiling
   with SCHED_4BSD to prevent accidental crashes from running ULE.  This
   is the sole remaining file outside of the scheduler that uses the
   global sched_lock.

Approved by:	re

Revision 1.102: download - view: text, markup, annotated - select for diffs
Tue Jun 12 07:47:09 2007 UTC (4 years, 7 months ago) by jeff
Branches: MAIN
Diff to: previous 1.101: preferred, colored
Changes since revision 1.101: +4 -15 lines
 - Move some common code out of sched_fork_exit() and back into fork_exit().

Revision 1.101: download - view: text, markup, annotated - select for diffs
Wed Jun 6 03:40:46 2007 UTC (4 years, 8 months ago) by jeff
Branches: MAIN
Diff to: previous 1.100: preferred, colored
Changes since revision 1.100: +1 -1 lines
 - Placing the 'volatile' on the right side of the * in the td_lock
   declaration removes the need for __DEVOLATILE().

Pointed out by:	tegge

Revision 1.100: download - view: text, markup, annotated - select for diffs
Tue Jun 5 04:12:46 2007 UTC (4 years, 8 months ago) by jeff
Branches: MAIN
Diff to: previous 1.99: preferred, colored
Changes since revision 1.99: +1 -1 lines
 - Better fix for previous error; use DEVOLATILE on the td_lock pointer
   it can actually sometimes be something other than sched_lock even on
   schedulers which rely on a global scheduler lock.

Tested by:	kan

Revision 1.99: download - view: text, markup, annotated - select for diffs
Tue Jun 5 03:46:54 2007 UTC (4 years, 8 months ago) by jeff
Branches: MAIN
Diff to: previous 1.98: preferred, colored
Changes since revision 1.98: +1 -1 lines
 - Pass &sched_lock as the third argument to cpu_switch() as this will
   always be the correct lock and we don't get volatile warnings this
   way.

Pointed out by:	kan

Revision 1.98: download - view: text, markup, annotated - select for diffs
Mon Jun 4 23:50:30 2007 UTC (4 years, 8 months ago) by jeff
Branches: MAIN
Diff to: previous 1.97: preferred, colored
Changes since revision 1.97: +115 -45 lines
Commit 1/14 of sched_lock decomposition.
 - Move all scheduler locking into the schedulers utilizing a technique
   similar to solaris's container locking.
 - A per-process spinlock is now used to protect the queue of threads,
   thread count, suspension count, p_sflags, and other process
   related scheduling fields.
 - The new thread lock is actually a pointer to a spinlock for the
   container that the thread is currently owned by.  The container may
   be a turnstile, sleepqueue, or run queue.
 - thread_lock() is now used to protect access to thread related scheduling
   fields.  thread_unlock() unlocks the lock and thread_set_lock()
   implements the transition from one lock to another.
 - A new "blocked_lock" is used in cases where it is not safe to hold the
   actual thread's lock yet we must prevent access to the thread.
 - sched_throw() and sched_fork_exit() are introduced to allow the
   schedulers to fix-up locking at these points.
 - Add some minor infrastructure for optionally exporting scheduler
   statistics that were invaluable in solving performance problems with
   this patch.  Generally these statistics allow you to differentiate
   between different causes of context switches.

Tested by:      kris, current@
Tested on:      i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc.
Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)

Revision 1.97: download - view: text, markup, annotated - select for diffs
Tue Feb 27 17:23:27 2007 UTC (4 years, 11 months ago) by jhb
Branches: MAIN
Diff to: previous 1.96: preferred, colored
Changes since revision 1.96: +1 -2 lines
Use pause() rather than tsleep() on stack variables and function pointers.

Revision 1.96: download - view: text, markup, annotated - select for diffs
Fri Feb 2 05:14:21 2007 UTC (5 years ago) by julian
Branches: MAIN
Diff to: previous 1.95: preferred, colored
Changes since revision 1.95: +25 -17 lines
Move the seting of the idle_mask bits to a place where they
can't be wrong.
Also use the IDLETD bit in the thread mask to test if its an idle thread
rather than doing a PCPU access.

Revision 1.95: download - view: text, markup, annotated - select for diffs
Tue Jan 23 08:46:50 2007 UTC (5 years ago) by jeff
Branches: MAIN
Diff to: previous 1.94: preferred, colored
Changes since revision 1.94: +65 -34 lines
 - Remove setrunqueue and replace it with direct calls to sched_add().
   setrunqueue() was mostly empty.  The few asserts and thread state
   setting were moved to the individual schedulers.  sched_add() was
   chosen to displace it for naming consistency reasons.
 - Remove adjustrunqueue, it was 4 lines of code that was ifdef'd to be
   different on all three schedulers where it was only called in one place
   each.
 - Remove the long ifdef'd out remrunqueue code.
 - Remove the now redundant ts_state.  Inspect the thread state directly.
 - Don't set TSF_* flags from kern_switch.c, we were only doing this to
   support a feature in one scheduler.
 - Change sched_choose() to return a thread rather than a td_sched.  Also,
   rely on the schedulers to return the idlethread.  This simplifies the
   logic in choosethread().  Aside from the run queue links kern_switch.c
   mostly does not care about the contents of td_sched.

Discussed with:	julian

 - Move the idle thread loop into the per scheduler area.  ULE wants to
   do something different from the other schedulers.

Suggested by:	jhb

Tested on:	x86/amd64 sched_{4BSD, ULE, CORE}.

Revision 1.94: download - view: text, markup, annotated - select for diffs
Sun Dec 31 15:56:04 2006 UTC (5 years, 1 month ago) by rwatson
Branches: MAIN
Diff to: previous 1.93: preferred, colored
Changes since revision 1.93: +1 -1 lines
Prefer a more traditional spelling of inhibited in comments and panic
messages.

Revision 1.93: download - view: text, markup, annotated - select for diffs
Sun Dec 24 01:52:27 2006 UTC (5 years, 1 month ago) by davidxu
Branches: MAIN
Diff to: previous 1.92: preferred, colored
Changes since revision 1.92: +1 -1 lines
Fix typo, p_slptime should be td_slptime.

Revision 1.92: download - view: text, markup, annotated - select for diffs
Wed Dec 6 06:34:55 2006 UTC (5 years, 2 months ago) by julian
Branches: MAIN
Diff to: previous 1.91: preferred, colored
Changes since revision 1.91: +134 -628 lines
Threading cleanup.. part 2 of several.

Make part of John Birrell's KSE patch permanent..
Specifically, remove:
Any reference of the ksegrp structure. This feature was
never fully utilised and made things overly complicated.
All code in the scheduler that tried to make threaded programs
fair to unthreaded programs.  Libpthread processes will already
do this to some extent and libthr processes already disable it.

Also:
Since this makes such a big change to the scheduler(s), take the opportunity
to rename some structures and elements that had to be moved anyhow.
This makes the code a lot more readable.

The ULE scheduler compiles again but I have no idea if it works.

The 4bsd scheduler still reqires a little cleaning and some functions that now do
ALMOST nothing will go away, but I thought I'd do that as a separate commit.

Tested by David Xu, and Dan Eischen using libthr and libpthread.

Revision 1.91: download - view: text, markup, annotated - select for diffs
Mon Nov 20 16:13:02 2006 UTC (5 years, 2 months ago) by julian
Branches: MAIN
Diff to: previous 1.90: preferred, colored
Changes since revision 1.90: +6 -6 lines
whitespace fix only

Revision 1.90: download - view: text, markup, annotated - select for diffs
Tue Nov 14 05:48:27 2006 UTC (5 years, 2 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.89: preferred, colored
Changes since revision 1.89: +12 -12 lines
Fix a copy-paste bug in NON-KSE case.

Revision 1.89: download - view: text, markup, annotated - select for diffs
Sat Nov 11 13:11:29 2006 UTC (5 years, 2 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.88: preferred, colored
Changes since revision 1.88: +2 -1 lines
Unbreak userland priority inheriting in NO_KSE case.

Revision 1.88: download - view: text, markup, annotated - select for diffs
Thu Oct 26 21:42:20 2006 UTC (5 years, 3 months ago) by jb
Branches: MAIN
Diff to: previous 1.87: preferred, colored
Changes since revision 1.87: +358 -0 lines
Make KSE a kernel option, turned on by default in all GENERIC
kernel configs except sun4v (which doesn't process signals properly
with KSE).

Reviewed by:	davidxu@

Revision 1.87: download - view: text, markup, annotated - select for diffs
Fri Aug 25 06:12:53 2006 UTC (5 years, 5 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.86: preferred, colored
Changes since revision 1.86: +56 -1 lines
Add user priority loaning code to support priority propagation for
1:1 threading's POSIX priority mutexes, the code is no-op unless
priority-aware umtx code is committed.

Revision 1.86: download - view: text, markup, annotated - select for diffs
Sun Jul 2 20:53:52 2006 UTC (5 years, 7 months ago) by maxim
Branches: MAIN
Diff to: previous 1.85: preferred, colored
Changes since revision 1.85: +7 -7 lines
o Fix grammar in the comment, indent macros.  No functional changes.

Revision 1.85: download - view: text, markup, annotated - select for diffs
Sun Jul 2 20:49:46 2006 UTC (5 years, 7 months ago) by maxim
Branches: MAIN
Diff to: previous 1.84: preferred, colored
Changes since revision 1.84: +0 -2 lines
o Remove rev. 1.57 leftover, not reached code.

Revision 1.84: download - view: text, markup, annotated - select for diffs
Thu Jun 29 19:37:31 2006 UTC (5 years, 7 months ago) by obrien
Branches: MAIN
Diff to: previous 1.83: preferred, colored
Changes since revision 1.83: +1 -0 lines
Fix building with GCC 4.2: define data types before referring to them.

Revision 1.77.2.1: download - view: text, markup, annotated - select for diffs
Fri Jun 16 22:11:55 2006 UTC (5 years, 7 months ago) by jhb
Branches: RELENG_6
CVS tags: RELENG_6_3_BP, RELENG_6_3_0_RELEASE, RELENG_6_3, RELENG_6_2_BP, RELENG_6_2_0_RELEASE, RELENG_6_2
Diff to: previous 1.77: preferred, colored
Changes since revision 1.77: +1 -1 lines
MFC: Change msleep() and tsleep() to not alter the calling thread's
priority if the specified priority is zero.

Revision 1.83: download - view: text, markup, annotated - select for diffs
Thu Jun 15 06:37:39 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.82: preferred, colored
Changes since revision 1.82: +15 -0 lines
Add scheduler API sched_relinquish(), the API is used to implement
yield() and sched_yield() syscalls. Every scheduler has its own way
to relinquish cpu, the ULE and CORE schedulers have two internal run-
queues, a timesharing thread which calls yield() syscall should be
moved to inactive queue.

Revision 1.82: download - view: text, markup, annotated - select for diffs
Tue Jun 13 13:12:56 2006 UTC (5 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.81: preferred, colored
Changes since revision 1.81: +5 -0 lines
Add scheduler CORE, the work I have done half a year ago, recent,
I picked it up again. The scheduler is forked from ULE, but the
algorithm to detect an interactive process is almost completely
different with ULE, it comes from Linux paper "Understanding the
Linux 2.6.8.1 CPU Scheduler", although I still use same word
"score" as a priority boost in ULE scheduler.

Briefly, the scheduler has following characteristic:
1. Timesharing process's nice value is seriously respected,
   timeslice and interaction detecting algorithm are based
   on nice value.
2. per-cpu scheduling queue and load balancing.
3. O(1) scheduling.
4. Some cpu affinity code in wakeup path.
5. Support POSIX SCHED_FIFO and SCHED_RR.
Unlike scheduler 4BSD and ULE which using fuzzy RQ_PPQ, the scheduler
uses 256 priority queues. Unlike ULE which using pull and push, the
scheduelr uses pull method, the main reason is to let relative idle
cpu do the work, but current the whole scheduler is protected by the
big sched_lock, so the benefit is not visible, it really can be worse
than nothing because all other cpu are locked out when we are doing
balancing work, which the 4BSD scheduelr does not have this problem.
The scheduler does not support hyperthreading very well, in fact,
the scheduler does not make the difference between physical CPU and
logical CPU, this should be improved in feature. The scheduler has
priority inversion problem on MP machine, it is not good for
realtime scheduling, it can cause realtime process starving.
As a result, it seems the MySQL super-smack runs better on my
Pentium-D machine when using libthr, despite on UP or SMP kernel.

Revision 1.81: download - view: text, markup, annotated - select for diffs
Tue Jun 6 12:26:17 2006 UTC (5 years, 8 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.80: preferred, colored
Changes since revision 1.80: +1 -1 lines
Make ke_rqindex unsigned.

Revision 1.80: download - view: text, markup, annotated - select for diffs
Thu Apr 27 17:57:59 2006 UTC (5 years, 9 months ago) by jmg
Branches: MAIN
Diff to: previous 1.79: preferred, colored
Changes since revision 1.79: +1 -1 lines
back out for now...  revert ccpu to being kern.ccpu...

Revision 1.79: download - view: text, markup, annotated - select for diffs
Wed Apr 26 19:42:38 2006 UTC (5 years, 9 months ago) by jmg
Branches: MAIN
Diff to: previous 1.78: preferred, colored
Changes since revision 1.78: +1 -1 lines
move remaining sysctl into the kern.sched tree...

Revision 1.78: download - view: text, markup, annotated - select for diffs
Mon Apr 17 18:20:37 2006 UTC (5 years, 9 months ago) by jhb
Branches: MAIN
Diff to: previous 1.77: preferred, colored
Changes since revision 1.77: +1 -1 lines
Change msleep() and tsleep() to not alter the calling thread's priority
if the specified priority is zero.  This avoids a race where the calling
thread could read a snapshot of it's current priority, then a different
thread could change the first thread's priority, then the original thread
would call sched_prio() inside msleep() undoing the change made by the
second thread.  I used a priority of zero as no thread that calls msleep()
or tsleep() should be specifying a priority of zero anyway.

The various places that passed 'curthread->td_priority' or some variant
as the priority now pass 0.

Revision 1.49.2.16: download - view: text, markup, annotated - select for diffs
Sun Jul 3 20:08:04 2005 UTC (6 years, 7 months ago) by ups
Branches: RELENG_5
CVS tags: RELENG_5_5_BP, RELENG_5_5_0_RELEASE, RELENG_5_5
Diff to: previous 1.49.2.15: preferred, colored; branchpoint 1.49: preferred, colored; next MAIN 1.50: preferred, colored
Changes since revision 1.49.2.15: +98 -50 lines
MFC: kern/kern_switch.c 1.112, 1.114-1.116
     kern/sched_4bsd.c 1.74 1.75

Fix some race conditions for pinned threads that may cause them to run
on the wrong CPU.

Add IPI support for preempting a thread on another CPU.
( To reduce diff for future MFCs, The required MD Part to support
  IPI preemption is not part of this MFC)

Revision 1.77: download - view: text, markup, annotated - select for diffs
Fri Jun 24 00:16:57 2005 UTC (6 years, 7 months ago) by peter
Branches: MAIN
CVS tags: RELENG_6_BP, RELENG_6_1_BP, RELENG_6_1_0_RELEASE, RELENG_6_1, RELENG_6_0_BP, RELENG_6_0_0_RELEASE, RELENG_6_0
Branch point for: RELENG_6
Diff to: previous 1.76: preferred, colored
Changes since revision 1.76: +2 -0 lines
Move HWPMC_HOOKS into its own opt_hwpmc_hooks.h file.  It doesn't merit
being in opt_global.h and forcing a global recompile when only a few files
reference it.

Approved by:  re

Revision 1.76: download - view: text, markup, annotated - select for diffs
Thu Jun 9 19:43:08 2005 UTC (6 years, 8 months ago) by ups
Branches: MAIN
Diff to: previous 1.75: preferred, colored
Changes since revision 1.75: +7 -20 lines
Lots of whitespace cleanup.
Fix for broken if condition.

Submitted by:	nate@

Revision 1.75: download - view: text, markup, annotated - select for diffs
Thu Jun 9 18:26:31 2005 UTC (6 years, 8 months ago) by ups
Branches: MAIN
Diff to: previous 1.74: preferred, colored
Changes since revision 1.74: +108 -47 lines
Fix some race conditions for pinned threads that may cause them to run
on the wrong CPU.

Add IPI support for preempting a thread on another CPU.

MFC after:3 weeks

Revision 1.74: download - view: text, markup, annotated - select for diffs
Tue Apr 19 04:01:24 2005 UTC (6 years, 9 months ago) by jkoshy
Branches: MAIN
Diff to: previous 1.73: preferred, colored
Changes since revision 1.73: +22 -1 lines
Bring a working snapshot of hwpmc(4), its associated libraries, userland utilities
and documentation into -CURRENT.

Bump FreeBSD_version.

Reviewed by:	alc, jhb (kernel changes)

Revision 1.73: download - view: text, markup, annotated - select for diffs
Fri Apr 15 14:01:43 2005 UTC (6 years, 9 months ago) by maxim
Branches: MAIN
Diff to: previous 1.72: preferred, colored
Changes since revision 1.72: +1 -1 lines
Fix a typo in the comment.

Noticed by:	Samy Al Bahra

Revision 1.72: download - view: text, markup, annotated - select for diffs
Fri Apr 8 03:37:53 2005 UTC (6 years, 10 months ago) by ups
Branches: MAIN
Diff to: previous 1.71: preferred, colored
Changes since revision 1.71: +1 -1 lines
Sprinkle some volatile magic and rearrange things a bit to avoid race
conditions in critical_exit now that it no longer blocks interrupts.

Reviewed by:	jhb

Revision 1.49.2.15: download - view: text, markup, annotated - select for diffs
Sat Feb 5 08:09:02 2005 UTC (7 years ago) by jeff
Branches: RELENG_5
CVS tags: RELENG_5_4_BP, RELENG_5_4_0_RELEASE, RELENG_5_4
Diff to: previous 1.49.2.14: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.14: +2 -2 lines
 - Correct a bad merge job.

Pointy hat to me.

Revision 1.49.2.14: download - view: text, markup, annotated - select for diffs
Fri Feb 4 20:11:59 2005 UTC (7 years ago) by jeff
Branches: RELENG_5
Diff to: previous 1.49.2.13: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.13: +30 -6 lines
 - MFC KTR_SCHED/schedgraph support.

Revision 1.49.2.13: download - view: text, markup, annotated - select for diffs
Fri Feb 4 19:54:25 2005 UTC (7 years ago) by jeff
Branches: RELENG_5
Diff to: previous 1.49.2.12: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.12: +0 -2 lines
 - MFC removal of the unused ke_oncpu field.

Revision 1.71: download - view: text, markup, annotated - select for diffs
Thu Dec 30 20:52:44 2004 UTC (7 years, 1 month ago) by jhb
Branches: MAIN
Diff to: previous 1.70: preferred, colored
Changes since revision 1.70: +102 -14 lines
Rework the interface between priority propagation (lending) and the
schedulers a bit to ensure more correct handling of priorities and fewer
priority inversions:
- Add two functions to the sched(9) API to handle priority lending:
  sched_lend_prio() and sched_unlend_prio().  The turnstile code uses these
  functions to ask the scheduler to lend a thread a set priority and to
  tell the scheduler when it thinks it is ok for a thread to stop borrowing
  priority.  The unlend case is slightly complex in that the turnstile code
  tells the scheduler what the minimum priority of the thread needs to be
  to satisfy the requirements of any other threads blocked on locks owned
  by the thread in question.  The scheduler then decides where the thread
  can go back to normal mode (if it's normal priority is high enough to
  satisfy the pending lock requests) or it it should continue to use the
  priority specified to the sched_unlend_prio() call.  This involves adding
  a new per-thread flag TDF_BORROWING that replaces the ULE-only kse flag
  for priority elevation.
- Schedulers now refuse to lower the priority of a thread that is currently
  borrowing another therad's priority.
- If a scheduler changes the priority of a thread that is currently sitting
  on a turnstile, it will call a new function turnstile_adjust() to inform
  the turnstile code of the change.  This function resorts the thread on
  the priority list of the turnstile if needed, and if the thread ends up
  at the head of the list (due to having the highest priority) and its
  priority was raised, then it will propagate that new priority to the
  owner of the lock it is blocked on.

Some additional fixes specific to the 4BSD scheduler include:
- Common code for updating the priority of a thread when the user priority
  of its associated kse group has been consolidated in a new static
  function resetpriority_thread().  One change to this function is that
  it will now only adjust the priority of a thread if it already has a
  time sharing priority, thus preserving any boosts from a tsleep() until
  the thread returns to userland.  Also, resetpriority() no longer calls
  maybe_resched() on each thread in the group. Instead, the code calling
  resetpriority() is responsible for calling resetpriority_thread() on
  any threads that need to be updated.
- schedcpu() now uses resetpriority_thread() instead of just calling
  sched_prio() directly after it updates a kse group's user priority.
- sched_clock() now uses resetpriority_thread() rather than writing
  directly to td_priority.
- sched_nice() now updates all the priorities of the threads after the
  group priority has been adjusted.

Discussed with:	bde
Reviewed by:	ups, jeffr
Tested on:	4bsd, ule
Tested on:	i386, alpha, sparc64

Revision 1.70: download - view: text, markup, annotated - select for diffs
Sun Dec 26 00:16:24 2004 UTC (7 years, 1 month ago) by jeff
Branches: MAIN
Diff to: previous 1.69: preferred, colored
Changes since revision 1.69: +30 -6 lines
 - Wrap the thread count adjustment in sched_load_add() and sched_load_rem()
   so that we may place some ktr entries nearby.
 - Define other KTR_SCHED tracepoints so that we may graph the operation
   of the scheduler.

Revision 1.69: download - view: text, markup, annotated - select for diffs
Tue Dec 14 10:53:55 2004 UTC (7 years, 1 month ago) by jeff
Branches: MAIN
Diff to: previous 1.68: preferred, colored
Changes since revision 1.68: +0 -9 lines
 - Garbage collect several unused members of struct kse and struce ksegrp.
   As best as I can tell, some of these were never used.

Revision 1.68: download - view: text, markup, annotated - select for diffs
Tue Dec 7 18:17:24 2004 UTC (7 years, 2 months ago) by ups
Branches: MAIN
Diff to: previous 1.67: preferred, colored
Changes since revision 1.67: +3 -0 lines
Propagate TDF_NEEDRESCHED to replacement thread in sched_switch().

Reviewed by:    julian, jhb (in October)
Approved by:    sam (mentor)
MFC after:      4 weeks

Revision 1.49.2.12: download - view: text, markup, annotated - select for diffs
Sat Oct 9 05:25:21 2004 UTC (7 years, 4 months ago) by julian
Branches: RELENG_5
CVS tags: RELENG_5_3_BP, RELENG_5_3_0_RELEASE, RELENG_5_3
Diff to: previous 1.49.2.11: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.11: +28 -26 lines
MFC:
  When preempting a thread, put it back on the HEAD of its run queue.
  (Only really implemented in 4bsd)

  Revision  Changes    Path
  1.97      +8 -6      src/sys/kern/kern_switch.c
  1.67      +28 -26    src/sys/kern/sched_4bsd.c
  1.133     +14 -6     src/sys/kern/sched_ule.c
  1.408     +2 -0      src/sys/sys/proc.h
  1.5       +1 -1      src/sys/sys/runq.h

Approved by:	re (scottl)

Revision 1.49.2.11: download - view: text, markup, annotated - select for diffs
Sat Oct 9 04:47:37 2004 UTC (7 years, 4 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.10: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.10: +26 -4 lines
MFC:
  Use some macros to track available scheduler slots to allow
  easier debugging.

  Revision  Changes    Path
  1.96      +8 -3      src/sys/kern/kern_switch.c
  1.66      +26 -4     src/sys/kern/sched_4bsd.c
  1.131     +30 -16    src/sys/kern/sched_ule.c
  1.132     +2 -0      src/sys/kern/sched_ule.c

Approved by:	re (scottl)

Revision 1.67: download - view: text, markup, annotated - select for diffs
Tue Oct 5 22:03:10 2004 UTC (7 years, 4 months ago) by julian
Branches: MAIN
Diff to: previous 1.66: preferred, colored
Changes since revision 1.66: +28 -26 lines
When preempting a thread, put it back on the HEAD of its run queue.
(Only really implemented in 4bsd)

MFC after:	4 days

Revision 1.66: download - view: text, markup, annotated - select for diffs
Tue Oct 5 21:10:44 2004 UTC (7 years, 4 months ago) by julian
Branches: MAIN
Diff to: previous 1.65: preferred, colored
Changes since revision 1.65: +26 -4 lines
Use some macros to trach available scheduler slots to allow
easier debugging.

MFC after:	4 days

Revision 1.49.2.10: download - view: text, markup, annotated - select for diffs
Sat Sep 18 04:11:35 2004 UTC (7 years, 4 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.9: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.9: +61 -2 lines
Cumulative MFC of patches applied to -current to get preemption
support to a non-instantly-crashing state.
Also includes some cosmetic changes to keep the diffs to a minimum and
an experimental option (followon) in sched_4bsd. (turned off but
included to keep diffs to a mimimum)

Approved by:	re (scottl)

Revision 1.65: download - view: text, markup, annotated - select for diffs
Thu Sep 16 07:12:59 2004 UTC (7 years, 4 months ago) by julian
Branches: MAIN
Diff to: previous 1.64: preferred, colored
Changes since revision 1.64: +13 -1 lines
clean up thread runq accounting a bit.

MFC after:	3 days

Revision 1.64: download - view: text, markup, annotated - select for diffs
Mon Sep 13 23:02:52 2004 UTC (7 years, 4 months ago) by julian
Branches: MAIN
Diff to: previous 1.63: preferred, colored
Changes since revision 1.63: +2 -0 lines
Add some kasserts

Revision 1.49.2.9: download - view: text, markup, annotated - select for diffs
Sat Sep 11 10:28:42 2004 UTC (7 years, 4 months ago) by scottl
Branches: RELENG_5
Diff to: previous 1.49.2.8: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.8: +1 -23 lines
MFC: Revert the previous round of scheduler changes as they cause instant
panics on boot.

Approved by: re (implicit)

Revision 1.63: download - view: text, markup, annotated - select for diffs
Sat Sep 11 10:07:22 2004 UTC (7 years, 4 months ago) by scottl
Branches: MAIN
Diff to: previous 1.62: preferred, colored
Changes since revision 1.62: +1 -23 lines
Revert the previous round of changes to td_pinned.  The scheduler isn't
fully initialed when the pmap layer tries to call sched_pini() early in the
boot and results in an quick panic.  Use ke_pinned instead as was originally
done with Tor's patch.

Approved by: julian

Revision 1.49.2.8: download - view: text, markup, annotated - select for diffs
Sat Sep 11 01:09:32 2004 UTC (7 years, 5 months ago) by scottl
Branches: RELENG_5
Diff to: previous 1.49.2.7: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.7: +22 -1 lines
MFC the fix for PR 71509.  This might not be the final fix, but it's good
enough for warrant wider testing.

Submitted by: tegge, julian
Approved by: re

Revision 1.62: download - view: text, markup, annotated - select for diffs
Fri Sep 10 22:28:32 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.61: preferred, colored
Changes since revision 1.61: +22 -2 lines
Make up my mind if cpu pinning is stored in the thread structure or the
scheduler specific extension to it. Put it in the extension as
the implimentation details of how the pinning is done needn't be visible
outside the scheduler.

Submitted by:	tegge  (of course!)   (with changes)
MFC after:	3 days

Revision 1.61: download - view: text, markup, annotated - select for diffs
Fri Sep 10 21:04:38 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.60: preferred, colored
Changes since revision 1.60: +47 -1 lines
Add some code to allow threads to nominat a sibling to run if theyu are going to sleep.

MFC after:	1 week

Revision 1.49.2.7: download - view: text, markup, annotated - select for diffs
Thu Sep 9 10:15:53 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.6: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.6: +3 -2 lines
MFC of:
  Don't do IPIs on behalf of interrupt threads.
  just punt straight on through to the preemption code.
  Make a KASSSERT out of a condition that can no longer occur.

Approved by: re (scottl)

Revision 1.49.2.6: download - view: text, markup, annotated - select for diffs
Thu Sep 9 10:10:37 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.5: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.5: +2 -2 lines
MFC:   slight code cleanup

Approved by: re (scottl)

Revision 1.49.2.5: download - view: text, markup, annotated - select for diffs
Thu Sep 9 10:08:50 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.4: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.4: +2 -2 lines
MFC:  turn on IPIs for 4bsd scheduler by default.

Approved by: re (scottl)

Revision 1.49.2.4: download - view: text, markup, annotated - select for diffs
Thu Sep 9 10:03:20 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.3: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.3: +116 -63 lines
MFC of:
  Refactor a bunch of scheduler code to give basically the same behaviour
  but with slightly cleaned up interfaces.
(2004-09-05 02:09:54 UTC)
  see version 1.16 of sched.h for the original commit message.

Approved by: re (scottl)

Revision 1.49.2.3: download - view: text, markup, annotated - select for diffs
Thu Sep 9 09:56:58 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.2: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.2: +192 -18 lines
MFC of:
   Give the 4bsd scheduler the ability to wake up idle processors
   when there is new work to be done.
   ( 2004-09-01 06:42:02 UTC)

Approved by: re (scottl)

Revision 1.49.2.2: download - view: text, markup, annotated - select for diffs
Thu Sep 9 09:45:26 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49.2.1: preferred, colored; branchpoint 1.49: preferred, colored
Changes since revision 1.49.2.1: +10 -5 lines
MFC of:
   Give setrunqueue() and sched_add() more of a clue as to
   where they are coming from and what is expected from them.
   (  2004-09-01 02:11:28 UTC )

Approved by:    re (scottl)

Revision 1.60: download - view: text, markup, annotated - select for diffs
Mon Sep 6 07:23:14 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.59: preferred, colored
Changes since revision 1.59: +3 -2 lines
Don't do IPIs on behalf of interrupt threads.
just punt straight on through to teh preemption code.

Make a KASSSERT out of a condition that can no longer occur.
MFC after:	1 week

Revision 1.59: download - view: text, markup, annotated - select for diffs
Sun Sep 5 23:23:58 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.58: preferred, colored
Changes since revision 1.58: +2 -2 lines
slight code cleanup

MFC after:	1 week

Revision 1.58: download - view: text, markup, annotated - select for diffs
Sun Sep 5 02:19:53 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.57: preferred, colored
Changes since revision 1.57: +2 -2 lines
turn on IPIs for 4bsd scheduler by default.

MFC after:	1 week

Revision 1.57: download - view: text, markup, annotated - select for diffs
Sun Sep 5 02:09:53 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.56: preferred, colored
Changes since revision 1.56: +116 -63 lines
Refactor a bunch of scheduler code to give basically the same behaviour
but with slightly cleaned up interfaces.

The KSE structure has become the same as the "per thread scheduler
private data" structure. In order to not make the diffs too great
one is #defined as the other at this time.

The KSE (or td_sched) structure is  now allocated per thread and has no
allocation code of its own.

Concurrency for a KSEGRP is now kept track of via a simple pair of counters
rather than using KSE structures as tokens.

Since the KSE structure is different in each scheduler, kern_switch.c
is now included at the end of each scheduler. Nothing outside the
scheduler knows the contents of the KSE (aka td_sched) structure.

The fields in the ksegrp structure that are to do with the scheduler's
queueing mechanisms are now moved to the kg_sched structure.
(per ksegrp scheduler private data structure). In other words how the
scheduler queues and keeps track of threads is no-one's business except
the scheduler's. This should allow people to write experimental
schedulers with completely different internal structuring.

A scheduler call sched_set_concurrency(kg, N) has been added that
notifies teh scheduler that no more than N threads from that ksegrp
should be allowed to be on concurrently scheduled. This is also
used to enforce 'fainess' at this time so that a ksegrp with
10000 threads can not swamp a the run queue and force out a process
with 1 thread, since the current code will not set the concurrency above
NCPU, and both schedulers will not allow more than that many
onto the system run queue at a time. Each scheduler should eventualy develop
their own methods to do this now that they are effectively separated.

Rejig libthr's kernel interface to follow the same code paths as
linkse for scope system threads. This has slightly hurt libthr's performance
but I will work to recover as much of it as I can.

Thread exit code has been cleaned up greatly.
exit and exec code now transitions a process back to
'standard non-threaded mode' before taking the next step.
Reviewed by:	scottl, peter
MFC after:	1 week

Revision 1.56: download - view: text, markup, annotated - select for diffs
Fri Sep 3 09:19:49 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.55: preferred, colored
Changes since revision 1.55: +2 -0 lines
Don't declare a function we are not defining.

Revision 1.55: download - view: text, markup, annotated - select for diffs
Fri Sep 3 09:15:10 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.54: preferred, colored
Changes since revision 1.54: +4 -0 lines
fix compile for UP

Revision 1.54: download - view: text, markup, annotated - select for diffs
Fri Sep 3 08:19:31 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.53: preferred, colored
Changes since revision 1.53: +1 -0 lines
ooops finish last commit.
moved the variables but not the declarations.

Revision 1.53: download - view: text, markup, annotated - select for diffs
Fri Sep 3 07:42:31 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.52: preferred, colored
Changes since revision 1.52: +126 -0 lines
Move 4bsd specific experimental IP code into the 4bsd file.
Move the sysctls into kern.sched

Revision 1.49.2.1: download - view: text, markup, annotated - select for diffs
Fri Sep 3 05:49:05 2004 UTC (7 years, 5 months ago) by julian
Branches: RELENG_5
Diff to: previous 1.49: preferred, colored
Changes since revision 1.49: +9 -8 lines
MFC 1.50 Use some macros to reduce diff to upcoming commits

Approved by:	re (scottl)

Revision 1.52: download - view: text, markup, annotated - select for diffs
Wed Sep 1 06:42:01 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.51: preferred, colored
Changes since revision 1.51: +59 -18 lines
Give the 4bsd scheduler the ability to wake up idle processors
when there is new work to be done.

MFC after:	5 days

Revision 1.51: download - view: text, markup, annotated - select for diffs
Wed Sep 1 02:11:27 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.50: preferred, colored
Changes since revision 1.50: +10 -5 lines
Give setrunqueue() and sched_add() more of a clue as to
where they are coming from and what is expected from them.

MFC after:	2 days

Revision 1.50: download - view: text, markup, annotated - select for diffs
Sun Aug 22 05:21:41 2004 UTC (7 years, 5 months ago) by julian
Branches: MAIN
Diff to: previous 1.49: preferred, colored
Changes since revision 1.49: +9 -8 lines
diff reduction for upcoming patch. Use a macro that masks
some of the odd goings on with sub-structures, because they will
go away anyhow.

Revision 1.49: download - view: text, markup, annotated - select for diffs
Wed Aug 11 20:54:48 2004 UTC (7 years, 6 months ago) by julian
Branches: MAIN
CVS tags: RELENG_5_BP
Branch point for: RELENG_5
Diff to: previous 1.48: preferred, colored
Changes since revision 1.48: +3 -2 lines
Properly keep track of how many kses are on the system run queue(s).

Revision 1.48: download - view: text, markup, annotated - select for diffs
Mon Aug 9 18:21:12 2004 UTC (7 years, 6 months ago) by julian
Branches: MAIN
Diff to: previous 1.47: preferred, colored
Changes since revision 1.47: +5 -6 lines
Increase the amount of data exported by KTR in the KTR_RUNQ setting.
This extra data is needed to really follow what is going on in the
threaded case.

Revision 1.47: download - view: text, markup, annotated - select for diffs
Fri Jul 23 23:09:00 2004 UTC (7 years, 6 months ago) by scottl
Branches: MAIN
Diff to: previous 1.46: preferred, colored
Changes since revision 1.46: +6 -8 lines
Clean up whitespace, increase consistency and correctness.

Submitted by: bde

Revision 1.46: download - view: text, markup, annotated - select for diffs
Sun Jul 18 23:36:12 2004 UTC (7 years, 6 months ago) by julian
Branches: MAIN
Diff to: previous 1.45: preferred, colored
Changes since revision 1.45: +14 -14 lines
When calling scheduler entrypoints for creating new threads and processes,
specify "us" as the thread not the process/ksegrp/kse.
You can always find the others from the thread but the converse is not true.
Theorotically this would lead to runtime being allocated to the wrong
entity in some cases though it is not clear how often this actually happenned.
(would only affect threaded processes and would probably be pretty benign,
but it WAS a bug..)

Reviewed by: peter

Revision 1.45: download - view: text, markup, annotated - select for diffs
Fri Jul 16 21:04:55 2004 UTC (7 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.44: preferred, colored
Changes since revision 1.44: +2 -1 lines
- Move TDF_OWEPREEMPT, TDF_OWEUPC, and TDF_USTATCLOCK over to td_pflags
  since they are only accessed by curthread and thus do not need any
  locking.
- Move pr_addr and pr_ticks out of struct uprof (which is per-process)
  and directly into struct thread as td_profil_addr and td_profil_ticks
  as these variables are really per-thread.  (They are used to defer an
  addupc_intr() that was too "hard" until ast()).

Revision 1.44: download - view: text, markup, annotated - select for diffs
Tue Jul 13 20:49:13 2004 UTC (7 years, 6 months ago) by jhb
Branches: MAIN
Diff to: previous 1.43: preferred, colored
Changes since revision 1.43: +1 -1 lines
Set TDF_NEEDRESCHED when a higher priority thread is scheduled in
sched_add() rather than just doing it in sched_wakeup().  The old
ithread preemption code used to set NEEDRESCHED unconditionally if it
didn't preempt which masked this bug in SCHED_4BSD.

Noticed by:	jake
Reported by:	kensmith, marcel

Revision 1.43: download - view: text, markup, annotated - select for diffs
Fri Jul 2 20:21:43 2004 UTC (7 years, 7 months ago) by jhb
Branches: MAIN
Diff to: previous 1.42: preferred, colored
Changes since revision 1.42: +11 -1 lines
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)

Revision 1.42: download - view: text, markup, annotated - select for diffs
Fri Jul 2 19:09:49 2004 UTC (7 years, 7 months ago) by jhb
Branches: MAIN
Diff to: previous 1.41: preferred, colored
Changes since revision 1.41: +11 -6 lines
- Change mi_switch() and sched_switch() to accept an optional thread to
  switch to.  If a non-NULL thread pointer is passed in, then the CPU will
  switch to that thread directly rather than calling choosethread() to pick
  a thread to choose to.
- Make sched_switch() aware of idle threads and know to do
  TD_SET_CAN_RUN() instead of sticking them on the run queue rather than
  requiring all callers of mi_switch() to know to do this if they can be
  called from an idlethread.
- Move constants for arguments to mi_switch() and thread_single() out of
  the middle of the function prototypes and up above into their own
  section.

Revision 1.41: download - view: text, markup, annotated - select for diffs
Mon Jun 21 23:47:47 2004 UTC (7 years, 7 months ago) by scottl
Branches: MAIN
Diff to: previous 1.40: preferred, colored
Changes since revision 1.40: +1 -1 lines
Fix another typo in the previous commit.

Revision 1.40: download - view: text, markup, annotated - select for diffs
Mon Jun 21 22:42:46 2004 UTC (7 years, 7 months ago) by scottl
Branches: MAIN
Diff to: previous 1.39: preferred, colored
Changes since revision 1.39: +1 -1 lines
Fix typo that somehow crept into the previous commit

Revision 1.39: download - view: text, markup, annotated - select for diffs
Mon Jun 21 22:05:46 2004 UTC (7 years, 7 months ago) by scottl
Branches: MAIN
Diff to: previous 1.38: preferred, colored
Changes since revision 1.38: +8 -1 lines
Add the sysctl node 'kern.sched.name' that has the name of the scheduler
currently in use.  Move the 4bsd kern.quantum node to kern.sched.quantum
for consistency.

Revision 1.38: download - view: text, markup, annotated - select for diffs
Wed Jun 16 00:26:29 2004 UTC (7 years, 7 months ago) by julian
Branches: MAIN
Diff to: previous 1.37: preferred, colored
Changes since revision 1.37: +8 -5 lines
Nice, is a property of a process as a whole..
I mistakenly moved it to the ksegroup when breaking up the process
structure. Put it back in the proc structure.

Revision 1.37: download - view: text, markup, annotated - select for diffs
Mon Apr 5 21:03:35 2004 UTC (7 years, 10 months ago) by imp
Branches: MAIN
Diff to: previous 1.36: preferred, colored
Changes since revision 1.36: +0 -4 lines
Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core

Revision 1.36: download - view: text, markup, annotated - select for diffs
Mon Apr 5 15:06:01 2004 UTC (7 years, 10 months ago) by dfr
Branches: MAIN
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +1 -1 lines
Try not to crash instantly when signalling a libthr program to death.

Revision 1.35: download - view: text, markup, annotated - select for diffs
Fri Mar 5 19:27:04 2004 UTC (7 years, 11 months ago) by rwatson
Branches: MAIN
Diff to: previous 1.34: preferred, colored
Changes since revision 1.34: +1 -1 lines
The roundrobin callout from sched_4bsd is MPSAFE, so set up the
callout as MPSAFE to avoid grabbing Giant.

Reviewed by:	jhb

Revision 1.34: download - view: text, markup, annotated - select for diffs
Fri Feb 27 18:52:43 2004 UTC (7 years, 11 months ago) by jhb
Branches: MAIN
Diff to: previous 1.33: preferred, colored
Changes since revision 1.33: +2 -2 lines
Switch the sleep/wakeup and condition variable implementations to use the
sleep queue interface:
- Sleep queues attempt to merge some of the benefits of both sleep queues
  and condition variables.  Having sleep qeueus in a hash table avoids
  having to allocate a queue head for each wait channel.  Thus, struct cv
  has shrunk down to just a single char * pointer now.  However, the
  hash table does not hold threads directly, but queue heads.  This means
  that once you have located a queue in the hash bucket, you no longer have
  to walk the rest of the hash chain looking for threads.  Instead, you have
  a list of all the threads sleeping on that wait channel.
- Outside of the sleepq code and the sleep/cv code the kernel no longer
  differentiates between cv's and sleep/wakeup.  For example, calls to
  abortsleep() and cv_abort() are replaced with a call to sleepq_abort().
  Thus, the TDF_CVWAITQ flag is removed.  Also, calls to unsleep() and
  cv_waitq_remove() have been replaced with calls to sleepq_remove().
- The sched_sleep() function no longer accepts a priority argument as
  sleep's no longer inherently bump the priority.  Instead, this is soley
  a propery of msleep() which explicitly calls sched_prio() before
  blocking.
- The TDF_ONSLEEPQ flag has been dropped as it was never used.  The
  associated TDF_SET_ONSLEEPQ and TDF_CLR_ON_SLEEPQ macros have also been
  dropped and replaced with a single explicit clearing of td_wchan.
  TD_SET_ONSLEEPQ() would really have only made sense if it had taken
  the wait channel and message as arguments anyway.  Now that that only
  happens in one place, a macro would be overkill.

Revision 1.33: download - view: text, markup, annotated - select for diffs
Sun Feb 1 06:20:18 2004 UTC (8 years ago) by jeff
Branches: MAIN
Diff to: previous 1.32: preferred, colored
Changes since revision 1.32: +5 -13 lines
 - Disable ithread binding in all cases for now.  This doesn't make as much
   sense with sched_4bsd as it does with sched_ule.
 - Use P_NOLOAD instead of the absence of td->td_ithd to determine whether or
   not a thread should be accounted for in sched_tdcnt.

Revision 1.32: download - view: text, markup, annotated - select for diffs
Sun Feb 1 02:46:47 2004 UTC (8 years ago) by jeff
Branches: MAIN
Diff to: previous 1.31: preferred, colored
Changes since revision 1.31: +19 -2 lines
 - Keep a variable 'sched_tdcnt' that is used for the local implementation
   of sched_load().  This variable tracks the number of running and runnable
   non ithd threads.  This removes the need to traverse the proc table and
   discover how many threads are runnable.

Revision 1.31: download - view: text, markup, annotated - select for diffs
Sun Jan 25 08:21:46 2004 UTC (8 years ago) by jeff
Branches: MAIN
Diff to: previous 1.30: preferred, colored
Changes since revision 1.30: +11 -10 lines
 - Correct function names listed in KASSERTs.  These were copied from other
   code and it was sloppy of me not to adjust these sooner.

Revision 1.30: download - view: text, markup, annotated - select for diffs
Sun Jan 25 08:00:04 2004 UTC (8 years ago) by jeff
Branches: MAIN
Diff to: previous 1.29: preferred, colored
Changes since revision 1.29: +128 -12 lines
 - Implement cpu pinning and binding.  This is acomplished by keeping a per-
   cpu run queue that is only used for pinned or bound threads.

Submitted by:	Chris Bradfield <chrisb@ation.org>

Revision 1.29: download - view: text, markup, annotated - select for diffs
Fri Dec 26 17:07:29 2003 UTC (8 years, 1 month ago) by jhb
Branches: MAIN
Diff to: previous 1.28: preferred, colored
Changes since revision 1.28: +21 -6 lines
Create a separate kthread that executes sched_cpu() once a second.  Because
sched_cpu() locks an sx lock (allproc_lock) which can sleep if it fails to
acquire the lock, it is not safe to execute this in a callout handler from
softclock().

Revision 1.28: download - view: text, markup, annotated - select for diffs
Sun Nov 9 13:45:54 2003 UTC (8 years, 3 months ago) by bde
Branches: MAIN
CVS tags: RELENG_5_2_BP, RELENG_5_2_1_RELEASE, RELENG_5_2_0_RELEASE, RELENG_5_2
Diff to: previous 1.27: preferred, colored
Changes since revision 1.27: +4 -0 lines
Quick fix for scaling of statclock ticks in the SMP case.  As explained
in the log message for kern_sched.c 1.83 (which should have been
repo-copied to preserve history for this file), the (4BSD) scheduler
algorithm only works right if stathz is nearly 128 Hz.  The old
commit lock said 64 Hz; the scheduler actually wants nearly 16 Hz
but there was a scale factor of 4 to give the requirement of 64 Hz,
and rev.1.83 changed the scale factor so that the requirement became
128 Hz.  The change of the scale factor was incomplete in the SMP
case.  Then scheduling ticks are provided by smp_ncpu CPUs, and the
scheduler cannot tell the difference between this and 1 CPU providing
scheduling ticks smp_ncpu times faster, so we need another scale
factor of smp_ncp or an algorithm change.

This quick fix uses the scale factor without even trying to optimize
the runtime divisions required for this as is done for the other
scale factor.

The main algorithmic problem is the clamp on the scheduling tick counts.
This was 295; it is now approximately 295 * smp_ncpu.  When the limit
is reached, threads get free timeslices and scheduling becomes very
unfair to the threads that don't hit the limit.  The limit can be
reached and maintained in the worst case if the load average is larger
than (limit / effective_stathz - 1) / 2 = 0.65 now (was just 0.08 with
2 CPUs before this change), so there are algorithmic problems even for
a load average of 1.  Fortunately, the worst case isn't common enough
for the problem to be very noticeable (it is mainly for niced CPU hogs
competing with less nice CPU hogs).

Revision 1.27: download - view: text, markup, annotated - select for diffs
Sat Nov 8 03:03:17 2003 UTC (8 years, 3 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.26: preferred, colored
Changes since revision 1.26: +2 -0 lines
Return a reasonable number for top or ps to display for M:N thread,
since there is no direct association between M:N thread and kse,
sometimes, a thread does not have a kse, in that case, return a pctcpu
from its last kse, it is not perfect, but gives a good number to be
displayed.

Revision 1.26: download - view: text, markup, annotated - select for diffs
Wed Oct 29 14:40:41 2003 UTC (8 years, 3 months ago) by bde
Branches: MAIN
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +0 -3 lines
Removed sched_nest variable in sched_switch().  Context switches always
begin with sched_lock held but not recursed, so this variable was
always 0.

Removed fixup of sched_lock.mtx_recurse after context switches in
sched_switch().  Context switches always end with this variable in the
same state that it began in, so there is no need to fix it up.  Only
sched_lock.mtx_lock really needs a fixup.

Replaced fixup of sched_lock.mtx_recurse in fork_exit() by an assertion
that sched_lock is owned and not recursed after it is fixed up.  This
assertion much match the one in mi_switch(), and if sched_lock were
recursed then a non-null fixup of sched_lock.mtx_recurse would probably
be needed again, unlike in sched_switch(), since fork_exit() doesn't
return to its caller in the normal way.

Revision 1.25: download - view: text, markup, annotated - select for diffs
Thu Oct 16 21:13:14 2003 UTC (8 years, 3 months ago) by jeff
Branches: MAIN
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +7 -1 lines
 - The kse may be null in sched_pctcpu().

Reported by:	kris

Revision 1.24: download - view: text, markup, annotated - select for diffs
Thu Oct 16 08:53:46 2003 UTC (8 years, 3 months ago) by jeff
Branches: MAIN
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +10 -9 lines
 - Collapse sched_switchin() and sched_switchout() into sched_switch().  Now
   mi_switch() calls sched_switch() which calls cpu_switch().  This is
   actually one less function call than it had been.

Revision 1.23: download - view: text, markup, annotated - select for diffs
Thu Oct 16 08:39:15 2003 UTC (8 years, 3 months ago) by jeff
Branches: MAIN
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +14 -8 lines
 - Update the sched api.  sched_{add,rem,clock,pctcpu} now all accept a td
   argument rather than a kse.

Revision 1.22: download - view: text, markup, annotated - select for diffs
Tue Aug 19 17:51:09 2003 UTC (8 years, 5 months ago) by sam
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +1 -1 lines
Change instances of callout_init that specify MPSAFE behaviour to
use CALLOUT_MPSAFE instead of "1" for the second parameter.  This
does not change the behaviour; it just makes the intent more clear.

Revision 1.21: download - view: text, markup, annotated - select for diffs
Fri Aug 15 21:29:06 2003 UTC (8 years, 5 months ago) by jhb
Branches: MAIN
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +31 -26 lines
- Various style fixes in both code and comments.
- Update some stale comments.
- Sort a couple of includes.
- Only set 'newcpu' in updatepri() if we use it.
- No functional changes.

Obtained from:	bde (via an old diff I got a long time ago)

Revision 1.20: download - view: text, markup, annotated - select for diffs
Sun Jun 15 00:31:24 2003 UTC (8 years, 7 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +1 -1 lines
Rename P_THREADED to P_SA. P_SA means a process is using scheduler
activations.

Revision 1.19: download - view: text, markup, annotated - select for diffs
Wed Jun 11 00:56:57 2003 UTC (8 years, 8 months ago) by obrien
Branches: MAIN
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +3 -2 lines
Use __FBSDID().

Revision 1.18: download - view: text, markup, annotated - select for diffs
Wed Apr 30 12:57:39 2003 UTC (8 years, 9 months ago) by markm
Branches: MAIN
CVS tags: RELENG_5_1_BP, RELENG_5_1_0_RELEASE, RELENG_5_1
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +1 -1 lines
Fix some easy, global, lint warnings. In most cases, this means
making some local variables static. In a couple of cases, this means
removing an unused variable.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Wed Apr 23 18:51:05 2003 UTC (8 years, 9 months ago) by jhb
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +12 -0 lines
Add lock assertions for various proc/thread/kse/ksegroup fields to the
scheduler functions.

Revision 1.16: download - view: text, markup, annotated - select for diffs
Tue Apr 22 20:50:38 2003 UTC (8 years, 9 months ago) by jhb
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +3 -2 lines
- Assert that the proc lock and sched_lock are held in sched_nice().
- For the 4BSD scheduler, this means that all callers of the static
  function resetpriority() now always hold sched_lock, so don't lock
  sched_lock explicitly in that function.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Apr 11 03:39:48 2003 UTC (8 years, 10 months ago) by jeff
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +48 -15 lines
 - Catch up with sched api changes.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Thu Apr 10 17:35:44 2003 UTC (8 years, 10 months ago) by julian
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +3 -3 lines
Move the _oncpu entry from the KSE to the thread.
The entry in the KSE still exists but it's purpose will change a bit
when we add the ability to lock a KSE to a cpu.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Mar 24 15:16:21 2003 UTC (8 years, 10 months ago) by mux
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +1 -1 lines
Remove a trailing semicolon in SCHED_QUANTUM definition.
Luckily this didn't cause any bugs.

Spotted by:	Samy Al Bahra <samy@kerneled.com>

Revision 1.12: download - view: text, markup, annotated - select for diffs
Thu Feb 27 02:05:18 2003 UTC (8 years, 11 months ago) by julian
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +1 -1 lines
Change the process flags P_KSES to be P_THREADED.
This is just a cosmetic change but I've been meaning to do it for about a year.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Wed Feb 19 13:36:51 2003 UTC (8 years, 11 months ago) by davidxu
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +0 -1 lines
Update comments to reflect new KSE code.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Mon Feb 17 09:55:09 2003 UTC (8 years, 11 months ago) by julian
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +2 -2 lines
Move a bunch of flags from the KSE to the thread.
I was in two minds as to where to put them in the first case..
I should have listenned to the other mind.

Submitted by:	 parts by davidxu@
Reviewed by:	jeff@ mini@

Revision 1.9: download - view: text, markup, annotated - select for diffs
Mon Jan 13 03:42:41 2003 UTC (9 years ago) by jeff
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +5 -7 lines
 - Unbreak world.  I did not notice that libkvm was still used in some places
   to access the pctcpu.  This will have to be sorted out more later as the
   new scheduler requires a procedural interface for this data.  A more
   complete solution will follow.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Sun Jan 12 19:04:49 2003 UTC (9 years ago) by jeff
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +30 -15 lines
 - Move ke_pctcpu and ke_cpticks into the scheduler specific datastructure.
   This will prevent access through mechanisms other than the published
   interfaces.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sat Dec 28 01:23:07 2002 UTC (9 years, 1 month ago) by julian
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +1 -1 lines
Add code to ddb to allow backtracing an arbitrary thread.
(show thread {address})

Remove the IDLE kse state and replace it with a change in
the way threads sahre KSEs. Every KSE now has a thread, which is
considered its "owner" however a KSE may also be lent to other
threads in the same group to allow completion of in-kernel work.
n this case the owner remains the same and the KSE will revert to the
owner when the other work has been completed.

All creations of upcalls etc. is now done from
kse_reassign() which in turn is called from mi_switch or
thread_exit(). This means that special code can be removed from
msleep() and cv_wait().

kse_release() does not leave a KSE with no thread any more but
converts the existing thread into teh KSE's owner, and sets it up
for doing an upcall. It is just inhibitted from being scheduled until
there is some reason to do an upcall.

Remove all trace of the kse_idle queue since it is no-longer needed.
"Idle" KSEs are now on the loanable queue.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Thu Nov 21 09:30:55 2002 UTC (9 years, 2 months ago) by jeff
Branches: MAIN
CVS tags: RELENG_5_0_BP, RELENG_5_0_0_RELEASE, RELENG_5_0
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +6 -0 lines
 - Add the new sched_pctcpu() function to the sched_* api.
 - Provide a routine in sched_4bsd to add this functionality.
 - Use sched_pctcpu() in kern_proc, which is the one place outside of
   sched_4bsd where the old pctcpu value was accessed directly.

Approved by:	re

Revision 1.5: download - view: text, markup, annotated - select for diffs
Thu Nov 21 09:14:13 2002 UTC (9 years, 2 months ago) by jeff
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +10 -0 lines
 - Move scheduler specific macros and defines out of proc.h

Approved by:	re

Revision 1.4: download - view: text, markup, annotated - select for diffs
Thu Nov 21 08:57:08 2002 UTC (9 years, 2 months ago) by jeff
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +0 -5 lines
 - Move FSCALE back to kern_sync.  This is not scheduler specific.
 - Create a new callout for lbolt and move it out of schedcpu().  This is not
   scheduler specific either.

Approved by:	re

Revision 1.3: download - view: text, markup, annotated - select for diffs
Thu Nov 21 01:22:38 2002 UTC (9 years, 2 months ago) by jeff
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +25 -0 lines
 - Implement a mechanism for allowing schedulers to place scheduler dependant
   data in the scheduler independant structures (proc, ksegrp, kse, thread).
 - Implement unused stubs for this mechanism in sched_4bsd.

Approved by:	re
Reviewed by:	luigi, trb
Tested on:	x86, alpha

Revision 1.2: download - view: text, markup, annotated - select for diffs
Mon Oct 14 20:34:31 2002 UTC (9 years, 3 months ago) by julian
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +11 -26 lines
Tidy up the scheduler's code for changing the priority of a thread.
Logically pretty much a NOP.

Revision 1.1: download - view: text, markup, annotated - select for diffs
Sat Oct 12 05:32:23 2002 UTC (9 years, 4 months ago) by jeff
Branches: MAIN
 - Create a new scheduler api that is defined in sys/sched.h
 - Begin moving scheduler specific functionality into sched_4bsd.c
 - Replace direct manipulation of scheduler data with hooks provided by the
   new api.
 - Remove KSE specific state modifications and single runq assumptions from
   kern_switch.c

Reviewed by:	-arch

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options