From: Willy Tarreau Date: Tue, 6 Sep 2022 13:01:55 +0000 (+0200) Subject: DEBUG: task: define a series of wakeup types for tasks and tasklets X-Git-Tag: v2.7-dev6~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2b2ad902b6098ed0e0232d3bf7b5d940516b049;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/task-t.h b/include/haproxy/task-t.h index 373ac297c3..98661ed8a2 100644 --- a/include/haproxy/task-t.h +++ b/include/haproxy/task-t.h @@ -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. */ diff --git a/include/haproxy/task.h b/include/haproxy/task.h index a711c2740d..161d557558 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -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