MINOR: debug: remove mask support from "debug dev sched"

The thread mask will not be used anymore, instead the thread id only
is used. Interestingly it was already implemented in the parsing but
not used. The single/multi thread argument is not needed anymore since
it's sufficient to pass tid<0 to get a multi-threaded task/tasklet.

This is in preparation for the removal of the thread_mask in tasks as
only this debug code was using it!
This commit is contained in:
Willy Tarreau 2022-06-15 16:32:41 +02:00
parent 66ef2c3af6
commit 8e5c53a6c9

View File

@ -868,24 +868,21 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
char *endarg;
unsigned long long new;
unsigned long count = 0;
unsigned long thrid = 0;
unsigned long thrid = tid;
unsigned int inter = 0;
unsigned long mask, tmask;
unsigned long i;
int mode = 0; // 0 = tasklet; 1 = task
int single = 0;
unsigned long *tctx; // [0] = #tasks, [1] = inter, [2+] = { tl | (tsk+1) }
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
return 1;
ptr = NULL; size = 0;
mask = all_threads_mask;
if (strcmp(args[3], "task") != 0 && strcmp(args[3], "tasklet") != 0) {
return cli_err(appctx,
"Usage: debug dev sched {task|tasklet} { <obj> = <value> }*\n"
" <obj> = {count | mask | inter | single }\n"
" <obj> = {count | tid | inter }\n"
" <value> = 64-bit dec/hex integer (0x prefix supported)\n"
);
}
@ -900,14 +897,10 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
name = ist2(word, end - word);
if (isteq(name, ist("count"))) {
ptr = &count; size = sizeof(count);
} else if (isteq(name, ist("mask"))) {
ptr = &mask; size = sizeof(mask);
} else if (isteq(name, ist("tid"))) {
ptr = &thrid; size = sizeof(thrid);
} else if (isteq(name, ist("inter"))) {
ptr = &inter; size = sizeof(inter);
} else if (isteq(name, ist("single"))) {
ptr = &single; size = sizeof(single);
} else
return cli_dynerr(appctx, memprintf(&msg, "Unsupported setting: '%s'.\n", word));
@ -938,25 +931,10 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
tctx[0] = (unsigned long)count;
tctx[1] = (unsigned long)inter;
mask &= all_threads_mask;
if (!mask)
mask = tid_bit;
if (thrid >= global.nbthread)
thrid = tid;
tmask = 0;
for (i = 0; i < count; i++) {
if (single || mode == 0) {
/* look for next bit matching a bit in mask or loop back to zero */
for (tmask <<= 1; !(mask & tmask); ) {
if (!(mask & -tmask))
tmask = 1;
else
tmask <<= 1;
}
} else {
/* multi-threaded task */
tmask = mask;
}
/* now, if poly or mask was set, tmask corresponds to the
* valid thread mask to use, otherwise it remains zero.
*/
@ -967,13 +945,12 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
if (!tl)
goto fail;
if (tmask)
tl->tid = my_ffsl(tmask) - 1;
tl->tid = thrid;
tl->process = debug_tasklet_handler;
tl->context = tctx;
tctx[i + 2] = (unsigned long)tl;
} else {
struct task *task = task_new(tmask ? tmask : tid_bit);
struct task *task = task_new_on(thrid);
if (!task)
goto fail;