From: Willy Tarreau Date: Fri, 24 Nov 2023 15:45:34 +0000 (+0100) Subject: MINOR: task/profiling: do not record task_drop_running() as a caller X-Git-Tag: v2.9-dev12~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc800b6cb72b0b7800a7cae202e75d52eccfd432;p=thirdparty%2Fhaproxy.git MINOR: task/profiling: do not record task_drop_running() as a caller Task_drop_running() is used to remove the RUNNING bit and check if while the task was running it got a new wakeup from itself. Thus each time task_drop_running() marks itself as a caller, it in fact removes the previous caller that woke up the task, such as below: Tasks activity over 10.439 sec till 0.000 sec ago: function calls cpu_tot cpu_avg lat_tot lat_avg task_run_applet 57895273 6.396m 6.628us 2.733h 170.0us <- run_tasks_from_lists@src/task.c:658 task_drop_running Better not mark this function as a caller and keep the original one: Tasks activity over 13.834 sec till 0.000 sec ago: function calls cpu_tot cpu_avg lat_tot lat_avg task_run_applet 62424582 5.825m 5.599us 5.717h 329.7us <- sc_app_chk_rcv_applet@src/stconn.c:952 appctx_wakeup --- diff --git a/include/haproxy/task-t.h b/include/haproxy/task-t.h index 43f13e7b9c..ea52de9d1b 100644 --- a/include/haproxy/task-t.h +++ b/include/haproxy/task-t.h @@ -94,7 +94,6 @@ enum { WAKEUP_TYPE_TASK_INSTANT_WAKEUP, WAKEUP_TYPE_TASKLET_WAKEUP, WAKEUP_TYPE_TASKLET_WAKEUP_AFTER, - WAKEUP_TYPE_TASK_DROP_RUNNING, WAKEUP_TYPE_TASK_SCHEDULE, WAKEUP_TYPE_TASK_QUEUE, WAKEUP_TYPE_APPCTX_WAKEUP, diff --git a/include/haproxy/task.h b/include/haproxy/task.h index df9e4ff7c5..1c9c45f496 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -229,10 +229,7 @@ static inline void _task_wakeup(struct task *t, unsigned int f, const struct ha_ * that it's possible to unconditionally wakeup the task and drop the RUNNING * flag if needed. */ -#define task_drop_running(t, f) \ - _task_drop_running(t, f, MK_CALLER(WAKEUP_TYPE_TASK_DROP_RUNNING, 0, 0)) - -static inline void _task_drop_running(struct task *t, unsigned int f, const struct ha_caller *caller) +static inline void task_drop_running(struct task *t, unsigned int f) { unsigned int state, new_state; @@ -248,16 +245,8 @@ static inline void _task_drop_running(struct task *t, unsigned int f, const stru __ha_cpu_relax(); } - if ((new_state & ~state) & TASK_QUEUED) { - if (likely(caller)) { - caller = HA_ATOMIC_XCHG(&t->caller, caller); - BUG_ON((ulong)caller & 1); -#ifdef DEBUG_TASK - HA_ATOMIC_STORE(&t->debug.prev_caller, caller); -#endif - } + if ((new_state & ~state) & TASK_QUEUED) __task_wakeup(t); - } } /* @@ -755,7 +744,6 @@ static inline const char *task_wakeup_type_str(uint t) 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_TASK_QUEUE : return "task_queue"; case WAKEUP_TYPE_TASK_SCHEDULE : return "task_schedule"; case WAKEUP_TYPE_APPCTX_WAKEUP : return "appctx_wakeup";