#
11d1f9b2 |
| 23-Aug-2023 |
cheloha <cheloha@openbsd.org> |
all platforms: separate cpu_initclocks() from cpu_startclock()
To give the primary CPU an opportunity to perform clock interrupt preparation in a machine-independent manner we need to separate the "
all platforms: separate cpu_initclocks() from cpu_startclock()
To give the primary CPU an opportunity to perform clock interrupt preparation in a machine-independent manner we need to separate the "initialization" parts of cpu_initclocks() from the "start the clock interrupt" parts. Currently, cpu_initclocks() does everything all at once, so there is no space for this MI setup.
Many platforms have more-or-less already done this separation by implementing a separate routine named "cpu_startclock()". This patch promotes cpu_startclock() from de facto standard to mandatory API.
- Prototype cpu_startclock() in sys/systm.h alongside cpu_initclocks(). The separation of responsibility between the two routines is a bit fuzzy but the basic guidelines are as follows:
+ cpu_initclocks() must initialize hz, stathz, and profhz, and call clockintr_init().
+ cpu_startclock() must call clockintr_cpu_init() and start the clock interrupt cycle on the calling CPU.
These guidelines will shift in the future, but that's the way things stand as of *this* commit.
- In initclocks(): first call cpu_initclocks(), then do MI setup, and last call cpu_startclock().
- On platforms where cpu_startclock() already exists: don't call cpu_startclock() from cpu_initclocks() anymore.
- On platforms where cpu_startclock() doesn't yet exist: implement it. Usually this is as simple as dividing cpu_initclocks() in two.
Tested on amd64 (i8254, lapic), arm64, i386 (i8254, lapic), macppc, mips64/octeon, and sparc64. Tested on arm/armv7 (agtimer(4)) by phessler@ and jmatthew@. Tested on m88k/luna88k by aoyama@. Tested on powerpc64 by gkoehler@ and mlarkin@. Tested on riscv64 by jmatthew@.
Thread: https://marc.info/?l=openbsd-tech&m=169195251322149&w=2
show more ...
|
#
671537bf |
| 25-Jul-2023 |
cheloha <cheloha@openbsd.org> |
statclock: move profil(2), GPROF code to profclock(), gmonclock()
This patch isolates profil(2) and GPROF from statclock(). Currently, statclock() implements both profil(2) and GPROF through a comp
statclock: move profil(2), GPROF code to profclock(), gmonclock()
This patch isolates profil(2) and GPROF from statclock(). Currently, statclock() implements both profil(2) and GPROF through a complex mechanism involving both platform code (setstatclockrate) and the scheduler (pscnt, psdiv, and psratio). We have a machine-independent interface to the clock interrupt hardware now, so we no longer need to do it this way.
- Move profil(2)-specific code from statclock() to a new clock interrupt callback, profclock(), in subr_prof.c. Each schedstate_percpu has its own profclock handle. The profclock is enabled/disabled for a given CPU when it is needed by the running thread during mi_switch() and sched_exit().
- Move GPROF-specific code from statclock() to a new clock interrupt callback, gmonclock(), in subr_prof.c. Where available, each cpu_info has its own gmonclock handle . The gmonclock is enabled/disabled for a given CPU via sysctl(2) in prof_state_toggle().
- Both profclock() and gmonclock() have a fixed period, profclock_period, that is initialized during initclocks().
- Export clockintr_advance(), clockintr_cancel(), clockintr_establish(), and clockintr_stagger() via <sys/clockintr.h>. They have external callers now.
- Delete pscnt, psdiv, psratio. From schedstate_percpu, also delete spc_pscnt and spc_psdiv. The statclock frequency is not dynamic anymore so these variables are now useless.
- Delete code/state related to the dynamic statclock frequency from kern_clockintr.c. The statclock frequency can still be pseudo-random, so move the contents of clockintr_statvar_init() into clockintr_init().
With input from miod@, deraadt@, and claudio@. Early revisions cleaned up by claudio. Early revisions tested by claudio@. Tested by cheloha@ on amd64, arm64, macppc, octeon, and sparc64 (sun4v). Compile- and boot- tested on i386 by mlarkin@. riscv64 compilation bugs found by mlarkin@. Tested on riscv64 by jca@. Tested on powerpc64 by gkoehler@.
show more ...
|
#
24ee467d |
| 04-Feb-2023 |
cheloha <cheloha@openbsd.org> |
timecounting: remove incomplete PPS support
The timecounting code has had stubs for pulse-per-second (PPS) polling since it was imported in 2004. At this point it seems unlikely that anyone is goin
timecounting: remove incomplete PPS support
The timecounting code has had stubs for pulse-per-second (PPS) polling since it was imported in 2004. At this point it seems unlikely that anyone is going to finish adding PPS support, so let's remove the stubs:
- Delete the dead tc_poll_pps() call from tc_windup(). - Remove all tc_poll_pps symbols from the kernel.
Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2
ok miod@
show more ...
|
#
f124c57c |
| 19-Nov-2022 |
cheloha <cheloha@openbsd.org> |
mips64, loongson, octeon: switch to clockintr
- Remove mips64-specific clock interrupt scheduling bits from cpu_info. - Add missing tick_nsec initialization to cpu_initclocks(). - Disable the glxclk
mips64, loongson, octeon: switch to clockintr
- Remove mips64-specific clock interrupt scheduling bits from cpu_info. - Add missing tick_nsec initialization to cpu_initclocks(). - Disable the glxclk interrupt clock on loongson. visa@/miod@ say it can be removed later if it isn't useful for anything else. - Wire up cp0_intrclock.
Notes:
- The loongson apm_suspend() changes are untested, but deraadt@ claims APM suspend/resume on loongson doesn't work anyway. - loongson and octeon now have a randomized statclock(), stathz = hz.
With input from miod@, visa@. Tested by miod@, visa@.
Link: https://marc.info/?l=openbsd-tech&m=166776379603497&w=2
ok visa@ mlarkin@
show more ...
|
#
1b4a394f |
| 30-Oct-2022 |
guenther <guenther@openbsd.org> |
Simplfity setregs() by passing it the ps_strings and switching sys_execve() to return EJUSTRETURN.
setregs() is the MD routine used by sys_execve() to set up the thread's trapframe and PCB such that
Simplfity setregs() by passing it the ps_strings and switching sys_execve() to return EJUSTRETURN.
setregs() is the MD routine used by sys_execve() to set up the thread's trapframe and PCB such that, on 'return' to userspace, it has the register values defined by the ABI and otherwise zero. It had to set the syscall retval[] values previously because the normal syscall return path overwrites a couple registers with the retval[] values. By instead returning EJUSTRETURN that and some complexity with program-counter handling on m88k and sparc64 goes away.
Also, give setregs() add a 'struct ps_strings *arginfo' argument so powerpc, powerpc64, and sh can directly get argc/argv/envp values for registers instead of copyin()ing the one in userspace.
Improvements from miod@ and millert@ Testing assistance miod@, kettenis@, and aoyama@ ok miod@ kettenis@
show more ...
|
#
85caa4b9 |
| 22-Aug-2022 |
cheloha <cheloha@openbsd.org> |
mips64, octeon, loonson: trigger deferred clock interrupts from splx(9)
As with powerpc, powerpc64, and riscv64, on mips64 platforms we need to isolate the clock interrupt schedule from the MD clock
mips64, octeon, loonson: trigger deferred clock interrupts from splx(9)
As with powerpc, powerpc64, and riscv64, on mips64 platforms we need to isolate the clock interrupt schedule from the MD clock interrupt code. To do this, we need to stop deferring clock interrupt work until the next tick and instead defer the work until we logically unmask the clock interrupt from splx(9).
Add a boolean (ci_clock_deferred) to the cpu_info struct to note whether we need to trigger the clock interrupt by hand, and then do so from splx(9) by calling md_triggerclock().
Currently md_triggerclock is only ever set to cp0_trigger_int5(). The routine takes great care to ensure that INT5 has fired or will fire before returning.
There are some loongson machines that use glxclk instead of CP0. They can be switched to use CP0 later.
With input and advice from visa@ and miod@.
Compiled and extensively tested by visa@ and miod@ on various octeon and loongson machines. No issues seen on octeon machines. miod@ saw some odd things on loongsoon, but suggests that all issues are probably unrelated to this patch.
Link: https://marc.info/?l=openbsd-tech&m=165929192702632&w=2
ok visa@, miod@
show more ...
|
#
bfc185c1 |
| 01-May-2021 |
visa <visa@openbsd.org> |
Retire OpenBSD/sgi.
OK deraadt@
|
#
4cab4d08 |
| 29-Apr-2021 |
visa <visa@openbsd.org> |
Remove unused RM7000 ICR handling.
|
#
8611d3cd |
| 23-Feb-2021 |
cheloha <cheloha@openbsd.org> |
timecounting: use C99-style initialization for all timecounter structs
The timecounter struct is large and I think it may change in the future. Changing it later will be easier if we use C99-style
timecounting: use C99-style initialization for all timecounter structs
The timecounter struct is large and I think it may change in the future. Changing it later will be easier if we use C99-style initialization for all timecounter structs. It also makes reading the code a bit easier.
For reasons I cannot explain, switching to C99-style initialization sometimes changes the hash of the resulting object file, even though the resulting struct should be the same. So there is a binary change here, but only sometimes. No behavior should change in either case.
I can't compile-test this everywhere but I have been staring at the diff for days now and I'm relatively confident this will not break compilation. Fingers crossed.
ok gnezdo@
show more ...
|
#
9589ba9d |
| 13-Jan-2021 |
cheloha <cheloha@openbsd.org> |
kernel, sysctl(8): remove dead variable: tickadj
The global "tickadj" variable is a remnant of the old NTP adjustment code we used in the kernel before the current timecounter subsystem was imported
kernel, sysctl(8): remove dead variable: tickadj
The global "tickadj" variable is a remnant of the old NTP adjustment code we used in the kernel before the current timecounter subsystem was imported from FreeBSD circa 2004 or 2005.
Fifteen years hence it is completely vestigial and we can remove it. We probably should have removed it long ago but I guess it slipped through the cracks. FreeBSD removed it in 2002:
https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d
NetBSD and DragonflyBSD can probably remove it, too.
We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2 and sysctl(8) accordingly. Hypothetically this change could break someone's sysctl(8) parsing script. I don't think that's very likely.
ok mvs@
show more ...
|
#
9e8849fb |
| 11-Jul-2020 |
visa <visa@openbsd.org> |
Synchronize each core's CP0 cycle counter using the IO clock counter. This makes the cycle counter usable as timecounter on multiprocessor machines.
Idea from Linux.
Tested on CN5020, CN6120, CN713
Synchronize each core's CP0 cycle counter using the IO clock counter. This makes the cycle counter usable as timecounter on multiprocessor machines.
Idea from Linux.
Tested on CN5020, CN6120, CN7130 and CN7360.
Looks reasonable to kettenis@
show more ...
|
#
d82e6535 |
| 06-Jul-2020 |
pirofti <pirofti@openbsd.org> |
Add support for timeconting in userland.
This diff exposes parts of clock_gettime(2) and gettimeofday(2) to userland via libc eliberating processes from the need for a context switch everytime they
Add support for timeconting in userland.
This diff exposes parts of clock_gettime(2) and gettimeofday(2) to userland via libc eliberating processes from the need for a context switch everytime they want to count the passage of time.
If a timecounter clock can be exposed to userland than it needs to set its tc_user member to a non-zero value. Tested with one or multiple counters per architecture.
The timing data is shared through a pointer found in the new ELF auxiliary vector AUX_openbsd_timekeep containing timehands information that is frequently updated by the kernel.
Timing differences between the last kernel update and the current time are adjusted in userland by the tc_get_timecount() function inside the MD usertc.c file.
This permits a much more responsive environment, quite visible in browsers, office programs and gaming (apparently one is are able to fly in Minecraft now).
Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!
OK from at least kettenis@, cheloha@, naddy@, sthen@
show more ...
|
#
f7542e3c |
| 30-Jun-2020 |
visa <visa@openbsd.org> |
Retire unused <mips64/dev/clockvar.h> interface.
|
#
5fcf2a4b |
| 16-May-2020 |
kettenis <kettenis@openbsd.org> |
Make inittodr() and resettodr() MI.
ok deraadt@, mpi@, visa@ ok cheloha@ as well (would have preferred in new file for this code)
|
#
c8475573 |
| 16-May-2020 |
visa <visa@openbsd.org> |
Use todr_gettime() in cp0_calibrate() on mips64.
This allows changing RTC drivers from <mips64/dev/clockvar.h> to <dev/clock_subr.h> API.
OK kettenis@
|
#
90325055 |
| 11-May-2020 |
kettenis <kettenis@openbsd.org> |
Initialize the timeval passed to todr_gettime() with the base time from the file system such that implementations can use it to guess the right century.
ok mpi@
|
#
bb2235eb |
| 09-May-2020 |
kettenis <kettenis@openbsd.org> |
Use the same inittodr()/resettodr() implementation as on amd64/arm64/armv7/hppa/i386/macppc/sparc64 and move it to the end of mips64_machdep.c. Wrap the existing tod_get and tod_set hooks into somet
Use the same inittodr()/resettodr() implementation as on amd64/arm64/armv7/hppa/i386/macppc/sparc64 and move it to the end of mips64_machdep.c. Wrap the existing tod_get and tod_set hooks into something that can be used as a todr_handle.
ok visa@
show more ...
|
#
70123da1 |
| 13-Jun-2018 |
visa <visa@openbsd.org> |
Make octeon kernels compile with DEBUG.
Based on a diff from jj@. Thank you!
|
#
6d1676f7 |
| 02-Sep-2017 |
visa <visa@openbsd.org> |
Let the kernel utilize the FPU if one is available, even when the FPUEMUL option is enabled. This benefits OCTEON III systems which can run floating-point operations natively.
Feedback from and OK m
Let the kernel utilize the FPU if one is available, even when the FPUEMUL option is enabled. This benefits OCTEON III systems which can run floating-point operations natively.
Feedback from and OK miod@; he also helped with testing.
Tested on octeon without FPU (CN5020, CN6120) and with FPU (CN7130), as well as on sgi/IP27 (MP R16000), sgi/IP32 (R5000), and loongson (3A1000).
show more ...
|
#
0dfef174 |
| 01-Sep-2017 |
visa <visa@openbsd.org> |
Ansify function definitions.
|
#
0d75fa6d |
| 08-Jun-2017 |
visa <visa@openbsd.org> |
Move loongson/octeon/sgi unmap_startup() under arch/mips64.
|
#
ae475946 |
| 29-May-2017 |
visa <visa@openbsd.org> |
Invalidate OCTEON icache after TLB ASID wraparound, otherwise userspace might execute stale instructions. The cache is virtually tagged and does not seem to pick up TLB alterations automatically.
|
#
592093c1 |
| 16-Aug-2016 |
visa <visa@openbsd.org> |
Remove RM7000/RM9000-specific performance counter code. It originates from PMON2000 and has not been enabled on OpenBSD.
Suggested by and ok miod@ (after seeing a quad_t cleanup patch of mine)
|
#
b43ebd13 |
| 06-Mar-2016 |
mpi <mpi@openbsd.org> |
Rename mips64's trap_frame into trapframe.
For coherency with other archs and in order to use it in MI code.
ok visa@, tobiasu@
|
#
e087cc70 |
| 15-Dec-2014 |
guenther <guenther@openbsd.org> |
Use MAP_INHERIT_* for the 'inh' argument to the UMV_MAPFLAG() macro, eliminating the must-be-kept-in-sync UVM_INH_* macros
ok deraadt@ tedu@
|