]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: activity: fix reporting of task latency
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 08:36:27 +0000 (10:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 08:44:33 +0000 (10:44 +0200)
In 2.4, "show tasks" was introduced by commit 7eff06e162 ("MINOR:
activity: add a new "show tasks" command to list currently active tasks")
to expose some info about running tasks. The latency is not correct
because it's a u32 subtracted from a u64. It ought to have been casted
to u32 for the operation, which is what this patch does.

This can be backported to 2.4.

src/activity.c

index 51fea7e408d78d4f6b3df801effbf910b5bb278c..8a306063a099b7d517440def8ffcb54d925ea298 100644 (file)
@@ -1327,7 +1327,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                        t = eb32_entry(rqnode, struct task, rq);
                        entry = sched_activity_entry(tmp_activity, t->process, NULL);
                        if (t->wake_date) {
-                               lat = now_ns - t->wake_date;
+                               lat = (uint32_t)now_ns - t->wake_date;
                                if ((int64_t)lat > 0)
                                        entry->lat_time += lat;
                        }
@@ -1344,7 +1344,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                        t = eb32_entry(rqnode, struct task, rq);
                        entry = sched_activity_entry(tmp_activity, t->process, NULL);
                        if (t->wake_date) {
-                               lat = now_ns - t->wake_date;
+                               lat = (uint32_t)now_ns - t->wake_date;
                                if ((int64_t)lat > 0)
                                        entry->lat_time += lat;
                        }
@@ -1357,7 +1357,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                        t = (const struct task *)tl;
                        entry = sched_activity_entry(tmp_activity, t->process, NULL);
                        if (!TASK_IS_TASKLET(t) && t->wake_date) {
-                               lat = now_ns - t->wake_date;
+                               lat = (uint32_t)now_ns - t->wake_date;
                                if ((int64_t)lat > 0)
                                        entry->lat_time += lat;
                        }
@@ -1370,7 +1370,7 @@ static int cli_io_handler_show_tasks(struct appctx *appctx)
                                t = (const struct task *)tl;
                                entry = sched_activity_entry(tmp_activity, t->process, NULL);
                                if (!TASK_IS_TASKLET(t) && t->wake_date) {
-                                       lat = now_ns - t->wake_date;
+                                       lat = (uint32_t)now_ns - t->wake_date;
                                        if ((int64_t)lat > 0)
                                                entry->lat_time += lat;
                                }