diff --git a/include/haproxy/task-t.h b/include/haproxy/task-t.h index f481364de..db3a5f827 100644 --- a/include/haproxy/task-t.h +++ b/include/haproxy/task-t.h @@ -126,9 +126,7 @@ struct tasklet { * list starts and this works because both are exclusive. Never ever * reorder these fields without taking this into account! */ -#ifdef DEBUG_TASK - uint64_t call_date; /* date of the last tasklet wakeup or call */ -#endif + uint32_t call_date; /* date of the last tasklet wakeup or call */ int tid; /* TID of the tasklet owner, <0 if local */ }; diff --git a/include/haproxy/task.h b/include/haproxy/task.h index 7a58e3ed9..34646130d 100644 --- a/include/haproxy/task.h +++ b/include/haproxy/task.h @@ -359,9 +359,9 @@ 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; +#endif if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING) tl->call_date = now_mono_time(); -#endif __tasklet_wakeup_on(tl, thr); } @@ -446,9 +446,9 @@ static inline struct list *_tasklet_wakeup_after(struct list *head, struct taskl 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; +#endif if (th_ctx->flags & TH_FL_TASK_PROFILING) tl->call_date = now_mono_time(); -#endif return __tasklet_wakeup_after(head, tl); } @@ -517,8 +517,8 @@ static inline void tasklet_init(struct tasklet *t) t->state = TASK_F_TASKLET; t->process = NULL; t->tid = -1; -#ifdef DEBUG_TASK t->call_date = 0; +#ifdef DEBUG_TASK t->debug.caller_idx = 0; #endif LIST_INIT(&t->list); diff --git a/src/task.c b/src/task.c index 0399a7110..395bc9ac4 100644 --- a/src/task.c +++ b/src/task.c @@ -572,12 +572,11 @@ unsigned int run_tasks_from_lists(unsigned int budgets[]) if (unlikely(_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)) { profile_entry = sched_activity_entry(sched_activity, t->process); before = now_mono_time(); -#ifdef DEBUG_TASK + if (((struct tasklet *)t)->call_date) { - HA_ATOMIC_ADD(&profile_entry->lat_time, before - ((struct tasklet *)t)->call_date); + HA_ATOMIC_ADD(&profile_entry->lat_time, (uint32_t)(before - ((struct tasklet *)t)->call_date)); ((struct tasklet *)t)->call_date = 0; } -#endif } state = _HA_ATOMIC_FETCH_AND(&t->state, TASK_PERSISTENT);