From 96c46ba2602bb998ad40f640b6a1178381cad878 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 10 Sep 2025 10:36:27 +0200 Subject: [PATCH] BUG/MINOR: activity: fix reporting of task latency 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. (cherry picked from commit 17d33923484ba5661f8938b55cc825b156766955) Signed-off-by: Christopher Faulet (cherry picked from commit 38233771977e142264a76b51c5d56068180d5fa2) Signed-off-by: Christopher Faulet (cherry picked from commit 885d50f802aa9b8c79eba8db1925cdb1ed4c3a01) Signed-off-by: Christopher Faulet --- src/activity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/activity.c b/src/activity.c index 13b3428..7ad8ac4 100644 --- a/src/activity.c +++ b/src/activity.c @@ -1329,7 +1329,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; } @@ -1346,7 +1346,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; } @@ -1359,7 +1359,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; } @@ -1372,7 +1372,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; } -- 1.7.10.4