Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern kern: Restore non-atomic time_second symbol.



details:   https://anonhg.NetBSD.org/src/rev/f1f6bea7e776
branches:  trunk
changeset: 378214:f1f6bea7e776
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Jul 27 01:48:49 2023 +0000

description:
kern: Restore non-atomic time_second symbol.

This is used by savecore(8), vmstat(8), and possibly other things.

XXX Should really teach dump and savecore(8) to use an intentionally
designed header, rather than relying on kvm(3) -- and make it work
for saving cores from other kernels so you don't have to boot the
same buggy kernel to get a core dump.

diffstat:

 sys/kern/kern_tc.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 4c76ea761233 -r f1f6bea7e776 sys/kern/kern_tc.c
--- a/sys/kern/kern_tc.c        Thu Jul 27 00:34:07 2023 +0000
+++ b/sys/kern/kern_tc.c        Thu Jul 27 01:48:49 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_tc.c,v 1.73 2023/07/17 21:51:45 riastradh Exp $ */
+/* $NetBSD: kern_tc.c,v 1.74 2023/07/27 01:48:49 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.73 2023/07/17 21:51:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.74 2023/07/27 01:48:49 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -133,6 +133,9 @@ static struct timehands *volatile timeha
 struct timecounter *timecounter = &dummy_timecounter;
 static struct timecounter *timecounters = &dummy_timecounter;
 
+/* used by savecore(8) */
+time_t time_second_legacy asm("time_second");
+
 #ifdef __HAVE_ATOMIC64_LOADSTORE
 volatile time_t time__second __cacheline_aligned = 1;
 volatile time_t time__uptime __cacheline_aligned = 1;
@@ -164,6 +167,8 @@ static inline void
 setrealuptime(time_t second, time_t uptime)
 {
 
+       time_second_legacy = second;
+
        atomic_store_relaxed(&time__second, second);
        atomic_store_relaxed(&time__uptime, uptime);
 }
@@ -178,6 +183,8 @@ setrealuptime(time_t second, time_t upti
 
        KDASSERT(mutex_owned(&timecounter_lock));
 
+       time_second_legacy = second;
+
        /*
         * Fast path -- no wraparound, just updating the low bits, so
         * no need for seqlocked access.



Home | Main Index | Thread Index | Old Index