Make the TUNABLE_*() macros look and behave more consistantly like the

SYSCTL_*() macros.  TUNABLE_INT_DECL() was an odd name because it didn't
actually declare the int, which is what the name suggests it would do.
This commit is contained in:
Peter Wemm 2001-06-06 22:17:08 +00:00
parent 23d3a203ad
commit 81930014ef
14 changed files with 82 additions and 74 deletions

View File

@ -82,10 +82,12 @@ static int ad_version(u_int16_t);
/* internal vars */
static u_int32_t adp_lun_map = 0;
static MALLOC_DEFINE(M_AD, "AD driver", "ATA disk driver");
static int ata_dma, ata_wc, ata_tags;
TUNABLE_INT_DECL("hw.ata.ata_dma", 1, ata_dma);
TUNABLE_INT_DECL("hw.ata.wc", 0, ata_wc);
TUNABLE_INT_DECL("hw.ata.tags", 0, ata_tags);
static int ata_dma = 1;
static int ata_wc = 0;
static int ata_tags = 0;
TUNABLE_INT("hw.ata.ata_dma", &ata_dma);
TUNABLE_INT("hw.ata.wc", &ata_wc);
TUNABLE_INT("hw.ata.tags", &ata_tags);
/* sysctl vars */
SYSCTL_DECL(_hw_ata);

View File

@ -54,8 +54,8 @@ static char *atapi_skey2str(u_int8_t);
/* internal vars */
static MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer");
static int atapi_dma;
TUNABLE_INT_DECL("hw.ata.atapi_dma", 0, atapi_dma);
static int atapi_dma = 0;
TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma);
/* systcl vars */
SYSCTL_DECL(_hw_ata);

View File

@ -92,8 +92,8 @@ nomenclature:
static devclass_t pcm_devclass;
#ifdef USING_DEVFS
static int snd_unit;
TUNABLE_INT_DECL("hw.snd.unit", 0, snd_unit);
static int snd_unit = 0;
TUNABLE_INT("hw.snd.unit", &snd_unit);
#endif
SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver");

View File

@ -87,12 +87,12 @@ SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options");
int ktr_extend = KTR_EXTEND_DEFAULT;
SYSCTL_INT(_debug_ktr, OID_AUTO, extend, CTLFLAG_RD, &ktr_extend, 0, "");
int ktr_cpumask;
TUNABLE_INT_DECL("debug.ktr.cpumask", KTR_CPUMASK, ktr_cpumask);
int ktr_cpumask = KTR_CPUMASK;
TUNABLE_INT("debug.ktr.cpumask", &ktr_cpumask);
SYSCTL_INT(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, &ktr_cpumask, 0, "");
int ktr_mask;
TUNABLE_INT_DECL("debug.ktr.mask", KTR_MASK, ktr_mask);
int ktr_mask = KTR_MASK;
TUNABLE_INT("debug.ktr.mask", &ktr_mask);
SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RW, &ktr_mask, 0, "");
int ktr_entries = KTR_ENTRIES;
@ -101,8 +101,8 @@ SYSCTL_INT(_debug_ktr, OID_AUTO, entries, CTLFLAG_RD, &ktr_entries, 0, "");
volatile int ktr_idx = 0;
struct ktr_entry ktr_buf[KTR_ENTRIES];
int ktr_verbose;
TUNABLE_INT_DECL("debug.ktr.verbose", KTR_VERBOSE_DEFAULT, ktr_verbose);
int ktr_verbose = KTR_VERBOSE_DEFAULT;
TUNABLE_INT("debug.ktr.verbose", &ktr_verbose);
SYSCTL_INT(_debug_ktr, OID_AUTO, verbose, CTLFLAG_RW, &ktr_verbose, 0, "");
#ifdef KTR

View File

@ -1208,14 +1208,12 @@ SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0);
* character as a separator to be consistent with the bootloader.
*/
static char def_linker_path[] = "/boot/modules/;/modules/;/boot/kernel/";
static char linker_path[MAXPATHLEN] = "";
static char linker_path[MAXPATHLEN] = "/boot/modules/;/modules/;/boot/kernel/";
SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path,
sizeof(linker_path), "module load search path");
TUNABLE_STR_DECL("module_path", def_linker_path, linker_path,
sizeof(linker_path));
TUNABLE_STR("module_path", linker_path, sizeof(linker_path));
static char *linker_ext_list[] = {
".ko",

View File

@ -424,7 +424,6 @@ kmeminit(dummy)
register long indx;
u_long npg;
u_long mem_size;
u_long xvm_kmem_size;
#if ((MAXALLOCSAVE & (MAXALLOCSAVE - 1)) != 0)
#error "kmeminit: MAXALLOCSAVE not power of 2"
@ -450,21 +449,21 @@ kmeminit(dummy)
* Note that the kmem_map is also used by the zone allocator,
* so make sure that there is enough space.
*/
xvm_kmem_size = VM_KMEM_SIZE;
vm_kmem_size = VM_KMEM_SIZE;
mem_size = cnt.v_page_count * PAGE_SIZE;
#if defined(VM_KMEM_SIZE_SCALE)
if ((mem_size / VM_KMEM_SIZE_SCALE) > xvm_kmem_size)
xvm_kmem_size = mem_size / VM_KMEM_SIZE_SCALE;
if ((mem_size / VM_KMEM_SIZE_SCALE) > vm_kmem_size)
vm_kmem_size = mem_size / VM_KMEM_SIZE_SCALE;
#endif
#if defined(VM_KMEM_SIZE_MAX)
if (xvm_kmem_size >= VM_KMEM_SIZE_MAX)
xvm_kmem_size = VM_KMEM_SIZE_MAX;
if (vm_kmem_size >= VM_KMEM_SIZE_MAX)
vm_kmem_size = VM_KMEM_SIZE_MAX;
#endif
/* Allow final override from the kernel environment */
TUNABLE_INT_FETCH("kern.vm.kmem.size", xvm_kmem_size, vm_kmem_size);
TUNABLE_INT_FETCH("kern.vm.kmem.size", &vm_kmem_size);
/*
* Limit kmem virtual size to twice the physical memory.

View File

@ -144,8 +144,8 @@ static struct lock_instance *find_instance(struct lock_list_entry *lock_list,
MALLOC_DEFINE(M_WITNESS, "witness", "witness structure");
static int witness_watch;
TUNABLE_INT_DECL("debug.witness_watch", 1, witness_watch);
static int witness_watch = 1;
TUNABLE_INT("debug.witness_watch", &witness_watch);
SYSCTL_INT(_debug, OID_AUTO, witness_watch, CTLFLAG_RD, &witness_watch, 0, "");
#ifdef DDB
@ -155,21 +155,21 @@ SYSCTL_INT(_debug, OID_AUTO, witness_watch, CTLFLAG_RD, &witness_watch, 0, "");
* - a lock heirarchy violation occurs
* - locks are held when going to sleep.
*/
int witness_ddb;
#ifdef WITNESS_DDB
TUNABLE_INT_DECL("debug.witness_ddb", 1, witness_ddb);
int witness_ddb = 1;
#else
TUNABLE_INT_DECL("debug.witness_ddb", 0, witness_ddb);
int witness_ddb = 0;
#endif
TUNABLE_INT("debug.witness_ddb", &witness_ddb);
SYSCTL_INT(_debug, OID_AUTO, witness_ddb, CTLFLAG_RW, &witness_ddb, 0, "");
#endif /* DDB */
int witness_skipspin;
#ifdef WITNESS_SKIPSPIN
TUNABLE_INT_DECL("debug.witness_skipspin", 1, witness_skipspin);
int witness_skipspin = 1;
#else
TUNABLE_INT_DECL("debug.witness_skipspin", 0, witness_skipspin);
int witness_skipspin = 0;
#endif
TUNABLE_INT("debug.witness_skipspin", &witness_skipspin);
SYSCTL_INT(_debug, OID_AUTO, witness_skipspin, CTLFLAG_RD, &witness_skipspin, 0,
"");

View File

@ -51,6 +51,10 @@
#include <vm/vm_kern.h>
#include <vm/vm_extern.h>
#ifndef NMBCLUSTERS
#define NMBCLUSTERS (512 + MAXUSERS * 16)
#endif
static void mbinit(void *);
SYSINIT(mbuf, SI_SUB_MBUF, SI_ORDER_FIRST, mbinit, NULL)
@ -61,8 +65,8 @@ int max_linkhdr;
int max_protohdr;
int max_hdr;
int max_datalen;
int nmbclusters;
int nmbufs;
int nmbclusters = NMBCLUSTERS;
int nmbufs = NMBCLUSTERS * 4;
int nmbcnt;
u_long m_mballoc_wid = 0;
u_long m_clalloc_wid = 0;
@ -99,13 +103,9 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0,
SYSCTL_INT(_kern_ipc, OID_AUTO, nmbcnt, CTLFLAG_RD, &nmbcnt, 0,
"Maximum number of ext_buf counters available");
#ifndef NMBCLUSTERS
#define NMBCLUSTERS (512 + MAXUSERS * 16)
#endif
TUNABLE_INT_DECL("kern.ipc.nmbclusters", NMBCLUSTERS, nmbclusters);
TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs);
TUNABLE_INT_DECL("kern.ipc.nmbcnt", EXT_COUNTERS, nmbcnt);
TUNABLE_INT("kern.ipc.nmbclusters", &nmbclusters);
TUNABLE_INT("kern.ipc.nmbufs", &nmbufs);
TUNABLE_INT("kern.ipc.nmbcnt", &nmbcnt);
static void m_reclaim(void);
@ -126,6 +126,12 @@ mbinit(void *dummy)
vm_offset_t maxaddr;
vm_size_t mb_map_size;
/* Sanity checks and pre-initialization for non-constants */
if (nmbufs < nmbclusters * 2)
nmbufs = nmbclusters * 2;
if (nmbcnt == 0)
nmbcnt = EXT_COUNTERS;
/*
* Setup the mb_map, allocate requested VM space.
*/

View File

@ -1012,7 +1012,7 @@ SYSCTL_INT(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
*/
static void init_maxsockets(void *ignored)
{
TUNABLE_INT_FETCH("kern.ipc.maxsockets", 0, maxsockets);
maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets);
maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
}
SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL);

View File

@ -1012,7 +1012,7 @@ SYSCTL_INT(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
*/
static void init_maxsockets(void *ignored)
{
TUNABLE_INT_FETCH("kern.ipc.maxsockets", 0, maxsockets);
maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets);
maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
}
SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL);

View File

@ -101,7 +101,7 @@ int looutput __P((struct ifnet *ifp,
#define LOMTU 16384
#endif
static int nloop;
static int nloop = 1;
struct ifnet *loif; /* Used externally */
@ -179,7 +179,7 @@ loop_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
TUNABLE_INT_FETCH("net.nloop", 1, nloop);
TUNABLE_INT_FETCH("net.nloop", &nloop);
if (nloop < 1) /* sanity check */
nloop = 1;
for (i = 0; i < nloop; i++)

View File

@ -180,7 +180,7 @@ struct inp_tp {
void
tcp_init()
{
int hashsize;
int hashsize = TCBHASHSIZE;
tcp_ccgen = 1;
tcp_cleartaocache();
@ -194,7 +194,7 @@ tcp_init()
LIST_INIT(&tcb);
tcbinfo.listhead = &tcb;
TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", TCBHASHSIZE, hashsize);
TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize);
if (!powerof2(hashsize)) {
printf("WARNING: TCB hash size not a power of 2\n");
hashsize = 512; /* safe default */

View File

@ -180,7 +180,7 @@ struct inp_tp {
void
tcp_init()
{
int hashsize;
int hashsize = TCBHASHSIZE;
tcp_ccgen = 1;
tcp_cleartaocache();
@ -194,7 +194,7 @@ tcp_init()
LIST_INIT(&tcb);
tcbinfo.listhead = &tcb;
TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", TCBHASHSIZE, hashsize);
TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", &hashsize);
if (!powerof2(hashsize)) {
printf("WARNING: TCB hash size not a power of 2\n");
hashsize = 512; /* safe default */

View File

@ -43,7 +43,7 @@
*/
#ifndef _SYS_KERNEL_H_
#define _SYS_KERNEL_H_
#define _SYS_KERNEL_H_
#include <sys/linker_set.h>
@ -258,31 +258,34 @@ void sysinit_add __P((struct sysinit **set));
* in a SYSINIT function at SI_SUB_TUNABLES with SI_ORDER_LAST.
*/
#define TUNABLE_INT_DECL(path, defval, var) \
static void __Tunable_ ## var (void *ignored) \
{ \
TUNABLE_INT_FETCH((path), (defval), (var)) \
} \
SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ## var , NULL);
#define TUNABLE_INT_FETCH(path, defval, var) \
if (!getenv_int((path), &(var))) \
(var) = (defval);
#define TUNABLE_STR_DECL(path, defval, var, size) \
#define TUNABLE_INT(path, var) \
static void __Tunable_ ## var (void *ignored) \
{ \
TUNABLE_STR_FETCH((path), (defval), (var), (size)) \
TUNABLE_INT_FETCH((path), (var)); \
} \
SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ## var , NULL);
SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ## var , NULL)
#define TUNABLE_STR_FETCH(path, defval, var, size) \
char *tmp; \
tmp = getenv((path)); \
if (tmp == NULL) \
tmp = (defval); \
strncpy((var), tmp, (size)); \
(var)[(size) - 1] = 0;
#define TUNABLE_INT_FETCH(path, var) \
do { \
getenv_int((path), (var)); \
} while (0)
#define TUNABLE_STR(path, var, size) \
static void __Tunable_ ## var (void *ignored) \
{ \
TUNABLE_STR_FETCH((path), (var), (size)); \
} \
SYSINIT(__Tunable_init_ ## var, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, __Tunable_ ## var , NULL)
#define TUNABLE_STR_FETCH(path, var, size) \
do { \
char *tmp; \
tmp = getenv((path)); \
if (tmp != NULL) { \
strncpy((var), tmp, (size)); \
(var)[(size) - 1] = 0; \
} \
} while (0)
struct intr_config_hook {
TAILQ_ENTRY(intr_config_hook) ich_links;