Wed Oct 4 09:10:37 2017 UTC ()
Call sysctl_kernhist_new for KERNHIST_LINK_STATIC.  I can get usbhist from
vmstat(1) again.


(skrll)
diff -r1.18 -r1.19 src/sys/sys/kernhist.h

cvs diff -r1.18 -r1.19 src/sys/sys/kernhist.h (expand / switch to unified diff)

--- src/sys/sys/kernhist.h 2017/01/10 00:50:57 1.18
+++ src/sys/sys/kernhist.h 2017/10/04 09:10:37 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kernhist.h,v 1.18 2017/01/10 00:50:57 pgoyette Exp $ */ 1/* $NetBSD: kernhist.h,v 1.19 2017/10/04 09:10:37 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Charles D. Cranor and Washington University. 4 * Copyright (c) 1997 Charles D. Cranor and Washington University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -137,64 +137,63 @@ LIST_HEAD(kern_history_head, kern_histor @@ -137,64 +137,63 @@ LIST_HEAD(kern_history_head, kern_histor
137#define KERNHIST_CALLED(NAME) 137#define KERNHIST_CALLED(NAME)
138#define KERNHIST_FUNC(FNAME) 138#define KERNHIST_FUNC(FNAME)
139#define KERNHIST_DUMP(NAME) 139#define KERNHIST_DUMP(NAME)
140#else 140#else
141#include <sys/kernel.h> /* for "cold" variable */ 141#include <sys/kernel.h> /* for "cold" variable */
142#include <sys/atomic.h> 142#include <sys/atomic.h>
143#include <sys/kmem.h> 143#include <sys/kmem.h>
144 144
145extern struct kern_history_head kern_histories; 145extern struct kern_history_head kern_histories;
146 146
147#define KERNHIST_DECL(NAME) extern struct kern_history NAME 147#define KERNHIST_DECL(NAME) extern struct kern_history NAME
148#define KERNHIST_DEFINE(NAME) struct kern_history NAME 148#define KERNHIST_DEFINE(NAME) struct kern_history NAME
149 149
 150#define KERNHIST_LINK_STATIC(NAME) \
 151 LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \
 152 sysctl_kernhist_new(&(NAME));
 153
150#define KERNHIST_INIT(NAME,N) \ 154#define KERNHIST_INIT(NAME,N) \
151do { \ 155do { \
152 (NAME).name = __STRING(NAME); \ 156 (NAME).name = __STRING(NAME); \
153 (NAME).namelen = strlen(__STRING(NAME)); \ 157 (NAME).namelen = strlen(__STRING(NAME)); \
154 (NAME).n = (N); \ 158 (NAME).n = (N); \
155 (NAME).f = 0; \ 159 (NAME).f = 0; \
156 (NAME).e = (struct kern_history_ent *) \ 160 (NAME).e = (struct kern_history_ent *) \
157 kmem_zalloc(sizeof(struct kern_history_ent) * (N), KM_SLEEP); \ 161 kmem_zalloc(sizeof(struct kern_history_ent) * (N), KM_SLEEP); \
158 (NAME).s = 0; \ 162 (NAME).s = 0; \
159 LIST_INSERT_HEAD(&kern_histories, &(NAME), list); \ 163 KERNHIST_LINK_STATIC(NAME) \
160 sysctl_kernhist_new(&(NAME)); \ 
161} while (/*CONSTCOND*/ 0) 164} while (/*CONSTCOND*/ 0)
162 165
163#define KERNHIST_INITIALIZER(NAME,BUF) \ 166#define KERNHIST_INITIALIZER(NAME,BUF) \
164{ \ 167{ \
165 .name = __STRING(NAME), \ 168 .name = __STRING(NAME), \
166 .namelen = sizeof(__STRING(NAME)) - 1, \ 169 .namelen = sizeof(__STRING(NAME)) - 1, \
167 .n = sizeof(BUF) / sizeof(struct kern_history_ent), \ 170 .n = sizeof(BUF) / sizeof(struct kern_history_ent), \
168 .f = 0, \ 171 .f = 0, \
169 .e = (struct kern_history_ent *) (BUF), \ 172 .e = (struct kern_history_ent *) (BUF), \
170 .s = 0, \ 173 .s = 0, \
171 /* BUF will inititalized to zeroes by being in .bss */ \ 174 /* BUF will inititalized to zeroes by being in .bss */ \
172} 175}
173 176
174#define KERNHIST_LINK_STATIC(NAME) \ 
175 LIST_INSERT_HEAD(&kern_histories, &(NAME), list) 
176 
177#define KERNHIST_INIT_STATIC(NAME,BUF) \ 177#define KERNHIST_INIT_STATIC(NAME,BUF) \
178do { \ 178do { \
179 (NAME).name = __STRING(NAME); \ 179 (NAME).name = __STRING(NAME); \
180 (NAME).namelen = strlen(__STRING(NAME)); \ 180 (NAME).namelen = strlen(__STRING(NAME)); \
181 (NAME).n = sizeof(BUF) / sizeof(struct kern_history_ent); \ 181 (NAME).n = sizeof(BUF) / sizeof(struct kern_history_ent); \
182 (NAME).f = 0; \ 182 (NAME).f = 0; \
183 (NAME).e = (struct kern_history_ent *) (BUF); \ 183 (NAME).e = (struct kern_history_ent *) (BUF); \
184 (NAME).s = 0; \ 184 (NAME).s = 0; \
185 memset((NAME).e, 0, sizeof(struct kern_history_ent) * (NAME).n); \ 185 memset((NAME).e, 0, sizeof(struct kern_history_ent) * (NAME).n); \
186 KERNHIST_LINK_STATIC(NAME); \ 186 KERNHIST_LINK_STATIC(NAME) \
187 sysctl_kernhist_new(&(NAME)); \ 
188} while (/*CONSTCOND*/ 0) 187} while (/*CONSTCOND*/ 0)
189 188
190#ifndef KERNHIST_DELAY 189#ifndef KERNHIST_DELAY
191#define KERNHIST_DELAY 100000 190#define KERNHIST_DELAY 100000
192#endif 191#endif
193 192
194#if defined(KERNHIST_PRINT) 193#if defined(KERNHIST_PRINT)
195extern int kernhist_print_enabled; 194extern int kernhist_print_enabled;
196#define KERNHIST_PRINTNOW(E) \ 195#define KERNHIST_PRINTNOW(E) \
197do { \ 196do { \
198 if (kernhist_print_enabled) { \ 197 if (kernhist_print_enabled) { \
199 kernhist_entry_print(E, printf); \ 198 kernhist_entry_print(E, printf); \
200 if (KERNHIST_DELAY != 0) \ 199 if (KERNHIST_DELAY != 0) \