Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Reduce splat_taskq_test2_impl() stack frame size
Browse files Browse the repository at this point in the history
Slightly increasing the size of a kmutex_t has caused us to exceed
the stack frame warning size in splat_taskq_test2_impl().  To address
this the tq_args have been moved to the heap.

  cc1: warnings being treated as errors
  spl-0.6.3/module/splat/splat-taskq.c:358:
  error: the frame size of 1040 bytes is larger than 1024 bytes

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tim Chase <[email protected]>
Issue #435
  • Loading branch information
behlendorf committed Mar 3, 2015
1 parent d0d5dd7 commit 6ab0866
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions module/splat/splat-taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int
splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
taskq_t *tq[TEST2_TASKQS] = { NULL };
taskqid_t id;
splat_taskq_arg_t tq_args[TEST2_TASKQS];
splat_taskq_arg_t *tq_args[TEST2_TASKQS] = { NULL };
taskq_ent_t *func1_tqes = NULL;
taskq_ent_t *func2_tqes = NULL;
int i, rc = 0;
Expand All @@ -252,6 +252,12 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
taskq_init_ent(&func1_tqes[i]);
taskq_init_ent(&func2_tqes[i]);

tq_args[i] = kmalloc(sizeof (splat_taskq_arg_t), GFP_KERNEL);
if (tq_args[i] == NULL) {
rc = -ENOMEM;
break;
}

splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' creating (%s dispatch)\n",
SPLAT_TASKQ_TEST2_NAME, i,
Expand All @@ -267,50 +273,50 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
break;
}

tq_args[i].flag = i;
tq_args[i].id = i;
tq_args[i].file = file;
tq_args[i].name = SPLAT_TASKQ_TEST2_NAME;
tq_args[i]->flag = i;
tq_args[i]->id = i;
tq_args[i]->file = file;
tq_args[i]->name = SPLAT_TASKQ_TEST2_NAME;

splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' function '%s' dispatching\n",
tq_args[i].name, tq_args[i].id,
tq_args[i]->name, tq_args[i]->id,
sym2str(splat_taskq_test2_func1));
if (prealloc) {
taskq_dispatch_ent(tq[i], splat_taskq_test2_func1,
&tq_args[i], TQ_SLEEP, &func1_tqes[i]);
tq_args[i], TQ_SLEEP, &func1_tqes[i]);
id = func1_tqes[i].tqent_id;
} else {
id = taskq_dispatch(tq[i], splat_taskq_test2_func1,
&tq_args[i], TQ_SLEEP);
tq_args[i], TQ_SLEEP);
}

if (id == 0) {
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' function '%s' dispatch "
"failed\n", tq_args[i].name, tq_args[i].id,
"failed\n", tq_args[i]->name, tq_args[i]->id,
sym2str(splat_taskq_test2_func1));
rc = -EINVAL;
break;
}

splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' function '%s' dispatching\n",
tq_args[i].name, tq_args[i].id,
tq_args[i]->name, tq_args[i]->id,
sym2str(splat_taskq_test2_func2));
if (prealloc) {
taskq_dispatch_ent(tq[i], splat_taskq_test2_func2,
&tq_args[i], TQ_SLEEP, &func2_tqes[i]);
tq_args[i], TQ_SLEEP, &func2_tqes[i]);
id = func2_tqes[i].tqent_id;
} else {
id = taskq_dispatch(tq[i], splat_taskq_test2_func2,
&tq_args[i], TQ_SLEEP);
tq_args[i], TQ_SLEEP);
}

if (id == 0) {
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq "
"'%s/%d' function '%s' dispatch failed\n",
tq_args[i].name, tq_args[i].id,
tq_args[i]->name, tq_args[i]->id,
sym2str(splat_taskq_test2_func2));
rc = -EINVAL;
break;
Expand All @@ -320,31 +326,36 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) {
/* When rc is set we're effectively just doing cleanup here, so
* ignore new errors in that case. They just cause noise. */
for (i = 0; i < TEST2_TASKQS; i++) {
if (tq_args[i] == NULL)
continue;

if (tq[i] != NULL) {
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' waiting\n",
tq_args[i].name, tq_args[i].id);
tq_args[i]->name, tq_args[i]->id);
taskq_wait(tq[i]);
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d; destroying\n",
tq_args[i].name, tq_args[i].id);
tq_args[i]->name, tq_args[i]->id);

taskq_destroy(tq[i]);

if (!rc && tq_args[i].flag != ((i * 2) + 1)) {
if (!rc && tq_args[i]->flag != ((i * 2) + 1)) {
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' processed tasks "
"out of order; %d != %d\n",
tq_args[i].name, tq_args[i].id,
tq_args[i].flag, i * 2 + 1);
tq_args[i]->name, tq_args[i]->id,
tq_args[i]->flag, i * 2 + 1);
rc = -EINVAL;
} else {
splat_vprint(file, SPLAT_TASKQ_TEST2_NAME,
"Taskq '%s/%d' processed tasks "
"in the correct order; %d == %d\n",
tq_args[i].name, tq_args[i].id,
tq_args[i].flag, i * 2 + 1);
tq_args[i]->name, tq_args[i]->id,
tq_args[i]->flag, i * 2 + 1);
}

kfree(tq_args[i]);
}
}
out:
Expand Down

0 comments on commit 6ab0866

Please sign in to comment.