]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sched: add TASK_F_WANTS_TIME to make the scheduler update the call date
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 15:27:46 +0000 (16:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Nov 2024 19:13:41 +0000 (20:13 +0100)
commitc5052bad8a2c745ecaf80dd6f4c237be07412ec2
treeba931693c6718508b43b65761ca27af75d7d9e1a
parent12969c1b1726857ffa274138c95500a337fb7bee
MINOR: sched: add TASK_F_WANTS_TIME to make the scheduler update the call date

Currently tasks being profiled have th_ctx->sched_call_date set to the
current nanosecond in monotonic time. But there's no other way to have
this, despite the scheduler being capable of it. Let's just declare a
new task flag, TASK_F_WANTS_TIME, that makes the scheduler take the time
just before calling the handler. This way, a task that needs nanosecond
resolution on the call date will be able to be called with an up-to-date
date without having to abuse now_mono_time() if not needed. In addition,
if CLOCK_MONOTONIC is not supported (now_mono_time() always returns 0),
the date is set to the most recently known now_ns, which is guaranteed
to be atomic and is only updated once per poll loop.

This date can be more conveniently retrieved using task_mono_time().

This can be useful, e.g. for pacing. The code was slightly adjusted so
as to merge the common parts between the profiling case and this one.
include/haproxy/task-t.h
include/haproxy/task.h
src/task.c