DEBUG: task: define a series of wakeup types for tasks and tasklets

The WAKEUP_* values will be used to report how a task/tasklet was woken
up, and task_wakeup_type_str() wlil report the associated function name.
This commit is contained in:
Willy Tarreau 2022-09-06 15:01:55 +02:00
parent d96d214b4c
commit d2b2ad902b
2 changed files with 29 additions and 1 deletions

View File

@ -61,6 +61,19 @@
#define TASK_PERSISTENT (TASK_SELF_WAKING | TASK_KILLED | \
TASK_HEAVY | TASK_F_TASKLET | TASK_F_USR1)
/* these wakeup types are used to indicate how a task/tasklet was woken up, for
* debugging purposes.
*/
enum {
WAKEUP_TYPE_UNSET = 0,
WAKEUP_TYPE_TASK_WAKEUP,
WAKEUP_TYPE_TASK_INSTANT_WAKEUP,
WAKEUP_TYPE_TASKLET_WAKEUP,
WAKEUP_TYPE_TASKLET_WAKEUP_AFTER,
WAKEUP_TYPE_TASK_DROP_RUNNING,
WAKEUP_TYPE_APPCTX_WAKEUP,
};
struct notification {
struct list purge_me; /* Part of the list of signals to be purged in the
case of the LUA execution stack crash. */

View File

@ -86,7 +86,6 @@
/* tasklets are recognized with nice==-32768 */
#define TASK_IS_TASKLET(t) ((t)->state & TASK_F_TASKLET)
/* a few exported variables */
extern struct pool_head *pool_head_task;
extern struct pool_head *pool_head_tasklet;
@ -677,6 +676,22 @@ static inline void task_schedule(struct task *task, int when)
}
}
/* returns the string corresponding to a task type as found in the task caller
* locations.
*/
static inline const char *task_wakeup_type_str(uint t)
{
switch (t) {
case WAKEUP_TYPE_TASK_WAKEUP : return "task_wakeup";
case WAKEUP_TYPE_TASK_INSTANT_WAKEUP : return "task_instant_wakeup";
case WAKEUP_TYPE_TASKLET_WAKEUP : return "tasklet_wakeup";
case WAKEUP_TYPE_TASKLET_WAKEUP_AFTER : return "tasklet_wakeup_after";
case WAKEUP_TYPE_TASK_DROP_RUNNING : return "task_drop_running";
case WAKEUP_TYPE_APPCTX_WAKEUP : return "appctx_wakeup";
default : return "?";
}
}
/* This function register a new signal. "lua" is the current lua
* execution context. It contains a pointer to the associated task.
* "link" is a list head attached to an other task that must be wake