]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sched: store the current profile entry in the thread context
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2022 14:16:39 +0000 (16:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Sep 2022 12:19:15 +0000 (14:19 +0200)
The profile entry that corresponds to the current task/tasklet being
profiled is now stored into the thread's context. This will allow it
to be accessed from the tasks themselves. This is needed for an upcoming
fix.

include/haproxy/tinfo-t.h
src/task.c

index 1555439023539d6c67f51d0838b4fdaccbd7cb8d..10fe7e98878b5f7a53b554c8b0d0bea832783bfd 100644 (file)
@@ -131,6 +131,7 @@ struct thread_ctx {
 
        uint32_t sched_wake_date;           /* current task/tasklet's wake date or 0 */
        uint32_t sched_call_date;           /* current task/tasklet's call date (valid if sched_wake_date > 0) */
+       struct sched_activity *sched_profile_entry; /* profile entry in use by the current task/tasklet, only if sched_wake_date>0 */
 
        uint64_t prev_cpu_time;             /* previous per thread CPU time */
        uint64_t prev_mono_time;            /* previous system wide monotonic time  */
index 5cebbbb0f7f211bf525f0541196d7677c01bc7e6..3d78680774fb3051085b7dc1893c46b0c4fafa0e 100644 (file)
@@ -575,6 +575,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
                                ((struct tasklet *)t)->wake_date = 0;
                                th_ctx->sched_call_date = now_ns;
                                profile_entry = sched_activity_entry(sched_activity, t->process);
+                               th_ctx->sched_profile_entry = profile_entry;
                                HA_ATOMIC_ADD(&profile_entry->lat_time, lat);
                                HA_ATOMIC_INC(&profile_entry->calls);
                        }
@@ -614,6 +615,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
                        t->wake_date = 0;
                        th_ctx->sched_call_date = now_ns;
                        profile_entry = sched_activity_entry(sched_activity, t->process);
+                       th_ctx->sched_profile_entry = profile_entry;
                        HA_ATOMIC_ADD(&profile_entry->lat_time, lat);
                        HA_ATOMIC_INC(&profile_entry->calls);
                }