CLEANUP: task: rename ->call_date to ->wake_date
This field is misnamed because its real and important content is the date the task was woken up, not the date it was called. It temporarily holds the call date during execution but this remains confusing. In fact before the latency measurements were possible it was indeed a call date. Thus is will now be called wake_date. This change is necessary because a subsequent fix will require the introduction of the real call date in the thread ctx. (cherry picked from commit 04e50b3d325fa35ce9557701513773a8a84e9230) Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
This commit is contained in:
parent
c432738cb0
commit
41f645a05a
@ -114,7 +114,7 @@ struct task {
|
||||
short nice; /* task prio from -1024 to +1024 */
|
||||
/* 16-bit hole here */
|
||||
unsigned long thread_mask; /* mask of thread IDs authorized to process the task */
|
||||
uint64_t call_date; /* date of the last task wakeup or call */
|
||||
uint64_t wake_date; /* date of the last task wakeup */
|
||||
uint64_t lat_time; /* total latency time experienced */
|
||||
uint64_t cpu_time; /* total CPU time consumed */
|
||||
};
|
||||
@ -128,7 +128,7 @@ struct tasklet {
|
||||
* list starts and this works because both are exclusive. Never ever
|
||||
* reorder these fields without taking this into account!
|
||||
*/
|
||||
uint32_t call_date; /* date of the last tasklet wakeup or call */
|
||||
uint32_t wake_date; /* date of the last tasklet wakeup */
|
||||
int tid; /* TID of the tasklet owner, <0 if local */
|
||||
};
|
||||
|
||||
|
@ -404,7 +404,7 @@ static inline void _tasklet_wakeup_on(struct tasklet *tl, int thr, const char *f
|
||||
tl->debug.caller_line[tl->debug.caller_idx] = line;
|
||||
#endif
|
||||
if (task_profiling_mask & tid_bit)
|
||||
tl->call_date = now_mono_time();
|
||||
tl->wake_date = now_mono_time();
|
||||
__tasklet_wakeup_on(tl, thr);
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ static inline void _task_instant_wakeup(struct task *t, unsigned int f, const ch
|
||||
t->debug.caller_line[t->debug.caller_idx] = line;
|
||||
#endif
|
||||
if (task_profiling_mask & tid_bit)
|
||||
t->call_date = now_mono_time();
|
||||
t->wake_date = now_mono_time();
|
||||
__tasklet_wakeup_on((struct tasklet *)t, thr);
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ static inline struct list *_tasklet_wakeup_after(struct list *head, struct taskl
|
||||
tl->debug.caller_line[tl->debug.caller_idx] = line;
|
||||
#endif
|
||||
if (th_ctx->flags & TH_FL_TASK_PROFILING)
|
||||
tl->call_date = now_mono_time();
|
||||
tl->wake_date = now_mono_time();
|
||||
return __tasklet_wakeup_after(head, tl);
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ static inline struct task *task_init(struct task *t, unsigned long thread_mask)
|
||||
t->state |= TASK_SHARED_WQ;
|
||||
t->nice = 0;
|
||||
t->calls = 0;
|
||||
t->call_date = 0;
|
||||
t->wake_date = 0;
|
||||
t->cpu_time = 0;
|
||||
t->lat_time = 0;
|
||||
t->expire = TICK_ETERNITY;
|
||||
@ -556,7 +556,7 @@ static inline void tasklet_init(struct tasklet *t)
|
||||
t->state = TASK_F_TASKLET;
|
||||
t->process = NULL;
|
||||
t->tid = -1;
|
||||
t->call_date = 0;
|
||||
t->wake_date = 0;
|
||||
#ifdef DEBUG_TASK
|
||||
t->debug.caller_idx = 0;
|
||||
#endif
|
||||
|
@ -878,8 +878,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
|
||||
while (rqnode) {
|
||||
t = eb32sc_entry(rqnode, struct task, rq);
|
||||
entry = sched_activity_entry(tmp_activity, t->process);
|
||||
if (t->call_date) {
|
||||
lat = now_ns - t->call_date;
|
||||
if (t->wake_date) {
|
||||
lat = now_ns - t->wake_date;
|
||||
if ((int64_t)lat > 0)
|
||||
entry->lat_time += lat;
|
||||
}
|
||||
@ -894,8 +894,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
|
||||
while (rqnode) {
|
||||
t = eb32sc_entry(rqnode, struct task, rq);
|
||||
entry = sched_activity_entry(tmp_activity, t->process);
|
||||
if (t->call_date) {
|
||||
lat = now_ns - t->call_date;
|
||||
if (t->wake_date) {
|
||||
lat = now_ns - t->wake_date;
|
||||
if ((int64_t)lat > 0)
|
||||
entry->lat_time += lat;
|
||||
}
|
||||
@ -907,8 +907,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
|
||||
list_for_each_entry(tl, mt_list_to_list(&ha_thread_ctx[thr].shared_tasklet_list), list) {
|
||||
t = (const struct task *)tl;
|
||||
entry = sched_activity_entry(tmp_activity, t->process);
|
||||
if (!TASK_IS_TASKLET(t) && t->call_date) {
|
||||
lat = now_ns - t->call_date;
|
||||
if (!TASK_IS_TASKLET(t) && t->wake_date) {
|
||||
lat = now_ns - t->wake_date;
|
||||
if ((int64_t)lat > 0)
|
||||
entry->lat_time += lat;
|
||||
}
|
||||
@ -920,8 +920,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
|
||||
list_for_each_entry(tl, &ha_thread_ctx[thr].tasklets[queue], list) {
|
||||
t = (const struct task *)tl;
|
||||
entry = sched_activity_entry(tmp_activity, t->process);
|
||||
if (!TASK_IS_TASKLET(t) && t->call_date) {
|
||||
lat = now_ns - t->call_date;
|
||||
if (!TASK_IS_TASKLET(t) && t->wake_date) {
|
||||
lat = now_ns - t->wake_date;
|
||||
if ((int64_t)lat > 0)
|
||||
entry->lat_time += lat;
|
||||
}
|
||||
|
@ -238,8 +238,8 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
|
||||
"%p (task) calls=%u last=%llu%s\n",
|
||||
task,
|
||||
task->calls,
|
||||
task->call_date ? (unsigned long long)(now_mono_time() - task->call_date) : 0,
|
||||
task->call_date ? " ns ago" : "");
|
||||
task->wake_date ? (unsigned long long)(now_mono_time() - task->wake_date) : 0,
|
||||
task->wake_date ? " ns ago" : "");
|
||||
|
||||
chunk_appendf(buf, "%s fct=%p(", pfx, task->process);
|
||||
resolve_sym_name(buf, NULL, task->process);
|
||||
|
20
src/task.c
20
src/task.c
@ -257,7 +257,7 @@ void __task_wakeup(struct task *t)
|
||||
}
|
||||
|
||||
if (task_profiling_mask & tid_bit)
|
||||
t->call_date = now_mono_time();
|
||||
t->wake_date = now_mono_time();
|
||||
|
||||
eb32sc_insert(root, &t->rq, t->thread_mask);
|
||||
|
||||
@ -604,9 +604,9 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||
profile_entry = sched_activity_entry(sched_activity, t->process);
|
||||
before = now_mono_time();
|
||||
|
||||
if (((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;
|
||||
if (((struct tasklet *)t)->wake_date) {
|
||||
HA_ATOMIC_ADD(&profile_entry->lat_time, (uint32_t)(before - ((struct tasklet *)t)->wake_date));
|
||||
((struct tasklet *)t)->wake_date = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,12 +658,12 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||
/* OK then this is a regular task */
|
||||
|
||||
_HA_ATOMIC_DEC(&ha_thread_ctx[tid].tasks_in_list);
|
||||
if (unlikely(t->call_date)) {
|
||||
if (unlikely(t->wake_date)) {
|
||||
uint64_t now_ns = now_mono_time();
|
||||
uint64_t lat = now_ns - t->call_date;
|
||||
uint64_t lat = now_ns - t->wake_date;
|
||||
|
||||
t->lat_time += lat;
|
||||
t->call_date = now_ns;
|
||||
t->wake_date = now_ns;
|
||||
profile_entry = sched_activity_entry(sched_activity, t->process);
|
||||
HA_ATOMIC_ADD(&profile_entry->lat_time, lat);
|
||||
HA_ATOMIC_INC(&profile_entry->calls);
|
||||
@ -696,11 +696,11 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
|
||||
* immediately, else we defer it into wait queue
|
||||
*/
|
||||
if (t != NULL) {
|
||||
if (unlikely(t->call_date)) {
|
||||
uint64_t cpu = now_mono_time() - t->call_date;
|
||||
if (unlikely(t->wake_date)) {
|
||||
uint64_t cpu = now_mono_time() - t->wake_date;
|
||||
|
||||
t->cpu_time += cpu;
|
||||
t->call_date = 0;
|
||||
t->wake_date = 0;
|
||||
HA_ATOMIC_ADD(&profile_entry->cpu_time, cpu);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user