]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: task: rename ->call_date to ->wake_date
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2022 12:49:50 +0000 (14:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Sep 2022 12:19:15 +0000 (14:19 +0200)
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.

include/haproxy/task-t.h
include/haproxy/task.h
src/activity.c
src/debug.c
src/task.c

index db3a5f827b0d2768b3429e625d0476dfe4523fcd..0014323159823252eecb26e41a259dd2be04c6bd 100644 (file)
@@ -112,7 +112,7 @@ struct task {
        int expire;                     /* next expiration date for this task, in ticks */
        short nice;                     /* task prio from -1024 to +1024 */
        short tid;                      /* TID where it's allowed to run, <0 if anywhere */
-       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 */
 };
@@ -126,7 +126,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 */
 };
 
index 34646130dfecbee4e52f695636547ad36868a2bc..33be63f0c279caea9cc8d072534ed576ab7ed382 100644 (file)
@@ -361,7 +361,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 (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
-               tl->call_date = now_mono_time();
+               tl->wake_date = now_mono_time();
        __tasklet_wakeup_on(tl, thr);
 }
 
@@ -414,7 +414,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 (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
-               t->call_date = now_mono_time();
+               t->wake_date = now_mono_time();
        __tasklet_wakeup_on((struct tasklet *)t, thr);
 }
 
@@ -448,7 +448,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);
 }
 
@@ -497,7 +497,7 @@ static inline struct task *task_init(struct task *t, int tid)
        t->tid = tid;
        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;
@@ -517,7 +517,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
index 41beb4d81f69449743ad864a0b054af3f67a08ba..627593d593f6434afd7bccc445a25e7c5bd620a1 100644 (file)
@@ -855,8 +855,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                while (rqnode) {
                        t = eb32_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;
                        }
@@ -872,8 +872,8 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                while (rqnode) {
                        t = eb32_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;
                        }
@@ -885,8 +885,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;
                        }
@@ -898,8 +898,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;
                                }
index 090b82c40402cefc2fd1f8634096be915a446c87..8e2ca42f57bccf93f7d439485cb95b22872318c8 100644 (file)
@@ -256,8 +256,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);
index 395bc9ac47763515bb1f3e2f219138105be50814..44aac72627d6d378ca24f6ff530aee7ec4a2e2c4 100644 (file)
@@ -233,7 +233,7 @@ void __task_wakeup(struct task *t)
        }
 
        if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_TASK_PROFILING)
-               t->call_date = now_mono_time();
+               t->wake_date = now_mono_time();
 
        eb32_insert(root, &t->rq);
 
@@ -573,9 +573,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;
                                }
                        }
 
@@ -627,12 +627,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);
@@ -665,11 +665,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);
                        }