]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: task: define a series of wakeup types for tasks and tasklets
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Sep 2022 13:01:55 +0000 (15:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Sep 2022 12:30:16 +0000 (14:30 +0200)
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.

include/haproxy/task-t.h
include/haproxy/task.h

index 373ac297c306b59900fe31af4994acedc5c706b0..98661ed8a279bf512aad5f0afcd00cd45d067506 100644 (file)
 #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. */
index a711c2740d756e636b2e12fa9d79558254b6799b..161d5575580bc3369e15ab2ef1980eaf26cae7ae 100644 (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