Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/kern_clock.c
RevisionDateAuthorComments
 1.151  02-Sep-2023  riastradh heartbeat(9): Move #ifdef HEARTBEAT to sys/heartbeat.h.

Less error-prone this way, and the callers are less cluttered.
 1.150  07-Jul-2023  riastradh heartbeat(9): New mechanism to check progress of kernel.

This uses hard interrupts to check progress of low-priority soft
interrupts, and one CPU to check progress of another CPU.

If no progress has been made after a configurable number of seconds
(kern.heartbeat.max_period, default 15), then the system panics --
preferably on the CPU that is stuck so we get a stack trace in dmesg
of where it was stuck, but if the stuckness was detected by another
CPU and the stuck CPU doesn't acknowledge the request to panic within
one second, the detecting CPU panics instead.

This doesn't supplant hardware watchdog timers. It is possible for
hard interrupts to be stuck on all CPUs for some reason too; in that
case heartbeat(9) has no opportunity to complete.

Downside: heartbeat(9) relies on hardclock to run at a reasonably
consistent rate, which might cause trouble for the glorious tickless
future. However, it could be adapted to take a parameter for an
approximate number of units that have elapsed since the last call on
the current CPU, rather than treating that as a constant 1.

XXX kernel revbump -- changes struct cpu_info layout
 1.149  30-Jun-2023  riastradh entropy(9): Reintroduce netbsd<=9 time-delta estimator for unblocking.

The system will (in a subsequent change) by default block for this
condition before almost all of userland is running (including
/etc/rc.d/sshd key generation). That way, a never-blocking
getentropy(3) API will never return any data without at least
best-effort entropy like netbsd<=9 did to applications except in
single-user mode (where you have to be careful about everything
anyway) or in the few processes that run before a seed can even be
loaded (where blocking indefinitely, e.g. when generating a stack
protector cookie in libc, could pose a severe availability problem
that can't be configured away, but where the security impact is low).

However, (in another subsequent change) we will continue to use
_only_ HWRNG driver estimates and seed estimates, and _not_
time-delta estimator, for _warning_ about security in motd, daily
security report, etc. And if HWRNG/seed provides enough entropy
before time-delta estimator does, that will unblock /dev/random too.

The result is:

- Machines with HWRNG or seed won't warn about entropy and will
essentially never block -- even on first boot without a seed, it
will take only as long as the fastest HWRNG to unblock.

- Machines with neither HWRNG nor seed:
. will warn about entropy, giving feedback about security;
and
. will avoid returning anything more predictable than netbsd<=9;
but
. won't block (much) longer than netbsd<=9 would (and won't block
again after blocking once, except with kern.entropy.depletion=1 for
testing).

(The threshold for unblocking is now somewhat higher than before:
512 samples that pass the time-delta estimator, rather than 80 as
it used to be.)

And, of course, adding a seed (or HWRNG) will prevent both warnings
and blocking.

The mechanism is:

1. /dev/random will block until _either_

(a) enough bits of entropy (256) from reliable sources have been
added to the pool, _or_

(b) enough samples have been added from any sources (512), passing
the old time-delta entropy estimator, that the possible
security benefit doesn't justify holding up availability any
longer (`best effort'), except on systems with higher security
requirements like securelevel=2 which can disable non-HWRNG,
non-seed sources with rndctl_flags in rc.conf(5).

2. dmesg will report `entropy: ready' when 1(a) is satisfied, but if
1(b) is satisfied first, it will report `entropy: best effort', so
the concise log messages will reflect the timing and whether in
any period of time any of the system might be relying on best
effort entropy.

3. The sysctl knob kern.entropy.needed (and the ioctl RNDGETPOOLSTAT
variable rndpoolstat_t::added) still reflects the number of bits
of entropy from reliable sources, so we can still use this to
suggest regenerating ssh keys.

This matters on platforms that can only be reached, after flashing
an installation image, by sshing in over a (private) network, like
small network appliances or remote virtual machines without
(interactive) serial consoles. If we blocked indefinitely at boot
when generating ssh keys, such platforms would be unusable. This
way, platforms are usable, but operators can still be advised at
login time to regenerate keys as soon as they can actually load
entropy onto the system, e.g. with rndctl(8) on a seed file copied
from a local machine over the (private) network.

4. On machines without HWRNG, using a seed file still suppresses
warnings for users who need more confident security. But it is no
longer necessary for availability.

This is a compromise between availability and security:

- The security mechanism of blocking indefinitely on machines without
HWRNG hurts availability too much, as painful experience over the
multiple years since I made the mistake of introducing it have
shown. (Sorry!)

- The other main alternative, not having a blocking path at all (as I
pushed for, and as OpenBSD has done for a long time) could
potentially reduce security vs netbsd<=9, and would run against the
expectations set by many popular operating systems to the severe
detriment of public perception of NetBSD security.

Even though we can't _confidently_ assess enough entropy from, e.g.,
sampling interrupt timings, this is the traditional behaviour that
most operating systems provide -- and the result here is a net
nondecrease in security over netbsd<=9, because all paths from the
entropy pool to userland now have at least as high a standard before
returning data as they did in netbsd<=9.

PR kern/55641
PR pkg/55847
PR kern/57185
https://mail-index.netbsd.org/current-users/2020/09/02/msg039470.html
https://mail-index.netbsd.org/current-users/2020/11/21/msg039931.html
https://mail-index.netbsd.org/current-users/2020/12/05/msg040019.html

XXX pullup-10
 1.148  19-Mar-2022  riastradh branches: 1.148.4;
kern: Delete kernel_ticks from kernel ABI.

Use getticks() instead.
 1.147  18-Mar-2022  riastradh clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.

This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.
 1.146  14-Aug-2021  ryo fix rumpkernel build failure
 1.145  14-Aug-2021  ryo Improved the performance of kernel profiling on MULTIPROCESSOR, and possible to get profiling data for each CPU.

In the current implementation, locks are acquired at the entrance of the mcount
internal function, so the higher the number of cores, the more lock conflict
occurs, making profiling performance in a MULTIPROCESSOR environment unusable
and slow. Profiling buffers has been changed to be reserved for each CPU,
improving profiling performance in MP by several to several dozen times.

- Eliminated cpu_simple_lock in mcount internal function, using per-CPU buffers.
- Add ci_gmon member to struct cpu_info of each MP arch.
- Add kern.profiling.percpu node in sysctl tree.
- Add new -c <cpuid> option to kgmon(8) to specify the cpuid, like openbsd.
For compatibility, if the -c option is not specified, the entire system can be
operated as before, and the -p option will get the total profiling data for
all CPUs.
 1.144  16-Jan-2021  riastradh entropy: Sample cycle counter or timecounter in hardclock.

Only do so when we're short on entropy, in order to minimize
performance impact.

The sampling should stay close to the time of the actual hardclock
timer interrupt, so that the oscillator driving it determines when we
sample the cycle counter or timecounter, which we hope is driven by
an independent oscillator.

If we used a callout, there might be many other influences -- such as
spin lock delays possibly synchronized with this core's cycle counter
-- that could get between the timer interrupt and the sample.

In the glorious tickless future, this should instead be wired up to
the timer interrupt handler, however that manifests in the future
tickless API.
 1.143  05-Dec-2020  thorpej Refactor interval timers to make it possible to support types other than
the BSD/POSIX per-process timers:

- "struct ptimer" is split into "struct itimer" (common interval timer
data) and "struct ptimer" (per-process timer data, which contains a
"struct itimer").

- Introduce a new "struct itimer_ops" that supplies information about
the specific kind of interval timer, including it's processing
queue, the softint handle used to schedule processing, the function
to call when the timer fires (which adds it to the queue), and an
optional function to call when the CLOCK_REALTIME clock is changed by
a call to clock_settime() or settimeofday().

- Rename some fuctions to clearly identify what they're operating on
(ptimer vs itimer).

- Use kmem(9) to allocate ptimer-related structures, rather than having
dedicated pools for them.

Welcome to NetBSD 9.99.77.
 1.142  11-Oct-2020  thorpej branches: 1.142.2;
Call cpu_initclocks() before registering the default timecounter,
in case it updates hz. If hz changes, recalculate tick and tickadj.
 1.141  08-May-2020  ad Run Solaris cyclics from statclock() so dtrace isn't locked out by IPL_SCHED
(assuming the machine has a separate statclock() which almost all don't).
 1.140  02-Apr-2020  maxv Hide 'hardclock_ticks' behind a new getticks() function, and use relaxed
atomics internally. Only one caller is converted for now.

Discussed with riastradh@ and ad@.
 1.139  01-Dec-2019  ad Fix false sharing problems with cpu_info. Identified with tprof(8).
This was a very nice win in my tests on a 48 CPU box.

- Reorganise cpu_data slightly according to usage.
- Put cpu_onproc into struct cpu_info alongside ci_curlwp (now is ci_onproc).
- On x86, put some items in their own cache lines according to usage, like
the IPI bitmask and ci_want_resched.
 1.138  03-Sep-2018  riastradh C99 initializers for intr_timecounter.

No functional change.
 1.137  12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.136  04-Feb-2018  maxv branches: 1.136.2; 1.136.4;
Add a proper defflag for GPROF, and include opt_gprof.h, otherwise we're
not gonna go very far.
 1.135  12-Feb-2017  maxv Add a KASSERT, otherwise it looks like a NULL deref; from Mootja.
 1.134  22-Apr-2015  pooka branches: 1.134.2; 1.134.4;
opt_ntp.h is no longer used in kern_clock.c
 1.133  22-Apr-2015  pooka _KERNEL_OPT wrap
 1.132  22-Apr-2015  pooka move clock sysctls from init_sysctl.c to kern_clock.c
 1.131  02-Dec-2012  chs branches: 1.131.14;
adapt the cyclic module and profile dtrace provider to netbsd.
for now, just hook the cyclic callback into hardclock().
 1.130  30-Oct-2011  christos branches: 1.130.2; 1.130.12;
Back out previous; this should not be done in statclock but when the
allocations change or getrusage(). Plus the += seems wrong, we cannot
keep adding to the stats.
 1.129  29-Oct-2011  christos PR/45539: Greg A. Woods: add support for getrusage(2) memory size statistics
 1.128  27-Jul-2011  uebayasi These don't need uvm/uvm_extern.h.
 1.127  20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.126  05-Oct-2008  pooka branches: 1.126.16; 1.126.20;
hardclock() itself doesn't schedule callout softintrs any more,
so update comment - less is more.
 1.125  02-Jul-2008  rmind branches: 1.125.2;
Remove locking of p_stmutex from sched_pstats(), protect l_pctcpu with p_lock,
and make l_cpticks lock-less. Should fix PR/38296.

Reviewed (slightly different version) by <ad>.
 1.124  01-Jun-2008  ad branches: 1.124.2;
Make trap counters per-cpu, like syscalls.
 1.123  19-May-2008  ad Reduce ifdefs due to MULTIPROCESSOR slightly.
 1.122  28-Apr-2008  martin branches: 1.122.2;
Remove clause 3 and 4 from TNF licenses
 1.121  22-Apr-2008  ad branches: 1.121.2;
Implement MP callouts as discussed on tech-kern. The CPU binding code is
disabled for the moment until we figure out what we want to do with CPUs
being offlined.
 1.120  21-Apr-2008  ad timer fixes for PR 37093:

- Fix serious concurrency problems, making the code MT and MP safe in
the process.
- Don't allocate memory or inspect process state from hardclock().
 1.119  11-Mar-2008  ad branches: 1.119.2;
Add casts to avoid potential compiler warnings.
 1.118  11-Mar-2008  ad Make context switch + syscall counters optionally per-CPU and accumulate
in schedclock() at "about 16 hz".
 1.117  20-Jan-2008  joerg branches: 1.117.2; 1.117.6;
Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.116  07-Jan-2008  simonb Actually return the computed uptime in microuptime(). Fixes many
wierd timing issues on non-timecounter ports (tested on sbmips, and
omap ARM by Marty Fouts).

Also move the microtime() inside the splclock() block in the same
function - it may be possible for the "time" variable to be updated
after the call to microtime() but before we use it to calculate the
offset from mono_time.
 1.115  22-Dec-2007  yamt provide binuptime etc for !__HAVE_TIMECOUNTER.
 1.114  06-Nov-2007  ad branches: 1.114.2; 1.114.6;
Merge scheduler changes from the vmlocking branch. All discussed on
tech-kern:

- Invert priority space so that zero is the lowest priority. Rearrange
number and type of priority levels into bands. Add new bands like
'kernel real time'.
- Ignore the priority level passed to tsleep. Compute priority for
sleep dynamically.
- For SCHED_4BSD, make priority adjustment per-LWP, not per-process.
 1.113  04-Oct-2007  ad branches: 1.113.2; 1.113.4;
G/C the HIGHBALL stuff.
 1.112  03-Oct-2007  ad Make kaputt code compile.
 1.111  03-Oct-2007  ad Fix a dodgy bit of code in the PERFCTRS case.
 1.110  09-Aug-2007  pooka branches: 1.110.2; 1.110.4;
Shuffle routines which just roll values around from kern_clock.c
and kern_time.c to subr_time.c.
 1.109  09-Jul-2007  ad branches: 1.109.2; 1.109.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.108  17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.107  13-May-2007  dsl Instead of the #define versions of tc_getfrequency() and nanouptime(), use
the function ones in kern_kern_clock.c (adding tc_getfrequency).
Adjust includes so this builds.
 1.106  16-Feb-2007  ad branches: 1.106.2; 1.106.6; 1.106.8;
Remove spllowersoftclock() and CLKF_BASEPRI(), and always dispatch callouts
via a soft interrupt. In the near future, softclock will be run from process
context.
 1.105  09-Feb-2007  ad Merge newlock2 to head.
 1.104  01-Nov-2006  yamt remove some __unused from function parameters.
 1.103  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.102  02-Sep-2006  christos branches: 1.102.2; 1.102.4;
Add missing initializers
 1.101  09-Jun-2006  kardel re-order initialization sequence to have real counters available during autoconfig
 1.100  08-Jun-2006  drochner make the public declaration of "hardclock_ticks" signed again; other
code (kernel timeout/callout) does comparisions with it
 1.99  07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.98  15-Apr-2006  christos branches: 1.98.2;
Make this compile again.
 1.97  15-Apr-2006  elad Coverity CID 1050, 1051: Correct NULL guards.
 1.96  11-Dec-2005  christos branches: 1.96.4; 1.96.6; 1.96.8; 1.96.10; 1.96.12;
merge ktrace-lwp.
 1.95  12-Sep-2005  christos Introduced nanotime() which is going to be used by some fs code yet to
be committed. This should really be an MD routine and microtime should
be implemented from it, not the opposite (which is what we have now).
 1.94  02-Mar-2005  mycroft branches: 1.94.4;
Copyright maintenance.
 1.93  26-Feb-2005  perry nuke trailing whitespace
 1.92  15-Sep-2004  tls branches: 1.92.4; 1.92.6;
Add 50Hz support -- this will allow 'options NTP' to work on the Xen port,
once the Xen port's timer interrupts are made somewhat more sane (it "works"
now, but keeps worse time than without the option, ouch)
 1.91  01-Jul-2004  yamt statclock: don't assume hz==100 when determining frequency to call schedclock.
 1.90  13-Feb-2004  wiz branches: 1.90.2;
Uppercase CPU, plural is CPUs.
 1.89  23-Jan-2004  simonb Fix NTP PPSAPI support (enabled with "options PPS_SYNC"):

From PR kern/13702 from Charles Carvalho. Tested on alpha and
i386 with a Laipac TF10 PPS-capable GPS. The com.c change was
copied wholesale from Charles' z8530tty.c patch.
 1.88  04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.87  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.86  23-Jun-2003  martin branches: 1.86.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.85  12-Jun-2003  drochner nuke unnecessary #include <sys/dkstat.h>
 1.84  04-Feb-2003  thorpej New callout implementation. This is based on callwheel implementation
done by Artur Grabowski and Thomas Nordin for OpenBSD, which is more
efficient in several ways than the callwheel implementation that it is
replacing. It has been adapted to our pre-existing callout API, and
also provides the slightly more efficient (and much more intuitive)
API (adapted to the callout_*() naming scheme) that the OpenBSD version
provides.

Among other things, this shaves a bunch of cycles off rescheduling-in-
the-future a callout which is already scheduled, which the common case
for TCP timers (notably REXMT and KEEP).

The API has been simplified a bit, as well. The (very confusing to
a good many people) "ACTIVE" state for callouts has gone away. There
is now only "PENDING" (scheduled to fire in the future) and "EXPIRED"
(has fired, and the function called).

Kernel version bump not done; we'll ride the 1.6N bump that happened
with the malloc(9) change.
 1.83  27-Jan-2003  pk There's a locking order issue with the scheduler and the callwheel locks
as ltsleep() may call callout_reset() with the scheduler lock held.
So, prevent interrupts that may take the scheduler lock while holding
the callwheel lock.
 1.82  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.81  02-Nov-2002  perry /*CONTCOND*/ while (0)'ed macros
 1.80  07-Aug-2002  briggs Implement pmc(9) -- An interface to hardware performance monitoring
counters. These counters do not exist on all CPUs, but where they
do exist, can be used for counting events such as dcache misses that
would otherwise be difficult or impossible to instrument by code
inspection or hardware simulation.

pmc(9) is meant to be a general interface. Initially, the Intel XScale
counters are the only ones supported.
 1.79  17-Mar-2002  simonb branches: 1.79.4; 1.79.6;
We don't need to include <uvm/uvm_extern.h> before <sys/sysctl.h> anymore.
 1.78  12-Nov-2001  lukem add RCSIDs
 1.77  13-Sep-2001  enami branches: 1.77.2;
Defopt CALLWHEEL_STATS.
 1.76  11-Sep-2001  thorpej Optimization suggested by Bill Sommerfeld: Keep a hint as to the
"earliest" firing callout in a bucket. This allows us to skip
the scan up the bucket if no callouts are due in the bucket.

A cheap O(1) hint update is done at callout insertion (if new callout
is earlier than hint) and removal (is bucket empty). A thorough
refresh of the hint is done when the bucket is traversed.

This doesn't matter much on machines with small values of hz
(e.g. i386), but on systems with large values of hz (e.g. Alpha),
it has a definite positive effect.

Also, keep the callwheel stats in evcnts, so that you can view them
with "vmstat -e".
 1.75  06-May-2001  simonb branches: 1.75.2; 1.75.4;
Declare schedhz.
 1.74  17-Jan-2001  thorpej branches: 1.74.2;
Explicitly include <machine/intr.h> if __HAVE_GENERIC_SOFT_INTERRUPTS.
 1.73  15-Jan-2001  thorpej Make softclock a generic soft interrupt of the API is available,
adding the requisite void * argument to softclock().
 1.72  10-Dec-2000  mycroft Introduce PROC_PC(), which is used to get a process's user PC. If this is
defined, call addupc_intr() directly from statclock() in the system time case,
using the same P_OWEUPC path if the copyin/copyout fails.
Use this in i386 to remove profiling code from the normal userret() path.
 1.71  26-Aug-2000  sommerfeld On second thought.. pass cpu_info * to roundrobin() explicitly.
 1.70  26-Aug-2000  sommerfeld More MP clock/scheduler changes:
- Periodically invoke roundrobin() from hardclock() on all cpu's rather
than from a timer callout; this allows time-slicing on non-primary cpu's.
- Make pscnt per-cpu.
- Notice psdiv changes on each cpu, and adjust pscnt at that point.
Also, invoke setstatclockrate() from the clock interrupt when each cpu
notices the divisor change, rather than when starting/stopping the
profiling clock.
 1.69  22-Aug-2000  thorpej Define the MI parts of the "big kernel lock" perimeter. From
Bill Sommerfeld.
 1.68  22-Aug-2000  eeh Should use an `intrptr_t' for address calculations rather than `int'.
 1.67  22-Aug-2000  thorpej Fix a locking glitch in callwheel_slock handling. Noted by Bill Sommerfeld.
 1.66  21-Aug-2000  thorpej Protect hardclock_ticks and softclock_ticks with the callwheel
lock to prevent a race between hardclock() and callout_reset().
 1.65  21-Aug-2000  thorpej spllowersoftclock() is already void; no need to cast it.
 1.64  21-Aug-2000  thorpej Add a lock for the callwheel (callout facility), and only go to
splclock() while holding it.
 1.63  01-Aug-2000  thorpej ANSI'ify.
 1.62  13-Jul-2000  thorpej New hzto() function from FreeBSD and Artur Grabowski <art@stacken.kth.se>.
Stops sleeps from returning early (by up to a clock tick), and return 0
ticks for timeouts that should happen now or in the past.

Returning 0 is different from the legacy hzto() interface, and callers
need to check for it.
 1.61  27-Jun-2000  mrg remove include of <vm/vm.h>
 1.60  03-Jun-2000  thorpej branches: 1.60.2;
Move schedticks and cp_time into schedstate_percpu. Also, allow
non-primary CPUs to call hardclock(), but make them bail about
before updating global timekeeping state (that's the job of the
primary CPU).
 1.59  02-Jun-2000  simonb Add new sysctl node "KERN_SYSVIPC_INFO" with "KERN_SYSVIPC_MSG_INFO",
"KERN_SYSVIPC_SEM_INFO" and "KERN_SYSVIPC_SHM_INFO" to return the
info and data structures for the relevent SysV IPC types. The return
structures use fixed-size types and should be compat32 safe. All
user-visible changes are protected with
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

Make all variable declarations extern in msg.h, sem.h and shm.h and
add relevent variable declarations to sysv_*.c and remove unneeded
header files from those .c files.

Make compat14 SysV IPC conversion functions and sysctl_file() static.

Change the data pointer to "void *" in sysctl_clockrate(),
sysctl_ntptime(), sysctl_file() and sysctl_doeproc().
 1.58  29-May-2000  mycroft Use a better multiplier for the 60Hz case.
 1.57  29-May-2000  mycroft Update an outdated comment.
Allow all powers of 2 from 2^0 to 2^16 for hz.
Enable hz==1200.
 1.56  29-May-2000  mycroft Improve the time_adj multiplier for the 100Hz and 1000Hz cases, and add a
1200Hz case.
 1.55  30-Mar-2000  augustss branches: 1.55.2;
Get rid of register declarations.
 1.54  24-Mar-2000  enami Call the routine to calculate callwheelsize from allocsys() instead of
main() since some port like alpha and mips calls allocsys() before main()
is called. While I'm here, I renamed some function.
 1.53  23-Mar-2000  thorpej Remove the CALLWHEEL_SORT code. It was implemented just for experimenting,
and I had no plans to ever enable it. A record of the code is now in the
CVS history of the file, so we can unclutter now.
 1.52  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.51  19-Jan-2000  thorpej Move callout initialization to a single location; no need to duplicate
that code all over the place.
 1.50  06-Sep-1999  sommerfeld branches: 1.50.2;
If using kernel PLL (for NTP), initialize "fixtick" to a reasonable
approximation of reality if the MD code doesn't. This variable is the
equivalent of "tickfix" for the non-NTP path.

This allows an alpha kernel (where hz=1024) with "options NTP" to
synch up quite nicely (as opposed to having an frequency error of
~560ppm, which is outside the capture range of the PLL).
 1.49  05-Aug-1999  thorpej Change the semantics of splsoftclock() to be like other spl*() functions,
that is priority is rasied. Add a new spllowersoftclock() to provide the
atomic drop-to-softclock semantics that the old splsoftclock() provided,
and update calls accordingly.

This fixes a problem with using the "rnd" pseudo-device from within
interrupt context to extract random data (e.g. from within the softnet
interrupt) where doing so would incorrectly unblock interrupts (causing
all sorts of lossage).

XXX 4 platforms do not have priority-raising capability: newsmips, sparc,
XXX sparc64, and VAX. This platforms still have this bug until their
XXX spl*() functions are fixed.
 1.48  04-May-1999  christos Align struct timeval time to the same alignment requirements of a quad.
This broke the sparc elf kernel which in microtime uses ldd to load both
words at the same time. The a.out kernel, just got lucky.
 1.47  28-Feb-1999  ross branches: 1.47.2; 1.47.4;
schedclk() -> schedclock(), for consistency with hardclock(), statclock(), ...
update comments for recent scheduler mods
 1.46  23-Feb-1999  mycroft While I'm on a fixed point kick, improve the NTP clock factor correction to
give <.1% error in all (supported) cases. It doesn't cost us much.
 1.45  23-Feb-1999  ross Scheduler bug fixes and reorganization
* fix the ancient nice(1) bug, where nice +20 processes incorrectly
steal 10 - 20% of the CPU, (or even more depending on load average)
* provide a new schedclk() mechanism at a new clock at schedhz, so high
platform hz values don't cause nice +0 processes to look like they are
niced
* change the algorithm slightly, and reorganize the code a lot
* fix percent-CPU calculation bugs, and eliminate some no-op code

=== nice bug === Correctly divide the scheduler queues between niced and
compute-bound processes. The current nice weight of two (sort of, see
`algorithm change' below) neatly divides the USRPRI queues in half; this
should have been used to clip p_estcpu, instead of UCHAR_MAX. Besides
being the wrong amount, clipping an unsigned char to UCHAR_MAX is a no-op,
and it was done after decay_cpu() which can only _reduce_ the value. It
has to be kept <= NICE_WEIGHT * PRIO_MAX - PPQ or processes can
scheduler-penalize themselves onto the same queue as nice +20 processes.
(Or even a higher one.)

=== New schedclk() mechansism === Some platforms should be cutting down
stathz before hitting the scheduler, since the scheduler algorithm only
works right in the vicinity of 64 Hz. Rather than prescale hz, then scale
back and forth by 4 every time p_estcpu is touched (each occurance an
abstraction violation), use p_estcpu without scaling and require schedhz
to be generated directly at the right frequency. Use a default stathz (well,
actually, profhz) / 4, so nothing changes unless a platform defines schedhz
and a new clock. Define these for alpha, where hz==1024, and nice was
totally broke.

=== Algorithm change === The nice value used to be added to the
exponentially-decayed scheduler history value p_estcpu, in _addition_ to
be incorporated directly (with greater wieght) into the priority calculation.
At first glance, it appears to be a pointless increase of 1/8 the nice
effect (pri = p_estcpu/4 + nice*2), but it's actually at least 3x that
because it will ramp up linearly but be decayed only exponentially, thus
converging to an additional .75 nice for a loadaverage of one. I killed
this, it makes the behavior hard to control, almost impossible to analyze,
and the effect (~~nothing at for the first second, then somewhat increased
niceness after three seconds or more, depending on load average) pointless.

=== Other bugs === hz -> profhz in the p_pctcpu = f(p_cpticks) calcuation.
Collect scheduler functionality. Try to put each abstraction in just one
place.
 1.44  22-Apr-1998  jonathan defopt NTP and PPS_SYNC, in preparation for adding PPS support.
 1.43  31-Jan-1998  ross Teach the NTP PLL how to lock when hz == 1000.
 1.42  21-May-1997  gwr Moved db_show_callout() to ddb/db_xxx.c
 1.41  05-May-1997  tls add case for 512Hz in NTP code
 1.40  28-Feb-1997  mycroft Use splclock() to block time updates, not splhigh().
 1.39  15-Jan-1997  cgd branches: 1.39.4;
apply patch from PR 2788 (from Dennis Ferguson <dennis@jnx.com>) to
more smoothly apply "tickfix"es microsecond deltas (when compensating
for clocks running at > 1000Hz).
 1.38  15-Jan-1997  cgd fix from PR 2787 (from Dennis Ferguson <dennis@jnx.com>): when adjtime
is running (and NTP is not enabled), the adjtime()-handling code clobbers
any tickfix that may be necessary for systems with clocks with frequency
greater than 1000Hz.
 1.37  15-Nov-1996  cgd branches: 1.37.2;
clean up a few spaces vs. tabs bogons
 1.36  24-Jul-1996  abrown Fix unused variable warning for an "int i" left over from the old disk
statistics code.
 1.35  12-Jul-1996  thorpej Remove old-style disk instrumentation code.
 1.34  09-Jun-1996  briggs Do not declare tickfixcnt ifdef NTP.
 1.33  22-Apr-1996  christos branches: 1.33.4;
remove include of <sys/cpu.h>
 1.32  30-Mar-1996  christos Fix db_printf formats.
 1.31  15-Mar-1996  mycroft Calculate the equivalent of `SHIFT_HZ' at run time, in initclocks().
 1.30  08-Mar-1996  mycroft Move an assignment inside #ifdef NTP.
 1.29  07-Mar-1996  christos - Make things compile cleanly after the NTP additions.
- Remove unused variables in exec_ecoff.c
 1.28  29-Feb-1996  jonathan Fix for PR kern/2140: a typo in the nested CPP if/else/endif caused
SHIFT_HZ to be undefined for values of HZ other than 64.
 1.27  27-Feb-1996  jonathan Add NTP kernel precision timekeeping from Dave Mill's xntp distribution
and the "kernel.tar.Z" distribution on louie.udel.edu, which is older than
xntp 3.4y or 3.5a, but contains newer kernel source fragments.

This commit adds support for a new kernel configuration option, NTP.
If NTP is selected, then the system clock should be run at "HZ", which
must be defined at compile time to be one value from:
60, 64, 100, 128, 256, 512, 1024.

Powers of 2 are ideal; 60 and 100 are supported but are marginally less
accurate.

If NTP is not configured, there should be no change in behavior relative
to pre-NTP kernels.

These changes have been tested extensively with xntpd 3.4y on a decstation;
almost identical kernel mods work on an i386. No pulse-per-second (PPS)
line discipline support is included, due to unavailability of hardware
to test it.

With this in-kernel PLL support for NetBSD, both xntp 3.4y and xntp
3.5a user-level code need minor changes. xntp's prototype for
syscall() is correct for FreeBSD, but not for NetBSD.
 1.26  09-Feb-1996  christos More proto fixes
 1.25  04-Feb-1996  christos First pass at prototyping
 1.24  17-Jan-1996  cgd fix off-by-one error in tickfix code. (should increment when count >=
interval, because count goes from 0->(interval-1) to count interval
ticks.)
 1.23  28-Dec-1995  thorpej Move the old-style disk instrumentation "structures" to a central location
(sys/kern/subr_disk.c) and note that they should/will be deperecated.
 1.22  03-Mar-1995  cgd add support for clocks with hz > 1000, and for cases where 1000000 / hz != int
 1.21  09-Oct-1994  mycroft Clean up #includes.
 1.20  18-Sep-1994  mycroft Add tickadj to clockinfo.
 1.19  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.18  07-May-1994  cgd clock info gathering
 1.17  05-May-1994  cgd lots of changes: prototype migration, move lots of variables, definitions,
and structure elements around. kill some unnecessary type and macro
definitions. standardize clock handling. More changes than you'd want.
 1.16  29-Apr-1994  cgd change timeout/untimeout/wakeup/sleep/tsleep args to void *
 1.15  27-Apr-1994  pk Routine to display callout table from DDB.
 1.14  07-Feb-1994  cgd kill support for 'dcfclk' ; shouldn't pollute tree for things not in NetBSD.
 1.13  01-Feb-1994  deraadt pass around a `clockframe *' instead of a `clockframe'
 1.12  11-Jan-1994  mycroft Remove the evil #ifndef; we no longer need it.
 1.11  18-Dec-1993  mycroft Canonicalize all #includes.
 1.10  29-Oct-1993  cgd kill the process 'space' accounting collection for the following reasons:
(1) text calculation incorrect (would 'overbill')
(2) data calculation incorrect (would 'overbill')
(3) the maxrss calculation uses stuff which isn't present
on the sparc.
if 3/4 tests are questionable and/or broken, well...
 1.9  19-Oct-1993  cgd from Mark Tinguely, with mods by davidg and then fially fixed by cgd.
do the space-used integration, over time, for processes.
 1.8  30-Aug-1993  deraadt branches: 1.8.2;
blast it, i forgot two ('s
 1.7  29-Aug-1993  deraadt added two __P() macros
 1.6  27-Jun-1993  andrew * ansifications
* cleaned up hardclock() to avoid checking "p" multiple times, and avoid a
gcc2 possible-use-before-initialisation warning.
* changed softclock() timeout callback functions to be of type timeout_t -
a pointer to a void fn(int). No-one was using the second, tick, argument
that was being passed to these callbacks - it is much cleaner to drop the
thing entirely, rather than add a whole heap of casts of dubious
correctness to calls to timeout(), etc. The old style is kept in an
#ifdef, for future reference.
 1.5  15-Jun-1993  cgd include the (stupid and ugly) patch for the i386 interrupt stuff.
it seems to help stability, when included.
 1.4  02-Jun-1993  cgd kill processes outright if they've exceeded their hard CPU limit.
 1.3  20-May-1993  cgd add $Id$ strings, and clean up file headers where necessary
 1.2  07-May-1993  cgd add dcfclock support from patchkit patch 113
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.11  05-Nov-1993  mycroft Forgot to garbage-collect some crap with the last change.
 1.8.2.10  05-Nov-1993  mycroft Merge changes from trunk.
 1.8.2.9  27-Oct-1993  mycroft Don't bother to check p->p_pstats; we always expect it to be non-NULL.
 1.8.2.8  26-Oct-1993  mycroft Merge changes from trunk.
 1.8.2.7  16-Oct-1993  mycroft #ifdef i386 kluge for softclock() shortcut can now die.
 1.8.2.6  15-Oct-1993  mycroft Nuke arg to softclock().
 1.8.2.5  29-Sep-1993  mycroft init_main.c: Remove calls to startrtclock(), startkgclock(), and enablertclock().
sys_process.c: Remove profil() (now in subr_prof.c).
vfs_bio.c: Merge changes from trunk.
kern_clock.c, tty_pty.c: Trivial changes to match KNF.
 1.8.2.4  28-Sep-1993  deraadt stathz & profhz belong here too.
 1.8.2.3  28-Sep-1993  deraadt define some things from sys/kernel.h
 1.8.2.2  24-Sep-1993  mycroft Make all files using spl*() #include cpu.h. Changes from trunk.
init_main.c: New method of pseudo-device of initialization.
kern_clock.c: hardclock() and softclock() now take a pointer to a clockframe.
softclock() only does callouts.
kern_synch.c: Remove spurious declaration of endtsleep(). Adjust uses of
averunnable for new struct loadav.
subr_prf.c: Allow printf() formats in panic().
tty.c: averunnable changes.
vfs_subr.c: va_size and va_bytes are now quads.
 1.8.2.1  14-Sep-1993  mycroft init_main.c: clock changes from 4.4; initclocks() is called after vfsinit().
No startrtclock() or enablertclock(). Some pseudo-device cruft, but this needs
to be updated.
kern_clock.c: from 4.4: gatherstats() --> statclock(). statclock(),
hardclock(), and softclock() take a `struct clockframe *'. New initclocks(),
harclock(), statclock(), startprofclock(), and stopprofclock().
kern_synch.c: from 4.4: machine-independent swtch(), which is now where
process time is integrated. Calls cpu_swtch() with the current process as an
arg.
subr_autoconf.c: Fix typo.
subr_prf.c: msgbufp and msgbufmapped are define in machdep.c
tty.c: Make TIOCHPCL #ifdef COMPAT_43.
Incorporate changes from main branch.
 1.33.4.1  11-Jun-1996  briggs Bring in changes to eradicate compile warning if NTP. With permission from jtc.
 1.37.2.1  18-Jan-1997  thorpej Update from trunk.
 1.39.4.1  12-Mar-1997  is Merge in changes from Trunk
 1.47.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.47.2.1  10-Oct-1999  cgd pull up rev 1.50 from trunk (requested by sommerfeld):
If using kernel NTP PLL, initialize "fixtick" to a reasonable
approximation of reality if machine-dependent code doesn't. This
allows a NetBSD/alpha kernel (where hz=1024) with "options NTP" to
synch up quite nicely (as opposed to having an frequency error of
~560ppm, which is outside the capture range of the PLL).
 1.50.2.4  11-Feb-2001  bouyer Sync with HEAD.
 1.50.2.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.50.2.2  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.50.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.55.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.60.2.1  13-Jul-2000  thorpej Pull up rev. 1.62:
New hzto() function from FreeBSD and Artur Grabowski <art@stacken.kth.se>.
Stops sleeps from returning early (by up to a clock tick), and return 0
ticks for timeouts that should happen now or in the past.

Returning 0 is different from the legacy hzto() interface, and callers
need to check for it.
 1.74.2.11  11-Nov-2002  nathanw Catch up to -current
 1.74.2.10  03-Oct-2002  nathanw Implement CLOCK_VIRTUAL and CLOCK_PROF support for POSIX timers. Factor
out some common code between POSIX timers and BSD timers along the way.
 1.74.2.9  13-Aug-2002  nathanw Catch up to -current.
 1.74.2.8  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.74.2.7  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.74.2.6  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.74.2.5  17-Nov-2001  nathanw Implement POSIX realtime timers, and reimplement getitimer() and setitimer()
in terms of them.
 1.74.2.4  14-Nov-2001  nathanw Catch up to -current.
 1.74.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.74.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.74.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.75.4.1  01-Oct-2001  fvdl Catch up with -current.
 1.75.2.4  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.75.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.75.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.75.2.1  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.77.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.79.6.1  22-Oct-2003  jmc Pullup via patch (requested by he in ticket #1530)


Introduce a new INVOKING status for callouts, and use it to close
a race condition in the TCP code. Fixes PR#20390.
 1.79.4.1  29-Aug-2002  gehenna catch up with -current.
 1.86.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.86.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.86.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.86.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.86.2.1  03-Aug-2004  skrll Sync with HEAD
 1.90.2.1  16-Sep-2004  jmc Pullup rev 1.92 (requested by tls in ticket #847)

Add 50Hz support -- this will allow 'options NTP' to work on the Xen port,
once the Xen port's timer interrupts are made somewhat more sane
 1.92.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.92.4.1  29-Apr-2005  kent sync with -current
 1.94.4.8  17-Mar-2008  yamt sync with head.
 1.94.4.7  21-Jan-2008  yamt sync with head
 1.94.4.6  15-Nov-2007  yamt sync with head.
 1.94.4.5  27-Oct-2007  yamt sync with head.
 1.94.4.4  03-Sep-2007  yamt sync with head.
 1.94.4.3  26-Feb-2007  yamt sync with head.
 1.94.4.2  30-Dec-2006  yamt sync with head.
 1.94.4.1  21-Jun-2006  yamt sync with head.
 1.96.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.96.10.1  19-Apr-2006  elad sync with head.
 1.96.8.3  03-Sep-2006  yamt sync with head.
 1.96.8.2  26-Jun-2006  yamt sync with head.
 1.96.8.1  24-May-2006  yamt sync with head.
 1.96.6.5  03-Jun-2006  kardel implement clock interrupt counter
 1.96.6.4  24-Apr-2006  kardel provide nanouptime compatibility
 1.96.6.3  22-Apr-2006  simonb Sync with head.
 1.96.6.2  28-Feb-2006  kardel increment hardclock_ticks always
 1.96.6.1  04-Feb-2006  simonb Adapt for timecounter changes.

Add FreeBSD's "tvtohz()" function to avoid the bogus "splfoo(), add
time, call hzto() which subtracts time" sequences, and add new tstohz()
function that does similar for timespecs.

Add compatibility routines so ports not yet converted to timecounters
can use the timecounter get*time() calls.
 1.96.4.1  09-Sep-2006  rpaulo sync with head
 1.98.2.1  19-Jun-2006  chap Sync with head.
 1.102.4.2  10-Dec-2006  yamt sync with head.
 1.102.4.1  22-Oct-2006  yamt sync with head
 1.102.2.7  05-Feb-2007  ad IPL_STATCLOCK needs to be >= IPL_CLOCK, so assume that proc::p_stmutex is
always a spinlock.
 1.102.2.6  16-Jan-2007  ad Fix locking botches.
 1.102.2.5  11-Jan-2007  ad Checkpoint work in progress.
 1.102.2.4  29-Dec-2006  ad Checkpoint work in progress.
 1.102.2.3  18-Nov-2006  ad Sync with head.
 1.102.2.2  17-Nov-2006  ad Checkpoint work in progress.
 1.102.2.1  21-Oct-2006  ad Update for addupc_intr() change.
 1.106.8.1  11-Jul-2007  mjf Sync with head.
 1.106.6.10  05-Nov-2007  ad Drive schedclock from hardclock, instead of from statclock.
 1.106.6.9  01-Nov-2007  ad - Fix interactivity problems under high load. Beacuse soft interrupts
are being stacked on top of regular LWPs, more often than not aston()
was being called on a soft interrupt thread instead of a user thread,
meaning that preemption was not happening on EOI.

- Don't use bool in a couple of data structures. Sub-word writes are not
always atomic and may clobber other fields in the containing word.

- For SCHED_4BSD, make p_estcpu per thread (l_estcpu). Rework how the
dynamic priority level is calculated - it's much better behaved now.

- Kill the l_usrpri/l_priority split now that priorities are no longer
directly assigned by tsleep(). There are three fields describing LWP
priority:

l_priority: Dynamic priority calculated by the scheduler.
This does not change for kernel/realtime threads,
and always stays within the correct band. Eg for
timeshared LWPs it never moves out of the user
priority range. This is basically what l_usrpri
was before.

l_inheritedprio: Lent to the LWP due to priority inheritance
(turnstiles).

l_kpriority: A boolean value set true the first time an LWP
sleeps within the kernel. This indicates that the LWP
should get a priority boost as compensation for blocking.
lwp_eprio() now does the equivalent of sched_kpri() if
the flag is set. The flag is cleared in userret().

- Keep track of scheduling class (OTHER, FIFO, RR) in struct lwp, and use
this to make decisions in a few places where we previously tested for a
kernel thread.

- Partially fix itimers and usr/sys/intr time accounting in the presence
of software interrupts.

- Use kthread_create() to create idle LWPs. Move priority definitions
from the various modules into sys/param.h.

- newlwp -> lwp_create
 1.106.6.8  18-Oct-2007  ad Update for soft interrupt changes. See kern_softint.c 1.1.2.17 for details.
 1.106.6.7  09-Oct-2007  ad Sync with head.
 1.106.6.6  09-Oct-2007  ad Sync with head.
 1.106.6.5  20-Aug-2007  ad Sync with HEAD.
 1.106.6.4  01-Jul-2007  ad - Adapt to callout API change.
- Add a counter to track how often soft interrupts sleep.
 1.106.6.3  17-Jun-2007  ad - Increase the number of thread priorities from 128 to 256. How the space
is set up is to be revisited.
- Implement soft interrupts as kernel threads. A generic implementation
is provided, with hooks for fast-path MD code that can run the interrupt
threads over the top of other threads executing in the kernel.
- Split vnode::v_flag into three fields, depending on how the flag is
locked (by the interlock, by the vnode lock, by the file system).
- Miscellaneous locking fixes and improvements.
 1.106.6.2  08-Jun-2007  ad Sync with head.
 1.106.6.1  21-Mar-2007  ad GC the simplelock/spinlock debugging stuff.
 1.106.2.7  17-May-2007  yamt sync with head.
 1.106.2.6  21-Apr-2007  ad Some changes mainly for top/ps:

- Add an optional name field to struct lwp.
- Count the total number of context switches + involuntary,
not voluntary + involuntary.
- Mark the idle threads as LSIDL when not running, otherwise
they show up funny in a top(1) that shows threads.
- Make pctcpu and cpticks per-LWP attributes.
- Add to kinfo_lwp: cpticks, pctcpu, pid, name.
 1.106.2.5  20-Mar-2007  yamt - revive schedclock and rename sched_clock to sched_schedclock.
(yes, a poor name...)
make schedclock check if curlwp is idle.
- statclock: in the case of schedhz==0, call schedclock periodically,
regardless of idleness.
- fix a comment. (don't assume schedhz==0.)
 1.106.2.4  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.106.2.3  23-Feb-2007  yamt remove an SCHED_4BSD #ifdef (schedclock). from Daniel Sieger.
discussed on tech-kern@.
 1.106.2.2  20-Feb-2007  rmind General Common Scheduler Framework (CSF) patch import. Huge thanks for
Daniel Sieger <dsieger at TechFak.Uni-Bielefeld de> for this work.

Short abstract: Split the dispatcher from the scheduler in order to
make the scheduler more modular. Introduce initial API for other
schedulers' implementations.

Discussed in tech-kern@
OK: yamt@, ad@

Note: further work will go soon.
 1.106.2.1  17-Feb-2007  yamt - separate context switching and thread scheduling.
- introduce idle lwp.
- change some related MD/MI interfaces and implement i386 version.
 1.109.6.3  06-Nov-2007  joerg Sync with HEAD.
 1.109.6.2  04-Oct-2007  joerg Sync with HEAD.
 1.109.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.109.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.110.4.1  06-Oct-2007  yamt sync with head.
 1.110.2.3  23-Mar-2008  matt sync with HEAD
 1.110.2.2  09-Jan-2008  matt sync with HEAD
 1.110.2.1  06-Nov-2007  matt sync with HEAD
 1.113.4.3  18-Feb-2008  mjf Sync with HEAD.
 1.113.4.2  27-Dec-2007  mjf Sync with HEAD.
 1.113.4.1  19-Nov-2007  mjf Sync with HEAD.
 1.113.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.114.6.3  23-Jan-2008  bouyer Sync with HEAD.
 1.114.6.2  08-Jan-2008  bouyer Sync with HEAD
 1.114.6.1  02-Jan-2008  bouyer Sync with HEAD
 1.114.2.1  26-Dec-2007  ad Sync with head.
 1.117.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.117.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.117.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.117.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.117.2.1  24-Mar-2008  keiichi sync with head.
 1.119.2.2  04-Jun-2008  yamt sync with head
 1.119.2.1  18-May-2008  yamt sync with head.
 1.121.2.2  04-May-2009  yamt sync with head.
 1.121.2.1  16-May-2008  yamt sync with head.
 1.122.2.3  10-Oct-2008  skrll Sync with HEAD.
 1.122.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.122.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.124.2.1  03-Jul-2008  simonb Sync with head.
 1.125.2.1  19-Oct-2008  haad Sync with HEAD.
 1.126.20.1  07-Jan-2011  matt Accumulate syscall, context switch, and other uvmexp counts in cpu_data
and merge into uvmexp. (smaller less impact change than the one for HEAD).
 1.126.16.1  05-Mar-2011  rmind sync with head
 1.130.12.2  03-Dec-2017  jdolecek update from HEAD
 1.130.12.1  25-Feb-2013  tls resync with head
 1.130.2.1  16-Jan-2013  yamt sync with (a bit old) head
 1.131.14.2  28-Aug-2017  skrll Sync with HEAD
 1.131.14.1  06-Jun-2015  skrll Sync with HEAD
 1.134.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.134.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.136.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.136.4.1  10-Jun-2019  christos Sync with HEAD
 1.136.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.136.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.142.2.2  03-Apr-2021  thorpej Sync with HEAD.
 1.142.2.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.148.4.1  11-Aug-2023  martin Pull up following revision(s) (requested by riastradh in ticket #319):

sys/dev/pci/ubsec.c: revision 1.64
sys/dev/pci/hifn7751.c: revision 1.82
lib/libc/gen/getentropy.3: revision 1.5
lib/libc/gen/getentropy.3: revision 1.6
share/man/man4/rnd.4: revision 1.41
lib/libc/sys/getrandom.2: revision 1.2
lib/libc/sys/getrandom.2: revision 1.3
share/man/man5/rc.conf.5: revision 1.193
share/man/man7/entropy.7: revision 1.5
share/man/man7/entropy.7: revision 1.6
share/man/man7/entropy.7: revision 1.7
share/man/man7/entropy.7: revision 1.8
etc/security: revision 1.130
share/man/man7/entropy.7: revision 1.9
etc/security: revision 1.131
sys/crypto/cprng_fast/cprng_fast.c: revision 1.19
sys/sys/rndio.h: revision 1.3
tests/lib/libc/sys/t_getrandom.c: revision 1.5
etc/defaults/rc.conf: revision 1.164
etc/defaults/rc.conf: revision 1.165
sys/sys/rndsource.h: revision 1.10
sys/kern/kern_entropy.c: revision 1.62
sys/kern/kern_entropy.c: revision 1.63
sys/kern/kern_entropy.c: revision 1.64
sys/kern/subr_cprng.c: revision 1.44
sys/kern/kern_entropy.c: revision 1.65
sys/kern/kern_clock.c: revision 1.149
sys/dev/pci/viornd.c: revision 1.22
share/man/man9/rnd.9: revision 1.32
sys/kern/subr_prf.c: revision 1.202
sys/sys/rndsource.h: revision 1.8
sys/sys/rndsource.h: revision 1.9
share/man/man7/entropy.7: revision 1.10

1. Reinstate netbsd<=9 entropy estimator to unblock /dev/random, in
parallel with assessment of only confident entropy sources (seed,
HWRNG) for security warnings like sshd keys in motd and daily
insecurity report.

2. Make multiuser boot wait for first /dev/random output soon after
loading a seed and configuring rndctl, so that getentropy(3) meets
its contract starting early at boot without introducing blocking
paths that could cause hangs in init(8) or single-user mode.
Operators can choose to disable this wait in rc.conf.

3. Fix some bugs left over from reducing the global entropy lock from
a spin lock at IPL_VM to an adaptive lock at IPL_SOFTSERIAL.

4. Update man pages.

RSS XML Feed