diff --git a/include/haproxy/task-t.h b/include/haproxy/task-t.h index 3df4bf689..34d9a4565 100644 --- a/include/haproxy/task-t.h +++ b/include/haproxy/task-t.h @@ -127,6 +127,9 @@ struct task { struct tasklet { TASK_COMMON; /* must be at the beginning! */ struct list list; +#ifdef DEBUG_TASK + uint64_t call_date; /* date of the last tasklet wakeup or call */ +#endif int tid; /* TID of the tasklet owner, <0 if local */ }; diff --git a/include/haproxy/task.h b/include/haproxy/task.h index ce6418260..c717420f7 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -368,6 +368,8 @@ static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const char *f tl->debug.caller_idx = !tl->debug.caller_idx; tl->debug.caller_file[tl->debug.caller_idx] = file; tl->debug.caller_line[tl->debug.caller_idx] = line; + if (task_profiling_mask & tid_bit) + tl->call_date = now_mono_time(); #endif __tasklet_wakeup_on(tl, thr); } diff --git a/src/task.c b/src/task.c index 9249068ec..e33120fcf 100644 --- a/src/task.c +++ b/src/task.c @@ -505,6 +505,9 @@ unsigned int run_tasks_from_lists(unsigned int budgets[]) profile_entry = sched_activity_entry(sched_activity, t->process); before = now_mono_time(); +#ifdef DEBUG_TASK + HA_ATOMIC_ADD(&profile_entry->lat_time, before - ((struct tasklet *)t)->call_date); +#endif process(t, ctx, state); HA_ATOMIC_ADD(&profile_entry->calls, 1); HA_ATOMIC_ADD(&profile_entry->cpu_time, now_mono_time() - before);