Skip to content

Commit 95cec04

Browse files
keith-packardcarlescufi
authored andcommitted
kernel: When TLS, skip switched_out tracing hook from dummy thread
The dummy thread doesn't include a TLS area, so any thread local variables will fail to work if used in the switched_out tracing hook. Skip the hook in this case, as it's not really accurate anyways; the dummy thread is only used to set context for the initial switch for each core. Signed-off-by: Keith Packard <[email protected]>
1 parent b02d252 commit 95cec04

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/thread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,12 @@ void z_thread_mark_switched_out(void)
10581058
#endif
10591059

10601060
#ifdef CONFIG_TRACING
1061+
#ifdef CONFIG_THREAD_LOCAL_STORAGE
1062+
/* Dummy thread won't have TLS set up to run arbitrary code */
1063+
if (!_current_cpu->current ||
1064+
(_current_cpu->current->base.thread_state & _THREAD_DUMMY) != 0)
1065+
return;
1066+
#endif
10611067
SYS_PORT_TRACING_FUNC(k_thread, switched_out);
10621068
#endif
10631069
}

0 commit comments

Comments
 (0)