Page MenuHomeFreeBSD

smp_tune_scrubbed.c

Authored By
alfred
Nov 12 2014, 4:54 PM
Size
1 KB
Referenced Files
None
Subscribers
None

smp_tune_scrubbed.c

#include <sys/types.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/smp.h>
static const char *g_tunable = "hw.mycompany.num_queues";
#ifndef MY_MOD_NAME
#define MY_MOD_NAME "smp_tune"
#endif
static const char *my_mod_name = MY_MOD_NAME;
static int
smp_tune(void)
{
char intbuf[128];
int x, y;
x = mp_ncpus / 4;
y = imax(1, y);
sprintf(intbuf, "%d", y);
printf("%s: setenv(%s, %s)\n", my_mod_name, g_tunable, intbuf);
setenv(g_tunable, intbuf);
setenv("hw.ix.num_queues", intbuf);
setenv("hw.igb.num_queues", intbuf);
printf("%s: %s\n", my_mod_name, getenv(g_tunable));
return 0;
}
static int
smp_tune_modevent(module_t mod, int type, void *unused)
{
switch (type) {
case MOD_LOAD:
smp_tune();
return 0;
case MOD_UNLOAD:
return 0;
}
return EINVAL;
}
static moduledata_t smp_tune_mod = {
MY_MOD_NAME,
smp_tune_modevent,
0
};
DECLARE_MODULE(smp_tune, smp_tune_mod, SI_SUB_CPU, SI_ORDER_ANY /* LAST */);
MODULE_VERSION(smp_tune, 1);

File Metadata

Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
45445
Default Alt Text
smp_tune_scrubbed.c (1 KB)

Event Timeline