Commit Graph

178 Commits

Author SHA1 Message Date
dwmalone
771efb08f5 Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported.  In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.
2007-06-04 18:25:08 +00:00
yar
209e4786e7 Commit the results of the typo hunt by Darren Pilgrim.
This change affects documentation and comments only,
no real code involved.

PR:		misc/101245
Submitted by:	Darren Pilgrim <darren pilgrim bitfreak org>
Tested by:	md5(1)
MFC after:	1 week
2006-08-04 07:56:35 +00:00
dwmalone
2e1fa1a727 Add a kern.timecounter.tc sysctl tree that contains the mask,
frequency, quality and current value of each available time counter.

At the moment all of these are read-only, but it might make sense to
make some of these read-write in the future.

MFC after:	3 months
2006-06-16 20:29:05 +00:00
phk
30dc06401a Disable the "cputick increased..." message now that the dust has settled. 2006-03-15 20:22:32 +00:00
phk
d27836ecbb Oops, forgot newline. 2006-03-09 09:44:10 +00:00
phk
64b4ff0373 silence cpu_tick calibration and notice only (under bootverbose)
when the frequency increases.
2006-03-09 09:30:33 +00:00
jhb
16da845ce6 Style nit. 2006-03-07 22:17:26 +00:00
phk
bb00fb407c Add missing cast. 2006-03-04 06:07:26 +00:00
phk
bfe1d73778 More detailed logging if timestepwarnings are enabled. 2006-03-04 06:06:43 +00:00
phk
8f424c3e93 Suffer a little bit of math every 16 second and tighten calibration of
cpu_ticks to the low side of PPM.
2006-03-02 08:09:46 +00:00
phk
79081baaf0 CPU time accounting speedup (step 2)
Keep accounting time (in per-cpu) cputicks and the statistics counts
in the thread and summarize into struct proc when at context switch.

Don't reach across CPUs in calcru().

Add code to calibrate the top speed of cpu_tickrate() for variable
cpu_tick hardware (like TSC on power managed machines).

Don't enforce monotonicity (at least for now) in calcru.  While the
calibrated cpu_tickrate ramps up it may not be true.

Use 27MHz counter on i386/Geode.

Use TSC on amd64 & i386 if present.

Use tick counter on sparc64
2006-02-11 09:33:07 +00:00
phk
bb2f62f536 Modify the way we account for CPU time spent (step 1)
Keep track of time spent by the cpu in various contexts in units of
"cputicks" and scale to real-world microsec^H^H^H^H^H^H^H^Hclock_t
only when somebody wants to inspect the numbers.

For now "cputicks" are still derived from the current timecounter
and therefore things should by definition remain sensible also on
SMP machines.  (The main reason for this first milestone commit is
to verify that hypothesis.)

On slower machines, the avoided multiplications to normalize timestams
at every context switch, comes out as a 5-7% better score on the
unixbench/context1 microbenchmark.  On more modern hardware no change
in performance is seen.
2006-02-07 21:22:02 +00:00
andre
9a84c48b48 Start time_uptime with 1 instead of 0.
Discussed with:		phk
2005-09-19 22:16:31 +00:00
obrien
b888392910 Forward declaring static variables as extern is invalid ISO-C. Now that
GCC can properly handle forward static declarations, do this properly.
2005-09-07 10:06:14 +00:00
phk
e104a9e0b0 s/ENOTTY/ENOIOCTL/ 2005-03-26 20:04:28 +00:00
peter
09964b7499 Put on my peril sensitive sunglasses and add a flags field to the internal
sysctl routines and state.  Add some code to use it for signalling the need
to downconvert a data structure to 32 bits on a 64 bit OS when requested by
a 32 bit app.

I tried to do this in a generic abi wrapper that intercepted the sysctl
oid's, or looked up the format string etc, but it was a real can of worms
that turned into a fragile mess before I even got it partially working.

With this, we can now run 'sysctl -a' on a 32 bit sysctl binary and have
it not abort.  Things like netstat, ps, etc have a long way to go.

This also fixes a bug in the kern.ps_strings and kern.usrstack hacks.
These do matter very much because they are used by libc_r and other things.
2004-10-11 22:04:16 +00:00
phk
9595df2db1 Add some KASSERTS. 2004-08-14 08:33:49 +00:00
phk
e215fa23b4 Just because the timecounter reads the same value on two samples
after each other doesn't mean that nothing happened.
2004-03-04 14:14:23 +00:00
phk
4e1a716219 Write 100 times for tomorrow:
"Always print time_t as %jd, you never know what width it has"
2004-01-22 19:50:06 +00:00
phk
03ff7a46df Add a sysctl (default: off) which enables a log(LOG_INFO...) warning
if the clock is stepped.
2004-01-21 21:05:40 +00:00
phk
c92feb226d Various minor details:
Give the HZ/overflow check a 10% margin.
	Eliminate bogus newline.
	If timecounters have equal quality, prefer higher frequency.

Some inspiration from:	bde
2003-11-13 10:03:58 +00:00
phk
158d08d6fb Use the quality to disable timecounters for which we deem Hz too low. 2003-09-03 08:14:16 +00:00
imp
ee0d294c7e bde made a number of suggested improvements to the code. This commit
represents the pruely stylistic changes and should have no net impact
on the rest of the code.

bde's more substantive changes will follow in a separate commit once
we've come to closure on them.

Submitted by: bde
2003-08-20 19:12:46 +00:00
imp
ef7e40c451 Fix an extreme edge case in leap second handling. We need to call
ntp_update_second twice when we have a large step in case that step
goes across a scheduled leap second.  The only way this could happen
would be if we didn't call tc_windup over the end of day on the day of
a leap second, which would only happen if timeouts were delayed for
seconds.  While it is an edge case, it is an important one to get
right for my employer.

Sponsored by: Timing Solutions Corporation
2003-08-20 05:34:27 +00:00
phk
34014d5261 Give timecounters a numeric quality field.
A timecounter will be selected when registered if its quality is
not negative and no less than the current timecounters.

Add a sysctl to report all available timecounters and their qualities.

Give the dummy timecounter a solid negative quality of minus a million.

Give the i8254 zero and the ACPI 1000.

The TSC gets 800, unless APM or SMP forces it negative.

Other timecounters default to zero quality and thereby retain current
selection behaviour.
2003-08-16 08:23:53 +00:00
mux
43629d3ba9 Remove extra space. 2003-08-12 20:34:31 +00:00
phk
ffa9cfbd86 typo fix in comment. 2003-07-02 08:01:52 +00:00
imp
9f82a8a978 Fix leap second processing by the kernel time keeping routines.
Before, we would add/subtract the leap second when the system had been
up for an even multiple of days, rather than at the end of the day, as
a leap second is defined (at least wrt ntp).  We do this by
calculating the notion of UTC earlier in the loop, and passing that to
get it adjusted.  Any adjustments that ntp_update_second makes to this
time are then transferred to boot time.  We can't pass it either the
boot time or the uptime because their sum is what determines when a
leap second is needed.  This code adds an extra assignment and two
extra compare in the typical case, which is as cheap as I could made
it.

I have confirmed with this code the kernel time does the correct thing
for both positive and negative leap seconds.  Since the ntp interface
doesn't allow for +2 or -2, those cases can't be tested (and the folks
in the know here say there will never be a +2s or -2s leap event, but
rather two +1s or -1s leap events).

There will very likely be no leap seconds for a while, given how the
earth is speeding up and slowing down, so there will be plenty of time
for this fix to propigate.  UT1-UTC is currently at "about -0.4s" and
decrementing by .1s every 8 months or so.  6 * 8 is 48 months, or 4
years.

-stable has different code, but a similar bug that was introduced
about the time of the last leap second, which is why nobody has
noticed until now.

MFC After: 3 weeks
Reviewed by: phk

"Furthermore, leap seconds must die." -- Cato the Elder
2003-06-25 21:23:51 +00:00
imp
c8a0ca10a0 Use UTC rather than GMT to describe time scale. latter is obsolete. 2003-06-23 20:14:08 +00:00
obrien
3b8fff9e4c Use __FBSDID(). 2003-06-11 00:56:59 +00:00
phk
e059b79437 Including <sys/stdint.h> is (almost?) universally only to be able to use
%j in printfs, so put a newsted include in <sys/systm.h> where the printf
prototype lives and save everybody else the trouble.
2003-03-18 08:45:25 +00:00
phk
13e0104093 Move timecounters notion of frequency to 64 bits.
[WARNING: CPUs in the distant future may be closer than they appear!]
2003-01-29 11:29:22 +00:00
phk
bd84d01eea Add sysctl kern.timecounter.nsetclock which indicates the number of
potential discontinuities in our UTC timescale.

Applications can monitor this variable if they want to be informed
about steps in the timescale.  Slews (ntp and adjtime(2)) and
frequency adjustments (ntp) will not increment this counter, only
operations which set the clock.  No attempt is made to classify
size or direction of the step.
2003-01-25 07:51:09 +00:00
phk
4ed685af08 Move a local variable to avoid the compiler warning about it being unused. 2003-01-16 20:06:45 +00:00
jhay
d24749bcb4 hardpps() wants the raw hardware counter value converted to nanoseconds. 2003-01-16 19:22:13 +00:00
peter
af85e6b2d6 Explicitly have the timecounter init happen after the cpu_initclocks is
called.  Otherwise (depending on a non-deterministic sort), the timecounter
code can be initialized before the clock rate has been set (on ia64) and it
assumes hz = 100, rather than the real value of 1024.  I'm not sure how much
gets upset by this.

Glanced at by:	phk
2003-01-06 01:01:08 +00:00
phk
3b4ae5ea5c Export tc_tick with sysctl, not tick.
Spotted by:	bde
2003-01-04 17:33:55 +00:00
phk
3ce3aae31e Introduce a "time_uptime" global variable which holds the time since boot
in seconds.
2002-11-01 18:52:20 +00:00
robert
1e0cdb534a Use strlcpy() instead of strncpy() to copy NUL terminated strings
for safety and consistency.
2002-10-17 20:03:38 +00:00
phk
d608e476ab Do not employ timecounter hardware if our hz does not support their
correct rewinding.
2002-09-04 19:32:18 +00:00
phk
8ceeefb3da Give up on calling tc_ticktock() from a timeout, we have timeout
functions which run for several milliseconds at a time and getting
in queue behind one or more of those makes us miss our rewind.

Instead call it from hardclock() like we used to do, but retain the
prescaler so we still cope with high HZ values.
2002-09-04 10:15:19 +00:00
markm
aee41bc9a8 Use a semicolon at the end of a function-like macro invocation. Kills
warnings and makes the visual style easier.
2002-07-15 13:13:04 +00:00
kbyanc
a46c40d9e1 Time counter stats are unsigned, advertise them to sysctl(8) that way.
PR:		(one small part of) 19720
Approved by:	phk
2002-06-11 19:47:44 +00:00
phk
53143bb2c1 Mistyped and lost a '&' in previous commit. 2002-05-30 16:26:39 +00:00
phk
559ad51949 Don't forget to factor in the boottime when we calculate PPS timestamps.
Submitted by:	Akira Watanabe <akira@myaw.ei.meisei-u.ac.jp>
2002-05-30 10:34:01 +00:00
phk
d26e256ae9 Initialize time_second to 1 instead of zero to pacify slightly bogus arp code.
Various minor style fixes from BDE.
2002-05-03 08:46:03 +00:00
peter
55a74432bb kern_tc.c doesn't use <machine/psl.h>, and having this #include breaks
other platforms.
2002-05-01 01:31:26 +00:00
phk
5ae616a516 Brucifixion ? Yes, out that door, row on the left, one patch each.
Many thanks to:	bde
2002-04-30 20:42:06 +00:00
phk
307f787e5a Stylistic sweep through the timecounter code.
Renovate comments.
2002-04-28 18:24:21 +00:00
phk
e866359c06 Don't screw up our uptime with historical dates. 2002-04-28 16:51:36 +00:00