Source-Changes-HG archive

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

[src/trunk]: src/sys/kern avoid calling into time code when cold, and avoid c...



details:   https://anonhg.NetBSD.org/src/rev/0559f2ce1a4c
branches:  trunk
changeset: 331580:0559f2ce1a4c
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Aug 15 07:39:25 2014 +0000

description:
avoid calling into time code when cold, and avoid calling nanotime()
if we're not going to use the result anyway.

XXX: not necessarily the best fix, but better than crashing *early*
boot due to too-early nanotime() calls.

XXX: pullup.

diffstat:

 sys/kern/subr_prf.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r 7d4ee4931630 -r 0559f2ce1a4c sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c       Thu Aug 14 20:59:54 2014 +0000
+++ b/sys/kern/subr_prf.c       Fri Aug 15 07:39:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_prf.c,v 1.154 2014/08/10 16:44:36 tls Exp $       */
+/*     $NetBSD: subr_prf.c,v 1.155 2014/08/15 07:39:25 mrg Exp $       */
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.154 2014/08/10 16:44:36 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.155 2014/08/15 07:39:25 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipkdb.h"
@@ -1200,7 +1200,6 @@
        const char *xdigs;      /* digits for [xX] conversion */
        char bf[KPRINTF_BUFSIZE]; /* space for %c, %[diouxX] */
        char *tailp;            /* tail pointer for snprintf */
-       struct timespec ts;
 
        if (oflags == TOBUFONLY && (vp != NULL))
                tailp = *(char **)vp;
@@ -1549,9 +1548,12 @@
                *(char **)vp = sbuf;
        (*v_flush)();
 
-       (void)nanotime(&ts);
 #ifdef RND_PRINTF
-       SHA512_Update(&kprnd_sha, (char *)&ts, sizeof(ts));
+       if (!cold) {
+               struct timespec ts;
+               (void)nanotime(&ts);
+               SHA512_Update(&kprnd_sha, (char *)&ts, sizeof(ts));
+       }
 #endif
        return ret;
 }



Home | Main Index | Thread Index | Old Index