diff --git a/contrib/bpftrace/rt_all.bt b/contrib/bpftrace/rt_all.bt index bc362010a0a2f2..ca32999c282806 100755 --- a/contrib/bpftrace/rt_all.bt +++ b/contrib/bpftrace/rt_all.bt @@ -20,6 +20,11 @@ usdt:usr/lib/libjulia-internal.so:julia:rt__new__task printf("Task created: %x (Parent %x)\n", arg1, arg0); } +usdt:usr/lib/libjulia-internal.so:julia:rt__finish__task +{ + printf("Task finished: %x\n", arg0); +} + usdt:usr/lib/libjulia-internal.so:julia:rt__start__process__events { printf("Task processing libuv events: %x\n", arg0); diff --git a/doc/src/devdocs/probes.md b/doc/src/devdocs/probes.md index 6f51ddfa27112a..8452773db02860 100644 --- a/doc/src/devdocs/probes.md +++ b/doc/src/devdocs/probes.md @@ -99,8 +99,9 @@ the probe handler. 1. `julia:rt__run__task(task)`: Switching to task `task` on current thread. 2. `julia:rt__pause__task(task)`: Switching from task `task` on current thread. 3. `julia:rt__new__task(parent, child)`: Task `parent` created task `child` on current thread. -4. `julia:rt__start__process__events(task)`: Task `task` started processing libuv events. -5. `julia:rt__finish__process__events(task)`: Task `task` finished processing libuv events. +4. `julia:rt__finish__task(task)`: Task `task` finished and will no longer execute. +5. `julia:rt__start__process__events(task)`: Task `task` started processing libuv events. +6. `julia:rt__finish__process__events(task)`: Task `task` finished processing libuv events. ### Thread sleep/wake probes diff --git a/src/julia_internal.h b/src/julia_internal.h index 4a226c4db80667..2acc8b498b3ab7 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -1535,6 +1535,7 @@ uint16_t __gnu_f2h_ieee(float param) JL_NOTSAFEPOINT; #define JL_PROBE_RT_RUN_TASK(task) do ; while (0) #define JL_PROBE_RT_PAUSE_TASK(task) do ; while (0) #define JL_PROBE_RT_NEW_TASK(parent, child) do ; while (0) +#define JL_PROBE_RT_FINISH_TASK(task) do ; while (0) #define JL_PROBE_RT_START_PROCESS_EVENTS(task) do ; while (0) #define JL_PROBE_RT_FINISH_PROCESS_EVENTS(task) do ; while (0) #define JL_PROBE_RT_SLEEP_CHECK_WAKE(other, old_state) do ; while (0) @@ -1553,6 +1554,7 @@ uint16_t __gnu_f2h_ieee(float param) JL_NOTSAFEPOINT; #define JL_PROBE_GC_END_ENABLED() (0) #define JL_PROBE_GC_FINALIZER_ENABLED() (0) #define JL_PROBE_RT_RUN_TASK_ENABLED() (0) +#define JL_PROBE_RT_FINISH_TASK_ENABLED() (0) #define JL_PROBE_RT_PAUSE_TASK_ENABLED() (0) #define JL_PROBE_RT_NEW_TASK_ENABLED() (0) #define JL_PROBE_RT_START_PROCESS_EVENTS_ENABLED() (0) diff --git a/src/task.c b/src/task.c index ff6c484dedb607..0c7860b207cf51 100644 --- a/src/task.c +++ b/src/task.c @@ -409,6 +409,7 @@ static void ctx_switch(jl_task_t *lastt) // early free of stkbuf back to the pool jl_release_task_stack(ptls, lastt); } + JL_PROBE_RT_FINISH_TASK(lastt); } else { #ifdef COPY_STACKS diff --git a/src/uprobes.d b/src/uprobes.d index 07f98d74025c9d..ab698da04cee75 100644 --- a/src/uprobes.d +++ b/src/uprobes.d @@ -13,6 +13,7 @@ provider julia { probe rt__run__task(jl_task_t *task); probe rt__pause__task(jl_task_t *task); probe rt__new__task(jl_task_t *parent, jl_task_t *child); + probe rt__finish__task(jl_task_t *task); probe rt__start__process__events(jl_task_t *task); probe rt__finish__process__events(jl_task_t *task); probe rt__sleep__check__wake(jl_ptls_t other, int8_t old_state);