By popular demand, update kernhist to use bintime(9) as the basis for
its timestamps. As this changes storage structures for data passed between kernel and userland, welcome to 7.99.55! XXX Output routines still use microsecond resolution when printf()ing. XXX Possible future feature would be addition of option to use XXX getbintime(9) for less time-critical histories.
This commit is contained in:
parent
c42fba4183
commit
c9b6361b98
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_history.c,v 1.10 2017/01/04 01:05:58 pgoyette Exp $ */
|
||||
/* $NetBSD: kern_history.c,v 1.11 2017/01/05 03:40:33 pgoyette Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
||||
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_history.c,v 1.10 2017/01/04 01:05:58 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_history.c,v 1.11 2017/01/05 03:40:33 pgoyette Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kernhist.h"
|
||||
|
@ -120,7 +120,7 @@ kernhist_dump(struct kern_history *l, void (*pr)(const char *, ...))
|
|||
static void
|
||||
kernhist_dump_histories(struct kern_history *hists[], void (*pr)(const char *, ...))
|
||||
{
|
||||
struct timeval tv;
|
||||
struct bintime bt;
|
||||
int cur[MAXHISTS];
|
||||
int lcv, hi;
|
||||
|
||||
|
@ -136,7 +136,7 @@ kernhist_dump_histories(struct kern_history *hists[], void (*pr)(const char *, .
|
|||
*/
|
||||
for (;;) {
|
||||
hi = -1;
|
||||
tv.tv_sec = tv.tv_usec = 0;
|
||||
bt.sec = 0; bt.frac = 0;
|
||||
|
||||
/* loop over each history */
|
||||
for (lcv = 0; hists[lcv]; lcv++) {
|
||||
|
@ -159,12 +159,12 @@ restart:
|
|||
|
||||
/*
|
||||
* if the time hasn't been set yet, or this entry is
|
||||
* earlier than the current tv, set the time and history
|
||||
* earlier than the current bt, set the time and history
|
||||
* index.
|
||||
*/
|
||||
if (tv.tv_sec == 0 ||
|
||||
timercmp(&hists[lcv]->e[cur[lcv]].tv, &tv, <)) {
|
||||
tv = hists[lcv]->e[cur[lcv]].tv;
|
||||
if (bt.sec == 0 ||
|
||||
bintimecmp(&hists[lcv]->e[cur[lcv]].bt, &bt, <)) {
|
||||
bt = hists[lcv]->e[cur[lcv]].bt;
|
||||
hi = lcv;
|
||||
}
|
||||
}
|
||||
|
@ -466,8 +466,7 @@ sysctl_kernhist_helper(SYSCTLFN_ARGS)
|
|||
out_evt->she_fmtoffset = 0;
|
||||
continue;
|
||||
}
|
||||
out_evt->she_time_sec = in_evt->tv.tv_sec;
|
||||
out_evt->she_time_usec = in_evt->tv.tv_usec;
|
||||
out_evt->she_bintime = in_evt->bt;
|
||||
out_evt->she_callnumber = in_evt->call;
|
||||
out_evt->she_cpunum = in_evt->cpunum;
|
||||
out_evt->she_values[0] = in_evt->v[0];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kernhist.h,v 1.16 2017/01/04 01:52:13 pgoyette Exp $ */
|
||||
/* $NetBSD: kernhist.h,v 1.17 2017/01/05 03:40:33 pgoyette Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Charles D. Cranor and Washington University.
|
||||
|
@ -46,7 +46,7 @@
|
|||
*/
|
||||
|
||||
struct kern_history_ent {
|
||||
struct timeval tv; /* time stamp */
|
||||
struct bintime bt; /* time stamp */
|
||||
int cpunum;
|
||||
const char *fmt; /* printf format */
|
||||
size_t fmtlen; /* length of printf format */
|
||||
|
@ -80,8 +80,7 @@ struct sysctl_history_list_entry {
|
|||
|
||||
/* info for a single history event */
|
||||
struct sysctl_history_event {
|
||||
uint64_t she_time_sec;
|
||||
uint64_t she_time_usec;
|
||||
struct bintime she_bintime;
|
||||
uint64_t she_callnumber;
|
||||
uint64_t she_values[4];
|
||||
uint32_t she_cpunum;
|
||||
|
@ -213,7 +212,7 @@ do { \
|
|||
} while (atomic_cas_uint(&(NAME).f, _i_, _j_) != _i_); \
|
||||
struct kern_history_ent * const _e_ = &(NAME).e[_i_]; \
|
||||
if (__predict_true(!cold)) \
|
||||
microtime(&_e_->tv); \
|
||||
bintime(&_e_->bt); \
|
||||
_e_->cpunum = cpu_number(); \
|
||||
_e_->fmt = (FMT); \
|
||||
_e_->fmtlen = strlen(FMT); \
|
||||
|
@ -257,7 +256,10 @@ do { \
|
|||
static inline void
|
||||
kernhist_entry_print(const struct kern_history_ent *e, void (*pr)(const char *, ...) __printflike(1, 2))
|
||||
{
|
||||
pr("%06" PRIu64 ".%06d ", e->tv.tv_sec, e->tv.tv_usec);
|
||||
struct timeval tv;
|
||||
|
||||
bintime2timeval(&e->bt, &tv);
|
||||
pr("%06" PRIu64 ".%06d ", tv.tv_sec, tv.tv_usec);
|
||||
pr("%s#%ld@%d: ", e->fn, e->call, e->cpunum);
|
||||
pr(e->fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
|
||||
pr("\n");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: param.h,v 1.521 2017/01/02 10:33:28 hannken Exp $ */
|
||||
/* $NetBSD: param.h,v 1.522 2017/01/05 03:40:33 pgoyette Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -67,7 +67,7 @@
|
|||
* 2.99.9 (299000900)
|
||||
*/
|
||||
|
||||
#define __NetBSD_Version__ 799005400 /* NetBSD 7.99.54 */
|
||||
#define __NetBSD_Version__ 799005500 /* NetBSD 7.99.55 */
|
||||
|
||||
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
|
||||
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
|
||||
|
|
Loading…
Reference in New Issue