The sched_set_state tracepoint changed prototype adding a new argument, this argument can differentiate between an explicit set_state called by a task and a set state to runnable by the scheduler due to a pending signal. Expand the model to handle the new set_state flavour, the monitor was making sure set state happens only outside of the scheduler, if the event occurs with the new argument (from_signal) set to true, we instead expect it to be inside the scheduler. Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx> --- Documentation/trace/rv/monitor_sched.rst | 35 +++++++++++++----------- kernel/trace/rv/monitors/sco/sco.c | 5 +++- kernel/trace/rv/monitors/sco/sco.h | 4 +++ tools/verification/models/sched/sco.dot | 1 + 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Documentation/trace/rv/monitor_sched.rst b/Documentation/trace/rv/monitor_sched.rst index 24b2c62a3bc26..6f76bba94d9fb 100644 --- a/Documentation/trace/rv/monitor_sched.rst +++ b/Documentation/trace/rv/monitor_sched.rst @@ -64,22 +64,25 @@ Monitor sco ~~~~~~~~~~~ The scheduling context operations (sco) monitor ensures changes in a task state -happen only in thread context:: - - - | - | - v - sched_set_state +------------------+ - +------------------ | | - | | thread_context | - +-----------------> | | <+ - +------------------+ | - | | - | schedule_entry | schedule_exit - v | - | - scheduling_context -+ +happen only in thread context, the only exception is a special kind of set +state that occurs if a task about to sleep has a pending signal. This set state +is not called by the thread but by the scheduler itself:: + + | + | + v + sched_set_state +------------------+ + +---------------------------------- | | + | | thread_context | + +---------------------------------> | | <+ + +------------------+ | + | | + | schedule_entry | schedule_exit + v | + sched_set_state_runnable_signal | + +---------------------------------- | + | scheduling_context | + +---------------------------------> -+ Monitor snroc ~~~~~~~~~~~~~ diff --git a/kernel/trace/rv/monitors/sco/sco.c b/kernel/trace/rv/monitors/sco/sco.c index c9206aa12c319..6457ff2469d08 100644 --- a/kernel/trace/rv/monitors/sco/sco.c +++ b/kernel/trace/rv/monitors/sco/sco.c @@ -22,7 +22,10 @@ DECLARE_DA_MON_PER_CPU(sco, unsigned char); static void handle_sched_set_state(void *data, struct task_struct *tsk, int state, bool from_signal) { - da_handle_start_event_sco(sched_set_state_sco); + if (from_signal) + da_handle_event_sco(sched_set_state_runnable_signal_sco); + else + da_handle_start_event_sco(sched_set_state_sco); } static void handle_schedule_entry(void *data, bool preempt, unsigned long ip) diff --git a/kernel/trace/rv/monitors/sco/sco.h b/kernel/trace/rv/monitors/sco/sco.h index 83ca9a03331af..2d05ab882b2a6 100644 --- a/kernel/trace/rv/monitors/sco/sco.h +++ b/kernel/trace/rv/monitors/sco/sco.h @@ -15,6 +15,7 @@ enum states_sco { enum events_sco { sched_set_state_sco = 0, + sched_set_state_runnable_signal_sco, schedule_entry_sco, schedule_exit_sco, event_max_sco @@ -35,17 +36,20 @@ static const struct automaton_sco automaton_sco = { }, .event_names = { "sched_set_state", + "sched_set_state_runnable_signal", "schedule_entry", "schedule_exit" }, .function = { { thread_context_sco, + INVALID_STATE, scheduling_context_sco, INVALID_STATE }, { INVALID_STATE, + scheduling_context_sco, INVALID_STATE, thread_context_sco }, diff --git a/tools/verification/models/sched/sco.dot b/tools/verification/models/sched/sco.dot index 20b0e3b449a6b..4e44ed58c62a3 100644 --- a/tools/verification/models/sched/sco.dot +++ b/tools/verification/models/sched/sco.dot @@ -7,6 +7,7 @@ digraph state_automaton { {node [shape = plaintext] "thread_context"}; "__init_thread_context" -> "thread_context"; "scheduling_context" [label = "scheduling_context"]; + "scheduling_context" -> "scheduling_context" [ label = "sched_set_state_runnable_signal" ]; "scheduling_context" -> "thread_context" [ label = "schedule_exit" ]; "thread_context" [label = "thread_context", color = green3]; "thread_context" -> "scheduling_context" [ label = "schedule_entry" ]; -- 2.50.1