diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2020-06-24 22:03:46 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2020-06-24 22:03:46 +0000 |
commit | ca98724d303a2d2852e5afc6ca4f8df91ce7c4f1 (patch) | |
tree | 78c03b913ca4a13ca82e30fea2eea3633977a5a0 /sys/arch/loongson | |
parent | d5d00fdfec2707a72d8f409ed3069c27bc916b04 (diff) |
kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)
time_second(9) and time_uptime(9) are widely used in the kernel to
quickly get the system UTC or system uptime as a time_t. However,
time_t is 64-bit everywhere, so it is not generally safe to use them
on 32-bit platforms: you have a split-read problem if your hardware
cannot perform atomic 64-bit reads.
This patch replaces time_second(9) with gettime(9), a safer successor
interface, throughout the kernel. Similarly, time_uptime(9) is replaced
with getuptime(9).
There is a performance cost on 32-bit platforms in exchange for
eliminating the split-read problem: instead of two register reads you
now have a lockless read loop to pull the values from the timehands.
This is really not *too* bad in the grand scheme of things, but
compared to what we were doing before it is several times slower.
There is no performance cost on 64-bit (__LP64__) platforms.
With input from visa@, dlg@, and tedu@.
Several bugs squashed by visa@.
ok kettenis@
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r-- | sys/arch/loongson/dev/apm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/arch/loongson/dev/apm.c b/sys/arch/loongson/dev/apm.c index 42b3d7c61ba..250d69d248e 100644 --- a/sys/arch/loongson/dev/apm.c +++ b/sys/arch/loongson/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.37 2020/05/29 04:42:24 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.38 2020/06/24 22:03:40 cheloha Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -415,7 +415,7 @@ apm_suspend(int state) if (rv == 0) rv = sys_platform->resume(); } - inittodr(time_second); /* Move the clock forward */ + inittodr(gettime()); /* Move the clock forward */ config_suspend_all(DVACT_RESUME); cold = 0; |