Style 9 changes.
MFC after: 1 Month
This commit is contained in:
parent
109297af09
commit
2d0289e25f
@ -66,7 +66,7 @@ struct callout_run {
|
||||
|
||||
static struct callout_run *comaster[MAXCPU];
|
||||
|
||||
uint64_t callout_total=0;
|
||||
uint64_t callout_total = 0;
|
||||
|
||||
static void execute_the_co_test(struct callout_run *rn);
|
||||
|
||||
@ -74,18 +74,19 @@ static void
|
||||
co_saydone(void *arg)
|
||||
{
|
||||
struct callout_run *rn;
|
||||
|
||||
rn = (struct callout_run *)arg;
|
||||
printf("The callout test is now complete for thread %d\n",
|
||||
rn->index);
|
||||
rn->index);
|
||||
printf("number_callouts:%d\n",
|
||||
rn->co_number_callouts);
|
||||
rn->co_number_callouts);
|
||||
printf("Callouts that bailed (Not PENDING or ACTIVE cleared):%d\n",
|
||||
rn->co_return_npa);
|
||||
rn->co_return_npa);
|
||||
printf("Callouts that completed:%d\n", rn->co_completed);
|
||||
printf("Drain calls:%d\n", rn->drain_calls);
|
||||
printf("Zero returns:%d non-zero:%d\n",
|
||||
rn->cnt_zero,
|
||||
rn->cnt_one);
|
||||
rn->cnt_zero,
|
||||
rn->cnt_one);
|
||||
|
||||
}
|
||||
|
||||
@ -93,6 +94,7 @@ static void
|
||||
drainit(void *arg)
|
||||
{
|
||||
struct callout_run *rn;
|
||||
|
||||
rn = (struct callout_run *)arg;
|
||||
mtx_lock(&rn->lock);
|
||||
rn->drain_calls++;
|
||||
@ -104,7 +106,7 @@ test_callout(void *arg)
|
||||
{
|
||||
struct callout_run *rn;
|
||||
int cpu;
|
||||
|
||||
|
||||
critical_enter();
|
||||
cpu = curcpu;
|
||||
critical_exit();
|
||||
@ -120,7 +122,7 @@ test_callout(void *arg)
|
||||
}
|
||||
callout_deactivate(&rn->co_array[cpu]);
|
||||
rn->co_completed++;
|
||||
mtx_unlock(&rn->lock);
|
||||
mtx_unlock(&rn->lock);
|
||||
atomic_subtract_int(&rn->callout_waiting, 1);
|
||||
}
|
||||
|
||||
@ -132,16 +134,16 @@ execute_the_co_test(struct callout_run *rn)
|
||||
|
||||
mtx_lock(&rn->lock);
|
||||
rn->callout_waiting = 0;
|
||||
for(i=0; i<rn->co_number_callouts; i++) {
|
||||
for (i = 0; i < rn->co_number_callouts; i++) {
|
||||
if (rn->co_test == 1) {
|
||||
/* start all on spread out cpu's */
|
||||
cpu = i % mp_ncpus;
|
||||
callout_reset_sbt_on(&rn->co_array[i], 3, 0, test_callout, rn,
|
||||
cpu, 0);
|
||||
callout_reset_sbt_on(&rn->co_array[i], 3, 0, test_callout, rn,
|
||||
cpu, 0);
|
||||
} else {
|
||||
/* Start all on the same CPU */
|
||||
callout_reset_sbt_on(&rn->co_array[i], 3, 0, test_callout, rn,
|
||||
rn->index, 0);
|
||||
callout_reset_sbt_on(&rn->co_array[i], 3, 0, test_callout, rn,
|
||||
rn->index, 0);
|
||||
}
|
||||
}
|
||||
tk_s = ticks;
|
||||
@ -154,7 +156,7 @@ execute_the_co_test(struct callout_run *rn)
|
||||
}
|
||||
}
|
||||
/* OK everyone is waiting and we have the lock */
|
||||
for(i=0; i<rn->co_number_callouts; i++) {
|
||||
for (i = 0; i < rn->co_number_callouts; i++) {
|
||||
ret = callout_async_drain(&rn->co_array[i], drainit);
|
||||
if (ret) {
|
||||
rn->cnt_one++;
|
||||
@ -191,7 +193,7 @@ run_callout_test(struct kern_test *test)
|
||||
if (comaster[index] == NULL) {
|
||||
rn = comaster[index] = malloc(sizeof(struct callout_run), M_CALLTMP, M_WAITOK);
|
||||
memset(comaster[index], 0, sizeof(struct callout_run));
|
||||
mtx_init(&rn->lock, "callouttest", NULL, MTX_DUPOK);
|
||||
mtx_init(&rn->lock, "callouttest", NULL, MTX_DUPOK);
|
||||
rn->index = index;
|
||||
} else {
|
||||
rn = comaster[index];
|
||||
@ -207,19 +209,20 @@ run_callout_test(struct kern_test *test)
|
||||
rn->co_test = u->test_number;
|
||||
sz = sizeof(struct callout) * rn->co_number_callouts;
|
||||
rn->co_array = malloc(sz, M_CALLTMP, M_WAITOK);
|
||||
for(i=0; i<rn->co_number_callouts; i++) {
|
||||
for (i = 0; i < rn->co_number_callouts; i++) {
|
||||
callout_init(&rn->co_array[i], CALLOUT_MPSAFE);
|
||||
}
|
||||
execute_the_co_test(rn);
|
||||
}
|
||||
|
||||
int callout_test_is_loaded=0;
|
||||
int callout_test_is_loaded = 0;
|
||||
|
||||
static void
|
||||
cocleanup(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<MAXCPU; i++) {
|
||||
|
||||
for (i = 0; i < MAXCPU; i++) {
|
||||
if (comaster[i]) {
|
||||
if (comaster[i]->co_array) {
|
||||
free(comaster[i]->co_array, M_CALLTMP);
|
||||
@ -234,15 +237,15 @@ cocleanup(void)
|
||||
static int
|
||||
callout_test_modevent(module_t mod, int type, void *data)
|
||||
{
|
||||
int err=0;
|
||||
int err = 0;
|
||||
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
err = kern_testframework_register("callout_test",
|
||||
run_callout_test);
|
||||
run_callout_test);
|
||||
if (err) {
|
||||
printf("Can't load callout_test err:%d returned\n",
|
||||
err);
|
||||
err);
|
||||
} else {
|
||||
memset(comaster, 0, sizeof(comaster));
|
||||
callout_test_is_loaded = 1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*-
|
||||
* Copyright (c) 2015
|
||||
* Netflix Incorporated, All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -55,27 +55,28 @@ struct kern_test_list {
|
||||
kerntfunc func;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(ktestlist, kern_test_list);
|
||||
TAILQ_HEAD(ktestlist, kern_test_list);
|
||||
|
||||
struct kern_test_entry {
|
||||
TAILQ_ENTRY(kern_test_entry) next;
|
||||
struct kern_test_list *kt_e;
|
||||
struct kern_test kt_data;
|
||||
struct kern_test_list *kt_e;
|
||||
struct kern_test kt_data;
|
||||
};
|
||||
TAILQ_HEAD(ktestqueue, kern_test_entry);
|
||||
|
||||
TAILQ_HEAD(ktestqueue, kern_test_entry);
|
||||
|
||||
MALLOC_DEFINE(M_KTFRWK, "kern_tfrwk", "Kernel Test Framework");
|
||||
struct kern_totfrwk {
|
||||
struct taskqueue *kfrwk_tq;
|
||||
struct task kfrwk_que;
|
||||
struct ktestlist kfrwk_testlist;
|
||||
struct ktestqueue kfrwk_testq;
|
||||
struct mtx kfrwk_mtx;
|
||||
int kfrwk_waiting;
|
||||
struct taskqueue *kfrwk_tq;
|
||||
struct task kfrwk_que;
|
||||
struct ktestlist kfrwk_testlist;
|
||||
struct ktestqueue kfrwk_testq;
|
||||
struct mtx kfrwk_mtx;
|
||||
int kfrwk_waiting;
|
||||
};
|
||||
|
||||
struct kern_totfrwk kfrwk;
|
||||
static int ktest_frwk_inited=0;
|
||||
static int ktest_frwk_inited = 0;
|
||||
|
||||
#define KTFRWK_MUTEX_INIT() mtx_init(&kfrwk.kfrwk_mtx, "kern_test_frwk", "tfrwk", MTX_DEF)
|
||||
|
||||
@ -90,7 +91,7 @@ kfrwk_task(void *context, int pending)
|
||||
{
|
||||
struct kern_totfrwk *tf;
|
||||
struct kern_test_entry *wk;
|
||||
int free_mem=0;
|
||||
int free_mem = 0;
|
||||
struct kern_test kt_data;
|
||||
kerntfunc ktf;
|
||||
|
||||
@ -113,14 +114,14 @@ kfrwk_task(void *context, int pending)
|
||||
if (wk->kt_e) {
|
||||
ktf = wk->kt_e->func;
|
||||
}
|
||||
}
|
||||
}
|
||||
KTFRWK_UNLOCK();
|
||||
if (wk && free_mem) {
|
||||
free(wk, M_KTFRWK);
|
||||
}
|
||||
/* Execute the test */
|
||||
if (ktf){
|
||||
(*ktf)(&kt_data);
|
||||
if (ktf) {
|
||||
(*ktf) (&kt_data);
|
||||
}
|
||||
/* We are done */
|
||||
atomic_add_int(&tf->kfrwk_waiting, 1);
|
||||
@ -135,9 +136,9 @@ kerntest_frwk_init(void)
|
||||
TAILQ_INIT(&kfrwk.kfrwk_testq);
|
||||
TAILQ_INIT(&kfrwk.kfrwk_testlist);
|
||||
/* Now lets start up a number of tasks to do the work */
|
||||
TASK_INIT(&kfrwk.kfrwk_que, 0, kfrwk_task, &kfrwk);
|
||||
TASK_INIT(&kfrwk.kfrwk_que, 0, kfrwk_task, &kfrwk);
|
||||
kfrwk.kfrwk_tq = taskqueue_create_fast("sbtls_task", M_NOWAIT,
|
||||
taskqueue_thread_enqueue, &kfrwk.kfrwk_tq);
|
||||
taskqueue_thread_enqueue, &kfrwk.kfrwk_tq);
|
||||
if (kfrwk.kfrwk_tq == NULL) {
|
||||
printf("Can't start taskqueue for Kernel Test Framework\n");
|
||||
panic("Taskqueue init fails for kfrwk");
|
||||
@ -145,16 +146,16 @@ kerntest_frwk_init(void)
|
||||
taskqueue_start_threads(&kfrwk.kfrwk_tq, ncpus, PI_NET, "[kt_frwk task]");
|
||||
kfrwk.kfrwk_waiting = ncpus;
|
||||
ktest_frwk_inited = 1;
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
kerntest_frwk_fini(void)
|
||||
{
|
||||
KTFRWK_LOCK();
|
||||
KTFRWK_LOCK();
|
||||
if (!TAILQ_EMPTY(&kfrwk.kfrwk_testlist)) {
|
||||
/* Still modules registered */
|
||||
KTFRWK_UNLOCK();
|
||||
KTFRWK_UNLOCK();
|
||||
return (EBUSY);
|
||||
}
|
||||
ktest_frwk_inited = 0;
|
||||
@ -168,25 +169,25 @@ kerntest_frwk_fini(void)
|
||||
|
||||
static int kerntest_execute(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
SYSCTL_NODE(_kern, OID_AUTO, testfrwk, CTLFLAG_RW, 0, "Kernel Test Framework");
|
||||
SYSCTL_NODE(_kern, OID_AUTO, testfrwk, CTLFLAG_RW, 0, "Kernel Test Framework");
|
||||
SYSCTL_PROC(_kern_testfrwk, OID_AUTO, runtest, (CTLTYPE_STRUCT | CTLFLAG_RW),
|
||||
0, 0, kerntest_execute, "IU", "Execute a kernel test");
|
||||
0, 0, kerntest_execute, "IU", "Execute a kernel test");
|
||||
|
||||
int
|
||||
int
|
||||
kerntest_execute(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct kern_test kt;
|
||||
struct kern_test_list *li, *te=NULL;
|
||||
struct kern_test_entry *kte=NULL;
|
||||
struct kern_test_list *li, *te = NULL;
|
||||
struct kern_test_entry *kte = NULL;
|
||||
int error = 0;
|
||||
|
||||
if (ktest_frwk_inited == 0) {
|
||||
return(ENOENT);
|
||||
return (ENOENT);
|
||||
}
|
||||
/* Find the entry if possible */
|
||||
error = SYSCTL_IN(req, &kt, sizeof(struct kern_test));
|
||||
if (error) {
|
||||
return(error);
|
||||
return (error);
|
||||
}
|
||||
if (kt.num_threads <= 0) {
|
||||
return (EINVAL);
|
||||
@ -230,21 +231,21 @@ kerntest_execute(SYSCTL_HANDLER_ARGS)
|
||||
taskqueue_enqueue(kfrwk.kfrwk_tq, &kfrwk.kfrwk_que);
|
||||
out:
|
||||
KTFRWK_UNLOCK();
|
||||
return(error);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
kern_testframework_register(const char *name, kerntfunc func)
|
||||
{
|
||||
int error = 0;
|
||||
struct kern_test_list *li, *te=NULL;
|
||||
struct kern_test_list *li, *te = NULL;
|
||||
int len;
|
||||
|
||||
len = strlen(name);
|
||||
if (len >= TEST_NAME_LEN) {
|
||||
return (E2BIG);
|
||||
}
|
||||
te = malloc(sizeof(struct kern_test_list), M_KTFRWK, M_WAITOK);
|
||||
te = malloc(sizeof(struct kern_test_list), M_KTFRWK, M_WAITOK);
|
||||
if (te == NULL) {
|
||||
error = ENOMEM;
|
||||
goto out;
|
||||
@ -263,20 +264,20 @@ kern_testframework_register(const char *name, kerntfunc func)
|
||||
strcpy(te->name, name);
|
||||
TAILQ_INSERT_TAIL(&kfrwk.kfrwk_testlist, te, next);
|
||||
out:
|
||||
KTFRWK_UNLOCK();
|
||||
return(error);
|
||||
KTFRWK_UNLOCK();
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
kern_testframework_deregister(const char *name)
|
||||
{
|
||||
struct kern_test_list *li, *te=NULL;
|
||||
struct kern_test_list *li, *te = NULL;
|
||||
u_int ncpus = mp_ncpus ? mp_ncpus : MAXCPU;
|
||||
int error = 0;
|
||||
|
||||
KTFRWK_LOCK();
|
||||
/* First does it already exist? */
|
||||
TAILQ_FOREACH (li, &kfrwk.kfrwk_testlist, next) {
|
||||
TAILQ_FOREACH(li, &kfrwk.kfrwk_testlist, next) {
|
||||
if (strcmp(li->name, name) == 0) {
|
||||
te = li;
|
||||
break;
|
||||
@ -301,8 +302,8 @@ kern_testframework_deregister(const char *name)
|
||||
memset(te, 0, sizeof(struct kern_test_list));
|
||||
free(te, M_KTFRWK);
|
||||
out:
|
||||
KTFRWK_UNLOCK();
|
||||
return(error);
|
||||
KTFRWK_UNLOCK();
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -321,7 +322,7 @@ kerntest_mod_init(module_t mod, int type, void *data)
|
||||
} else {
|
||||
err = EBUSY;
|
||||
}
|
||||
KTFRWK_UNLOCK();
|
||||
KTFRWK_UNLOCK();
|
||||
break;
|
||||
case MOD_UNLOAD:
|
||||
err = kerntest_frwk_fini();
|
||||
|
Loading…
x
Reference in New Issue
Block a user