diff options
| author | thorpej <thorpej@NetBSD.org> | 2020-01-02 15:42:26 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2020-01-02 15:42:26 +0000 |
| commit | 1813308f3dc95da15482d30d538529ebbb8f2503 (patch) | |
| tree | 013882703f47cf3c0cd0ad3507cb0560f288ae86 /sys/miscfs/procfs/procfs_linux.c | |
| parent | b83b0a58dd302e911ffcef6b91fe7c02d99e22ab (diff) | |
- Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).
XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
Diffstat (limited to 'sys/miscfs/procfs/procfs_linux.c')
| -rw-r--r-- | sys/miscfs/procfs/procfs_linux.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/miscfs/procfs/procfs_linux.c b/sys/miscfs/procfs/procfs_linux.c index f9aad563963..146fddaa6ad 100644 --- a/sys/miscfs/procfs/procfs_linux.c +++ b/sys/miscfs/procfs/procfs_linux.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_linux.c,v 1.79 2019/12/31 13:07:13 ad Exp $ */ +/* $NetBSD: procfs_linux.c,v 1.80 2020/01/02 15:42:27 thorpej Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.79 2019/12/31 13:07:13 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.80 2020/01/02 15:42:27 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -297,6 +297,9 @@ procfs_docpustat(struct lwp *curl, struct proc *p, cpu_count_sync_all(); + struct timeval btv; + getmicroboottime(&btv); + len += snprintf(&bf[len], LBFSZ - len, "disk 0 0 0 0\n" "page %u %u\n" @@ -308,7 +311,7 @@ procfs_docpustat(struct lwp *curl, struct proc *p, uvmexp.pgswapin, uvmexp.pgswapout, cpu_count_get(CPU_COUNT_NINTR), cpu_count_get(CPU_COUNT_NSWTCH), - boottime.tv_sec); + btv.tv_sec); if (len >= LBFSZ) goto out; |
