Add Hybrid Automata monitor type, per-object and deadline monitors
Subsystems (4)
Gabriele Monaco
maintainerv3 cover Add Hybrid Automata monitor type, per-object and deadline monitors
This series contains several related changes, the main areas are:
* hybrid automata
Hybrid automata are an extension of deterministic automata where each state transition is validating a constraint on a finite number of environment variables.
Hybrid automata can be used to implement timed automata, where the environment variables are clocks.
* per-object monitors
Define the generic per-object monitor allow RV monitors on any kind of object where the user can specify how to get an id (e.g. pid for tasks) and the data type for the monitor_target (e.g. struct task_struct * for tasks).
The monitor storage (e.g. the rv monitor, pointer to the target, etc.) is stored in a hash table indexed by id.
* deadline monitors collection
Add the throttle and nomiss monitors to validate timing aspects of the deadline scheduler, as they work for tasks and servers, their inclusion requires also per-object monitors (for dl entities). Also add the boost and laxity monitors specific to servers.
This series is based on the previously sent [1] that includes preliminary patches present in V2 [2] and already reviewed. As such this series is simplified and includes only relevant new changes.
The entire series can also be found on:
git.kernel.org/pub/scm/linux/kernel/git/gmonaco/linux.git rv_hybrid_automata
Changes since V2 [2]:
* Adapt models to new dl server behaviour
* Rearrange start/handle helpers to share more code
* Improve documentation clarity after review
* Extend stall model to handle preemption
* Improve functions naming for HA helpers
* Use kmalloc_nolock for per-obj storage allocation
* Add boost and laxity monitors for deadline servers
* Add _is_id_monitor() in dot2k to handle per-obj together with per-task
* Rename dl argument to dl_se in tracepoints
* Use __COUNTER__ in dl monitor syscall helpers
* Fix conflicts after rebase (cond_react -> rv_react)
* General cleanup
Changes since V1 [3]:
* Cleanup unused trace events definitions
* Improve hybrid automata description about use of timers
* Unify event handler internals across DA monitor types
* Implement timer wheel alternative for invariants
* Extend models to consider timing of task switches (in before deadline, out after throttle)
* Refactor tracepoints and per-object monitors to allow server events from remote CPUs
* Changed clock representation in case of invariants (time to expire vs time since reset) and allow conversion without reset
* Extend dot2k to understand the graph relations and suggest where invariant conversions are needed
* General cleanup of rvgen scripts
[1] - https://lore.kernel.org/lkml/[email protected]
[2] - https://lore.kernel.org/lkml/[email protected]
[3] - https://lore.kernel.org/lkml/[email protected]
To: Steven Rostedt <[email protected]>
To: Nam Cao <[email protected]>
Cc: Tomas Glozar <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Clark Williams <[email protected]>
Cc: John Kacur <[email protected]>
Cc: [email protected]
Gabriele Monaco (13):
rv: Unify DA event handling functions across monitor types
rv: Add Hybrid Automata monitor type verification/rvgen: Allow spaces in and events strings verification/rvgen: Add support for Hybrid Automata Documentation/rv: Add documentation about hybrid automata
rv: Add sample hybrid monitors stall
rv: Convert the opid monitor to a hybrid automaton
sched: Export hidden tracepoints to modules
sched: Add deadline tracepoints
rv: Add support for per-object monitors in DA/HA verification/rvgen: Add support for per-obj monitors
rv: Add deadline monitors
rv: Add dl_server specific monitors
Documentation/tools/rv/index.rst | 1 + Documentation/tools/rv/rv-mon-stall.rst | 44 ++ .../trace/rv/deterministic_automata.rst | 2 +- Documentation/trace/rv/hybrid_automata.rst | 341 +++++++++ Documentation/trace/rv/index.rst | 3 + Documentation/trace/rv/monitor_deadline.rst | 266 +++++++ Documentation/trace/rv/monitor_sched.rst | 62 +- Documentation/trace/rv/monitor_stall.rst | 43 ++ Documentation/trace/rv/monitor_synthesis.rst | 117 +++- include/linux/rv.h | 39 ++ include/rv/da_monitor.h | 654 +++++++++++++----- include/rv/ha_monitor.h | 479 +++++++++++++ include/trace/events/sched.h | 16 + kernel/sched/core.c | 7 + kernel/sched/deadline.c | 7 + kernel/trace/rv/Kconfig | 21 + kernel/trace/rv/Makefile | 6 + kernel/trace/rv/monitors/boost/Kconfig | 15 + kernel/trace/rv/monitors/boost/boost.c | 279 ++++++++ kernel/trace/rv/monitors/boost/boost.h | 159 +++++ kernel/trace/rv/monitors/boost/boost_trace.h | 19 + kernel/trace/rv/monitors/deadline/Kconfig | 10 + kernel/trace/rv/monitors/deadline/deadline.c | 35 + kernel/trace/rv/monitors/deadline/deadline.h | 203 ++++++ kernel/trace/rv/monitors/laxity/Kconfig | 14 + kernel/trace/rv/monitors/laxity/laxity.c | 226 ++++++ kernel/trace/rv/monitors/laxity/laxity.h | 126 ++++ .../trace/rv/monitors/laxity/laxity_trace.h | 19 + kernel/trace/rv/monitors/nomiss/Kconfig | 15 + kernel/trace/rv/monitors/nomiss/nomiss.c | 289 ++++++++ kernel/trace/rv/monitors/nomiss/nomiss.h | 137 ++++ .../trace/rv/monitors/nomiss/nomiss_trace.h | 19 + kernel/trace/rv/monitors/opid/Kconfig | 11 +- kernel/trace/rv/monitors/opid/opid.c | 111 +-- kernel/trace/rv/monitors/opid/opid.h | 86 +-- kernel/trace/rv/monitors/opid/opid_trace.h | 4 + kernel/trace/rv/monitors/stall/Kconfig | 13 + kernel/trace/rv/monitors/stall/stall.c | 150 ++++ kernel/trace/rv/monitors/stall/stall.h | 81 +++ kernel/trace/rv/monitors/stall/stall_trace.h | 19 + kernel/trace/rv/monitors/throttle/Kconfig | 15 + kernel/trace/rv/monitors/throttle/throttle.c | 248 +++++++ kernel/trace/rv/monitors/throttle/throttle.h | 116 ++++ .../rv/monitors/throttle/throttle_trace.h | 19 + kernel/trace/rv/rv_trace.h | 70 +- tools/verification/models/deadline/boost.dot | 51 ++ tools/verification/models/deadline/laxity.dot | 34 + tools/verification/models/deadline/nomiss.dot | 43 ++ .../verification/models/deadline/throttle.dot | 44 ++ tools/verification/models/sched/opid.dot | 36 +- tools/verification/models/stall.dot | 22 + tools/verification/rvgen/__main__.py | 8 +- tools/verification/rvgen/rvgen/automata.py | 150 +++- tools/verification/rvgen/rvgen/dot2c.py | 49 ++ tools/verification/rvgen/rvgen/dot2k.py | 488 ++++++++++++- tools/verification/rvgen/rvgen/generator.py | 4 +- .../rvgen/rvgen/templates/dot2k/main.c | 2 +- .../rvgen/templates/dot2k/trace_hybrid.h | 16 + 58 files changed, 5138 insertions(+), 425 deletions(-) create mode 100644 Documentation/tools/rv/rv-mon-stall.rst create mode 100644 Documentation/trace/rv/hybrid_automata.rst create mode 100644 Documentation/trace/rv/monitor_deadline.rst create mode 100644 Documentation/trace/rv/monitor_stall.rst create mode 100644 include/rv/ha_monitor.h create mode 100644 kernel/trace/rv/monitors/boost/Kconfig create mode 100644 kernel/trace/rv/monitors/boost/boost.c create mode 100644 kernel/trace/rv/monitors/boost/boost.h create mode 100644 kernel/trace/rv/monitors/boost/boost_trace.h create mode 100644 kernel/trace/rv/monitors/deadline/Kconfig create mode 100644 kernel/trace/rv/monitors/deadline/deadline.c create mode 100644 kernel/trace/rv/monitors/deadline/deadline.h create mode 100644 kernel/trace/rv/monitors/laxity/Kconfig create mode 100644 kernel/trace/rv/monitors/laxity/laxity.c create mode 100644 kernel/trace/rv/monitors/laxity/laxity.h create mode 100644 kernel/trace/rv/monitors/laxity/laxity_trace.h create mode 100644 kernel/trace/rv/monitors/nomiss/Kconfig create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss.c create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss.h create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss_trace.h create mode 100644 kernel/trace/rv/monitors/stall/Kconfig create mode 100644 kernel/trace/rv/monitors/stall/stall.c create mode 100644 kernel/trace/rv/monitors/stall/stall.h create mode 100644 kernel/trace/rv/monitors/stall/stall_trace.h create mode 100644 kernel/trace/rv/monitors/throttle/Kconfig create mode 100644 kernel/trace/rv/monitors/throttle/throttle.c create mode 100644 kernel/trace/rv/monitors/throttle/throttle.h create mode 100644 kernel/trace/rv/monitors/throttle/throttle_trace.h create mode 100644 tools/verification/models/deadline/boost.dot create mode 100644 tools/verification/models/deadline/laxity.dot create mode 100644 tools/verification/models/deadline/nomiss.dot create mode 100644 tools/verification/models/deadline/throttle.dot create mode 100644 tools/verification/models/stall.dot create mode 100644 tools/verification/rvgen/rvgen/templates/dot2k/trace_hybrid.h
base-commit: ce91eea7c90fe4ec76c071f6d3cc14e1ce049b30
Signature · 1 line
2.52.0
Gabriele Monaco
maintainerPATCH v3 1/13 Unify DA event handling functions across monitor types
The DA event handling functions are mostly duplicated because the per-task monitors need to propagate the task to use the pid in the trace events. This is a maintenance burden for a little advantage. The task can be obtained with some pointer arithmetic from the da_mon, hence only the function tracing events really need to differ.
Unify all code handling the events, create da_trace_event() and da_trace_error() that only call the tracepoint function. Propagate the monitor id through the calls, the do_trace_ functions use the id (pid) in case of per-task monitors but ignore it for implicit monitors.
---
Notes:
V3:
* Rearrange start/handle helpers to share more code
include/rv/da_monitor.h | 303 +++++++++++++++++----------------------- 1 file changed, 132 insertions(+), 171 deletions(-)
include/rv/da_monitor.h +132 -171
@@ -22,6 +22,13 @@static struct rv_monitor rv_this; +/* +* Type for the target id, default to int but can be overridden. +*/ +#ifndef da_id_type +#define da_id_type int +#endif +static void react (enum states curr_state,enum events event) { rv_react(&rv_this,
@@ -91,90 +98,6 @@ static inline bool da_monitor_handling_event(struct da_monitor *da_mon)return 1 ; } -#if RV_MON_TYPE ==RV_MON_GLOBAL ||RV_MON_TYPE ==RV_MON_PER_CPU -/* -* Event handler for implicit monitors. Implicit monitor is the one which the -* handler does not need to specify which da_monitor to manipulate. Examples -* of implicit monitor are the per_cpu or the global ones. -* -* Retry in case there is a race between getting and setting the next state, -* warn and reset the monitor if it runs out of retries. The monitor should be -* able to handle various orders. -*/ - -static inline bool da_event (struct da_monitor *da_mon,enum events event) -{ -enum states curr_state, next_state; - - curr_state =READ_ONCE (da_mon->curr_state); -for (int i =0 ; i <MAX_DA_RETRY_RACING_EVENTS ; i++) { - next_state =model_get_next_state (curr_state, event); -if (next_state ==INVALID_STATE ) { -react (curr_state, event); -CONCATENATE (trace_error_,MONITOR_NAME )( -model_get_state_name (curr_state), -model_get_event_name (event)); -return false; - } -if (likely (try_cmpxchg (&da_mon->curr_state, &curr_state, next_state))) { -CONCATENATE (trace_event_,MONITOR_NAME )( -model_get_state_name (curr_state), -model_get_event_name (event), -model_get_state_name (next_state), -model_is_final_state (next_state)); -return true; - } - } - -trace_rv_retries_error (__stringify (MONITOR_NAME ),model_get_event_name (event)); - pr_warn("rv: " __stringify(MAX_DA_RETRY_RACING_EVENTS) -" retries reached for event %s, resetting monitor %s" , -model_get_event_name (event),__stringify (MONITOR_NAME )); -return false; -} - -#elif RV_MON_TYPE ==RV_MON_PER_TASK -/* -* Event handler for per_task monitors. -* -* Retry in case there is a race between getting and setting the next state, -* warn and reset the monitor if it runs out of retries. The monitor should be -* able to handle various orders. -*/ - -static inline bool da_event (struct da_monitor *da_mon,struct task_struct *tsk, -enum events event) -{ -enum states curr_state, next_state; - - curr_state =READ_ONCE (da_mon->curr_state); -for (int i =0 ; i <MAX_DA_RETRY_RACING_EVENTS ; i++) { - next_state =model_get_next_state (curr_state, event); -if (next_state ==INVALID_STATE ) { -react (curr_state, event); -CONCATENATE (trace_error_,MONITOR_NAME )(tsk->pid, -model_get_state_name (curr_state), -model_get_event_name (event)); -return false; - } -if (likely (try_cmpxchg (&da_mon->curr_state, &curr_state, next_state))) { -CONCATENATE (trace_event_,MONITOR_NAME )(tsk->pid, -model_get_state_name (curr_state), -model_get_event_name (event), -model_get_state_name (next_state), -model_is_final_state (next_state)); -return true; - } - } - -trace_rv_retries_error (__stringify (MONITOR_NAME ),model_get_event_name (event)); - pr_warn("rv: " __stringify(MAX_DA_RETRY_RACING_EVENTS) -" retries reached for event %s, resetting monitor %s" , -model_get_event_name (event),__stringify (MONITOR_NAME )); -return false; -} -#endif /* RV_MON_TYPE */ -#if RV_MON_TYPE ==RV_MON_GLOBAL /* * Functions to define, init and get a global monitor.
@@ -329,115 +252,179 @@ static inline void da_monitor_destroy(void)#if RV_MON_TYPE ==RV_MON_GLOBAL ||RV_MON_TYPE ==RV_MON_PER_CPU /* -* Handle event for implicit monitor: da_get_monitor() will figure out -* the monitor. +* Trace events for implicit monitors. Implicit monitor is the one which the +* handler does not need to specify which da_monitor to manipulate. Examples +* of implicit monitor are the per_cpu or the global ones. */ -static inline void __da_handle_event (struct da_monitor *da_mon, -enum events event) +static inline void da_trace_event (struct da_monitor *da_mon, +char *curr_state,char *event, +char *next_state,bool is_final, +da_id_type id) { -bool retval; +CONCATENATE (trace_event_,MONITOR_NAME )(curr_state, event, next_state, + is_final); +} - retval =da_event (da_mon, event); -if (!retval) -da_monitor_reset (da_mon); +static inline void da_trace_error (struct da_monitor *da_mon, +char *curr_state,char *event, +da_id_type id) +{ +CONCATENATE (trace_error_,MONITOR_NAME )(curr_state, event); } +#elif RV_MON_TYPE ==RV_MON_PER_TASK /* -* da_handle_event - handle an event +* Trace events for per_task monitors, report the PID of the task. */ -static inline void da_handle_event (enum events event) -{ -struct da_monitor *da_mon =da_get_monitor (); -bool retval; - retval =da_monitor_handling_event (da_mon); -if (!retval) -return ; +static inline void da_trace_event (struct da_monitor *da_mon, +char *curr_state,char *event, +char *next_state,bool is_final, +da_id_type id) +{ +CONCATENATE (trace_event_,MONITOR_NAME )(id, curr_state, event, + next_state, is_final); +} -__da_handle_event (da_mon, event); +static inline void da_trace_error (struct da_monitor *da_mon, +char *curr_state,char *event, +da_id_type id) +{ +CONCATENATE (trace_error_,MONITOR_NAME )(id, curr_state, event); } +#endif /* RV_MON_TYPE */ /* -* da_handle_start_event - start monitoring or handle event -* -* This function is used to notify the monitor that the system is returning -* to the initial state, so the monitor can start monitoring in the next event. -* Thus: +* da_event - handle an event for the da_mon * -* If the monitor already started, handle the event. -* If the monitor did not start yet, start the monitor but skip the event. +* This function is valid for both implicit and id monitors. +* Retry in case there is a race between getting and setting the next state, +* warn and reset the monitor if it runs out of retries. The monitor should be +* able to handle various orders. */ -static inline bool da_handle_start_event (enum events event) +static inline bool da_event (struct da_monitor *da_mon,enum events event,da_id_type id) { -struct da_monitor *da_mon; +enum states curr_state, next_state; -if (!da_monitor_enabled ()) -return 0 ; + curr_state =READ_ONCE (da_mon->curr_state); +for (int i =0 ; i <MAX_DA_RETRY_RACING_EVENTS ; i++) { + next_state =model_get_next_state (curr_state, event); +if (next_state ==INVALID_STATE ) { +react (curr_state, event); +da_trace_error (da_mon,model_get_state_name (curr_state), +model_get_event_name (event), id); +return false; + } +if (likely (try_cmpxchg (&da_mon->curr_state, &curr_state, next_state))) { +da_trace_event (da_mon,model_get_state_name (curr_state), +model_get_event_name (event), +model_get_state_name (next_state), +model_is_final_state (next_state), id); +return true; + } + } + +trace_rv_retries_error (__stringify (MONITOR_NAME ),model_get_event_name (event)); + pr_warn("rv: " __stringify(MAX_DA_RETRY_RACING_EVENTS) +" retries reached for event %s, resetting monitor %s" , +model_get_event_name (event),__stringify (MONITOR_NAME )); +return false; +} - da_mon =da_get_monitor (); +static inline void __da_handle_event_common (struct da_monitor *da_mon, +enum events event,da_id_type id) +{ +if (!da_event (da_mon, event, id)) +da_monitor_reset (da_mon); +} +static inline void __da_handle_event (struct da_monitor *da_mon, +enum events event,da_id_type id) +{ +if (da_monitor_handling_event (da_mon)) +__da_handle_event_common (da_mon, event, id); +} + +static inline bool __da_handle_start_event (struct da_monitor *da_mon, +enum events event,da_id_type id) +{ +if (!da_monitor_enabled ()) +return 0 ;if (unlikely (!da_monitoring (da_mon))) {da_monitor_start (da_mon);return 0 ; } -__da_handle_event (da_mon, event); +__da_handle_event_common (da_mon, event, id);return 1 ; } -/* -* da_handle_start_run_event - start monitoring and handle event -* -* This function is used to notify the monitor that the system is in the -* initial state, so the monitor can start monitoring and handling event. -*/ -static inline bool da_handle_start_run_event (enum events event) +static inline bool __da_handle_start_run_event (struct da_monitor *da_mon, +enum events event,da_id_type id) { -struct da_monitor *da_mon; -if (!da_monitor_enabled ())return 0 ; - - da_mon =da_get_monitor (); -if (unlikely (!da_monitoring (da_mon)))da_monitor_start (da_mon); -__da_handle_event (da_mon, event); +__da_handle_event_common (da_mon, event, id);return 1 ; } -#elif RV_MON_TYPE ==RV_MON_PER_TASK +#if RV_MON_TYPE ==RV_MON_GLOBAL ||RV_MON_TYPE ==RV_MON_PER_CPU /* -* Handle event for per task. +* Handle event for implicit monitor: da_get_monitor() will figure out +* the monitor. */ -static inline void __da_handle_event (struct da_monitor *da_mon, -struct task_struct *tsk,enum events event) +/* +* da_handle_event - handle an event +*/ +static inline void da_handle_event (enum events event) { -bool retval; +__da_handle_event (da_get_monitor (), event,0 ); +} - retval =da_event (da_mon, tsk, event); -if (!retval) -da_monitor_reset (da_mon); +/* +* da_handle_start_event - start monitoring or handle event +* +* This function is used to notify the monitor that the system is returning +* to the initial state, so the monitor can start monitoring in the next event. +* Thus: +* +* If the monitor already started, handle the event. +* If the monitor did not start yet, start the monitor but skip the event. +*/ +static inline bool da_handle_start_event (enum events event) +{ +return __da_handle_start_event (da_get_monitor (), event,0 ); }/* -* da_handle_event - handle an event +* da_handle_start_run_event - start monitoring and handle event +* +* This function is used to notify the monitor that the system is in the +* initial state, so the monitor can start monitoring and handling event. */ -static inline void da_handle_event (struct task_struct *tsk,enum events event) +static inline bool da_handle_start_run_event (enum events event) { -struct da_monitor *da_mon =da_get_monitor (tsk); -bool retval; +return __da_handle_start_run_event (da_get_monitor (), event,0 ); +} - retval =da_monitor_handling_event (da_mon); -if (!retval) -return ; +#elif RV_MON_TYPE ==RV_MON_PER_TASK +/* +* Handle event for per task. +*/ -__da_handle_event (da_mon, tsk, event); +/* +* da_handle_event - handle an event +*/ +static inline void da_handle_event (struct task_struct *tsk,enum events event) +{ +__da_handle_event (da_get_monitor (tsk), event, tsk->pid); }/*
@@ -453,21 +440,7 @@ static inline void da_handle_event(struct task_struct *tsk, enum events event)static inline bool da_handle_start_event (struct task_struct *tsk,enum events event) { -struct da_monitor *da_mon; - -if (!da_monitor_enabled ()) -return 0 ; - - da_mon =da_get_monitor (tsk); - -if (unlikely (!da_monitoring (da_mon))) { -da_monitor_start (da_mon); -return 0 ; - } - -__da_handle_event (da_mon, tsk, event); - -return 1 ; +return __da_handle_start_event (da_get_monitor (tsk), event, tsk->pid); }/*
@@ -479,19 +452,7 @@ static inline bool da_handle_start_event(struct task_struct *tsk,static inline bool da_handle_start_run_event (struct task_struct *tsk,enum events event) { -struct da_monitor *da_mon; - -if (!da_monitor_enabled ()) -return 0 ; - - da_mon =da_get_monitor (tsk); - -if (unlikely (!da_monitoring (da_mon))) -da_monitor_start (da_mon); - -__da_handle_event (da_mon, tsk, event); - -return 1 ; +return __da_handle_start_run_event (da_get_monitor (tsk), event, tsk->pid); }#endif /* RV_MON_TYPE */
Signature · 1 line
2.52.0
Re: [PATCH v3 01/13] rv: Unify DA event handling functions across monitor types
Quoted 11 lines · Gabriele Monaco
The DA event handling functions are mostly duplicated because the per-task monitors need to propagate the task to use the pid in the trace events. This is a maintenance burden for a little advantage. The task can be obtained with some pointer arithmetic from the
da_mon, hence only the function tracing events really need to differ.Unify all code handling the events, create
da_trace_event()andda_trace_error()that only call the tracepoint function. Propagate the monitor id through the calls, thedo_trace_functions use the id (pid) in case of per-task monitors but ignore it for implicit monitors.
I think this overexplains. I would just explain the "WHY", then the general idea how the patch solves the problem. Let the diff speaks for the rest.
Perhaps something like:
The DA event handling functions are mostly duplicated for differerent monitor types, because per-task monitors' functions require a task_struct parameter while the others do not.
Unify the functions, handle the difference by always passing a da_id_type which is the task's pid for per-task monitor but is ignored for the other types.
Regardless:
Nam
Gabriele Monaco
maintainerRe: [PATCH v3 01/13] rv: Unify DA event handling functions across monitor types
Quoted 6 lines · Nam Cao
I think this overexplains. I would just explain the "WHY", then the general idea how the patch solves the problem. Let the diff speaks for the rest.
Perhaps something like:
Quoted 8 lines
The DA event handling functions are mostly duplicated for differerent monitor types, because per-task monitors' functions require a
task_structparameter while the others do not.Unify the functions, handle the difference by always passing a
da_id_typewhich is the task's pid for per-task monitor but is ignored for the other types.
Good point, I'll squeeze it.
Thanks,
Gabriele
Quoted 5 lines
Regardless:
Reviewed-by Nam Cao <[email protected]>Nam
Gabriele Monaco
maintainerPATCH v3 2/13 Add Hybrid Automata monitor type
In reply to Gabriele MonacoDeterministic automata define which events are allowed in every state, but cannot define more sophisticated constraint taking into account the system's environment (e.g. time or other states not producing events).
Add the Hybrid Automata monitor type as an extension of Deterministic automata where each state transition is validating a constraint on a finite number of environment variables.
Hybrid automata can be used to implement timed automata, where the environment variables are clocks.
Also implement the necessary functionality to handle clock constraints (ns or jiffy granularity) on state and events.
---
Notes:
V3:
* Improve functions naming for HA helpers
include/linux/rv.h | 38 +++ include/rv/da_monitor.h | 83 ++++++- include/rv/ha_monitor.h | 476 +++++++++++++++++++++++++++++++++++++ kernel/trace/rv/Kconfig | 13 + kernel/trace/rv/rv_trace.h | 63 +++++ 5 files changed, 664 insertions(+), 9 deletions(-) create mode 100644 include/rv/ha_monitor.h
include/linux/rv.h +38 -0
@@ -81,11 +81,49 @@ struct ltl_monitor {};#endif /* CONFIG_RV_LTL_MONITOR */ +#ifdef CONFIG_RV_HA_MONITOR +/* +* In the future, hybrid automata may rely on multiple +* environment variables, e.g. different clocks started at +* different times or running at different speed. +* For now we support only 1 variable. +*/ +#define MAX_HA_ENV_LEN 1 + +/* +* Monitors can pick the preferred timer implementation: +* No timer: if monitors don't have state invariants. +* Timer wheel: lightweight invariants check but far less precise. +* Hrtimer: accurate invariants check with higher overhead. +*/ +#define HA_TIMER_NONE 0 +#define HA_TIMER_WHEEL 1 +#define HA_TIMER_HRTIMER 2 + +/* +* Hybrid automaton per-object variables. +*/ +struct ha_monitor { +struct da_monitor da_mon; +u64 env_store[MAX_HA_ENV_LEN ]; +union { +struct hrtimer hrtimer; +struct timer_list timer; + }; +}; + +#else + +struct ha_monitor { }; + +#endif /* CONFIG_RV_HA_MONITOR */ +#define RV_PER_TASK_MONITOR_INIT (CONFIG_RV_PER_TASK_MONITORS)union rv_task_monitor {struct da_monitor da_mon;struct ltl_monitor ltl_mon; +struct ha_monitor ha_mon; };#ifdef CONFIG_RV_REACTORS
include/rv/da_monitor.h +74 -9
174 lines not on this page · raw message
include/rv/ha_monitor.h new file +476 -0
476 lines not on this page · raw message
kernel/trace/rv/Kconfig +13 -0
@@ -23,6 +23,19 @@ config LTL_MON_EVENTS_ID config RV_LTL_MONITOR bool +config RV_HA_MONITOR + bool + +config HA_MON_EVENTS_IMPLICIT + select DA_MON_EVENTS_IMPLICIT + select RV_HA_MONITOR + bool + +config HA_MON_EVENTS_ID + select DA_MON_EVENTS_ID + select RV_HA_MONITOR + bool + menuconfig RV bool "Runtime Verification" select TRACING
kernel/trace/rv/rv_trace.h +63 -0
75 lines not on this page · raw message
Signature · 1 line
2.52.0
Re: [PATCH v3 02/13] rv: Add Hybrid Automata monitor type
include/rv/ha_monitor.h line 400
Quoted 7 lines · Gabriele Monaco
include/rv/ha_monitor.h new file +7
-0+static inline void ha_start_timer_ns (struct ha_monitor *ha_mon,enum envs env, +u64 expire,u64 time_ns) +{ +u64 passed =ha_invariant_passed_ns (ha_mon, env, expire, time_ns); + +ha_start_timer_jiffy (ha_mon,ENV_MAX_STORED , +nsecs_to_jiffies (expire - passed) +1 , time_ns);
What is the +1 for? I guess to prevent it being rounded down to zero? If so, maybe we should do
nsecs_to_jiffies(expire - passed + TICK_NSEC - 1)
instead.
Anyway, no big deal:
Gabriele Monaco
maintainerRe: [PATCH v3 02/13] rv: Add Hybrid Automata monitor type
Quoted 14 lines · Nam Cao
Quoted 9 lines · Gabriele Monaco
+static inline void ha_start_timer_ns(struct
ha_monitor*ha_mon, enum envs env,include/rv/ha_monitor.h new file +6
-0+ u64 expire, u64 time_ns) +{ +u64 passed =ha_invariant_passed_ns (ha_mon, env, expire, time_ns); + + ha_start_timer_jiffy(ha_mon, ENV_MAX_STORED, + nsecs_to_jiffies(expire - passed) + 1,
time_ns);What is the +1 for? I guess to prevent it being rounded down to zero? If so, maybe we should do
Quoted 3 lines
nsecs_to_jiffies(expire - passed + TICK_NSEC - 1)instead.
Yeah that was the reason and your suggestion is actually cleaner.
Thanks,
Gabriele
Quoted 3 lines
Anyway, no big deal:
Reviewed-by Nam Cao <[email protected]>
Gabriele Monaco
maintainerPATCH v3 3/13 verification/rvgen: Allow spaces in and events strings
In reply to Gabriele MonacoCurrently the automata parser assumes event strings don't have any space, this stands true for event names, but can be a wrong assumption if we want to store other information in the event strings (e.g. constraints for hybrid automata).
Adapt the parser logic to allow spaces in the event strings.
--- tools/verification/rvgen/rvgen/automata.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/verification/rvgen/rvgen/automata.py +4 -5
@@ -127,14 +127,13 @@ class Automata: # ------------ event is here ------------^^^^^ if self.__dot_lines[cursor].split()[1] == "->": line = self.__dot_lines[cursor].split() - event = line[-2].replace('"','') + event = "".join(line[line.index("label")+2:-1]).replace('"','') # when a transition has more than one lables, they are like this # "local_irq_enable\nhw_local_irq_enable_n" # so split them. - event = event.replace("\\n", " ") - for i in event.split(): + for i in event.split("\\n"): events.append(i) cursor += 1
@@ -167,8 +166,8 @@ class Automata: line = self.__dot_lines[cursor].split() origin_state = line[0].replace('"','').replace(',','_') dest_state = line[2].replace('"','').replace(',','_') - possible_events = line[-2].replace('"','').replace("\\n", " ") - for event in possible_events.split(): + possible_events = "".join(line[line.index("label")+2:-1]).replace('"','') + for event in possible_events.split("\\n"): matrix[states_dict[origin_state]][events_dict[event]] = dest_state cursor += 1
Signature · 1 line
2.52.0
Gabriele Monaco
maintainerPATCH v3 4/13 verification/rvgen: Add support for Hybrid Automata
In reply to Gabriele MonacoAdd the possibility to parse dot files as hybrid automata and generate the necessary code from rvgen.
Hybrid automata are very similar to deterministic ones and most functionality is shared, the dot files include also constraints together with event names (separated by ;) and state names (separated by \n).
The tool can now generate the appropriate code to validate constraints at runtime according to the dot specification.
--- tools/verification/rvgen/__main__.py | 8 +- tools/verification/rvgen/rvgen/automata.py | 141 +++++- tools/verification/rvgen/rvgen/dot2c.py | 49 ++ tools/verification/rvgen/rvgen/dot2k.py | 473 +++++++++++++++++- tools/verification/rvgen/rvgen/generator.py | 2 + .../rvgen/rvgen/templates/dot2k/main.c | 2 +- .../rvgen/templates/dot2k/trace_hybrid.h | 16 + 7 files changed, 677 insertions(+), 14 deletions(-) create mode 100644 tools/verification/rvgen/rvgen/templates/dot2k/trace_hybrid.h
tools/verification/rvgen/__main__.py +5 -3
@@ -9,7 +9,7 @@ # Documentation/trace/rv/da_monitor_synthesis.rst if __name__ == '__main__': - from rvgen.dot2k import dot2k + from rvgen.dot2k import da2k, ha2k from rvgen.generator import Monitor from rvgen.container import Container from rvgen.ltl2k import ltl2k
@@ -29,7 +29,7 @@ if __name__ == '__main__': monitor_parser.add_argument("-p", "--parent", dest="parent", required=False, help="Create a monitor nested to parent") monitor_parser.add_argument('-c', "--class", dest="monitor_class", - help="Monitor class, either \"da\" or \"ltl\"") + help="Monitor class, either \"da\", \"ha\" or \"ltl\"") monitor_parser.add_argument('-s', "--spec", dest="spec", help="Monitor specification file") monitor_parser.add_argument('-t', "--monitor_type", dest="monitor_type", help=f"Available options: {', '.join(Monitor.monitor_types.keys())}")
@@ -43,7 +43,9 @@ if __name__ == '__main__': if params.subcmd == "monitor": print("Opening and parsing the specification file %s" % params.spec) if params.monitor_class == "da": - monitor = dot2k(params.spec, params.monitor_type, vars(params)) + monitor = da2k(params.spec, params.monitor_type, vars(params)) + elif params.monitor_class == "ha": + monitor = ha2k(params.spec, params.monitor_type, vars(params)) elif params.monitor_class == "ltl": monitor = ltl2k(params.spec, params.monitor_type, vars(params)) else:
tools/verification/rvgen/rvgen/automata.py +133 -8
199 lines not on this page · raw message
tools/verification/rvgen/rvgen/dot2c.py +49 -0
83 lines not on this page · raw message
tools/verification/rvgen/rvgen/dot2k.py +471 -2
516 lines not on this page · raw message
tools/verification/rvgen/rvgen/generator.py +2 -0
@@ -255,12 +255,14 @@ class Monitor(RVGenerator): monitor_class_type = self.fill_monitor_class_type() tracepoint_args_skel_event = self.fill_tracepoint_args_skel("event") tracepoint_args_skel_error = self.fill_tracepoint_args_skel("error") + tracepoint_args_skel_error_env = self.fill_tracepoint_args_skel("error_env") trace_h = trace_h.replace("%%MODEL_NAME%%", self.name) trace_h = trace_h.replace("%%MODEL_NAME_UP%%", self.name.upper()) trace_h = trace_h.replace("%%MONITOR_CLASS%%", monitor_class) trace_h = trace_h.replace("%%MONITOR_CLASS_TYPE%%", monitor_class_type) trace_h = trace_h.replace("%%TRACEPOINT_ARGS_SKEL_EVENT%%", tracepoint_args_skel_event) trace_h = trace_h.replace("%%TRACEPOINT_ARGS_SKEL_ERROR%%", tracepoint_args_skel_error) + trace_h = trace_h.replace("%%TRACEPOINT_ARGS_SKEL_ERROR_ENV%%", tracepoint_args_skel_error_env) return trace_h def print_files(self):
tools/verification/rvgen/rvgen/templates/dot2k/main.c +1 -1
@@ -21,7 +21,7 @@*/ #define RV_MON_TYPE RV_MON_%%MONITOR_TYPE%%#include "%%MODEL_NAME%%.h" -#include <rv/da_monitor.h> +#include <rv/%%MONITOR_CLASS%%_monitor.h> /* * This is the instrumentation part of the monitor.
tools/verification/rvgen/rvgen/templates/dot2k/trace_hybrid.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_%%MODEL_NAME_UP%% +DEFINE_EVENT(event_%%MONITOR_CLASS%%, event_%%MODEL_NAME%%, +%%TRACEPOINT_ARGS_SKEL_EVENT%%); + +DEFINE_EVENT(error_%%MONITOR_CLASS%%, error_%%MODEL_NAME%%, +%%TRACEPOINT_ARGS_SKEL_ERROR%%); + +DEFINE_EVENT(error_env_%%MONITOR_CLASS%%, error_env_%%MODEL_NAME%%, +%%TRACEPOINT_ARGS_SKEL_ERROR_ENV%%); +#endif /* CONFIG_RV_MON_%%MODEL_NAME_UP%% */
Signature · 1 line
2.52.0
Re: [PATCH v3 04/13] verification/rvgen: Add support for Hybrid Automata
Quoted 11 lines · Gabriele Monaco
Add the possibility to parse dot files as hybrid automata and generate the necessary code from rvgen.
Hybrid automata are very similar to deterministic ones and most functionality is shared, the dot files include also constraints together with event names (separated by ;) and state names (separated by \n).
The tool can now generate the appropriate code to validate constraints at runtime according to the dot specification.
Signed-off-by Gabriele Monaco <[email protected]>
Gabriele Monaco
maintainerPATCH v3 5/13 Documentation/rv: Add documentation about hybrid automata
In reply to Gabriele MonacoDescribe theory and implementation of hybrid automata in the dedicated page hybrid_automata.rst
Include a section on how to integrate a hybrid automaton in monitor_synthesis.rst
Also remove a hanging $ in deterministic_automata.rst
---
Notes:
V3:
* Improve documentation clarity after review
.../trace/rv/deterministic_automata.rst | 2 +- Documentation/trace/rv/hybrid_automata.rst | 341 ++++++++++++++++++ Documentation/trace/rv/index.rst | 1 + Documentation/trace/rv/monitor_synthesis.rst | 117 +++++- 4 files changed, 458 insertions(+), 3 deletions(-) create mode 100644 Documentation/trace/rv/hybrid_automata.rst
Documentation/trace/rv/deterministic_automata.rst +1 -1
@@ -11,7 +11,7 @@ where: - *E* is the finite set of events; - x\ :subscript:`0` is the initial state; - X\ :subscript:`m` (subset of *X*) is the set of marked (or final) states. -- *f* : *X* x *E* -> *X* $ is the transition function. It defines the state +- *f* : *X* x *E* -> *X* is the transition function. It defines the state transition in the occurrence of an event from *E* in the state *X*. In the special case of deterministic automata, the occurrence of the event in *E* in a state in *X* has a deterministic next state from *X*.
Documentation/trace/rv/hybrid_automata.rst new file +341 -0
341 lines not on this page · raw message
Documentation/trace/rv/index.rst +1 -0
@@ -9,6 +9,7 @@ Runtime Verification runtime-verification.rst deterministic_automata.rst linear_temporal_logic.rst + hybrid_automata.rst monitor_synthesis.rst da_monitor_instrumentation.rst monitor_wip.rst
Documentation/trace/rv/monitor_synthesis.rst +115 -2
135 lines not on this page · raw message
Signature · 1 line
2.52.0
Re: [PATCH v3 05/13] Documentation/rv: Add documentation about hybrid automata
Quoted 7 lines · Gabriele Monaco
Describe theory and implementation of hybrid automata in the dedicated page
hybrid_automata.rst
Include a section on how to integrate a hybrid automaton inmonitor_synthesis.rst
Also remove a hanging $ indeterministic_automata.rstSigned-off-by Gabriele Monaco <[email protected]>
Gabriele Monaco
maintainerPATCH v3 6/13 Add sample hybrid monitors stall
In reply to Gabriele MonacoAdd a sample monitor to showcase hybrid/timed automata.
The stall monitor identifies tasks stalled for longer than a threshold and reacts when that happens.
---
Notes:
V3:
* Extend stall model to handle preemption
Documentation/tools/rv/index.rst | 1 + Documentation/tools/rv/rv-mon-stall.rst | 44 ++++++ Documentation/trace/rv/index.rst | 1 + Documentation/trace/rv/monitor_stall.rst | 43 ++++++ kernel/trace/rv/Kconfig | 1 + kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitors/stall/Kconfig | 13 ++ kernel/trace/rv/monitors/stall/stall.c | 150 +++++++++++++++++++ kernel/trace/rv/monitors/stall/stall.h | 81 ++++++++++ kernel/trace/rv/monitors/stall/stall_trace.h | 19 +++ kernel/trace/rv/rv_trace.h | 1 + tools/verification/models/stall.dot | 22 +++ 12 files changed, 377 insertions(+) create mode 100644 Documentation/tools/rv/rv-mon-stall.rst create mode 100644 Documentation/trace/rv/monitor_stall.rst create mode 100644 kernel/trace/rv/monitors/stall/Kconfig create mode 100644 kernel/trace/rv/monitors/stall/stall.c create mode 100644 kernel/trace/rv/monitors/stall/stall.h create mode 100644 kernel/trace/rv/monitors/stall/stall_trace.h create mode 100644 tools/verification/models/stall.dot
Documentation/tools/rv/index.rst +1 -0
@@ -16,6 +16,7 @@ Runtime verification (rv) tool rv-mon-wip rv-mon-wwnr rv-mon-sched + rv-mon-stall .. only:: subproject and html
Documentation/tools/rv/rv-mon-stall.rst new file +44 -0
44 lines not on this page · raw message
Documentation/trace/rv/index.rst +1 -0
@@ -16,3 +16,4 @@ Runtime Verification monitor_wwnr.rst monitor_sched.rst monitor_rtapp.rst + monitor_stall.rst
Documentation/trace/rv/monitor_stall.rst new file +43 -0
43 lines not on this page · raw message
kernel/trace/rv/Kconfig +1 -0
@@ -78,6 +78,7 @@ source "kernel/trace/rv/monitors/pagefault/Kconfig" source "kernel/trace/rv/monitors/sleep/Kconfig" # Add new rtapp monitors here +source "kernel/trace/rv/monitors/stall/Kconfig" # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_RV_MON_STS) += monitors/sts/sts.o obj-$(CONFIG_RV_MON_NRP) += monitors/nrp/nrp.o obj-$(CONFIG_RV_MON_SSSW) += monitors/sssw/sssw.o obj-$(CONFIG_RV_MON_OPID) += monitors/opid/opid.o +obj-$(CONFIG_RV_MON_STALL) += monitors/stall/stall.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/stall/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_STALL + depends on RV + select HA_MON_EVENTS_ID + bool "stall monitor" + help + Enable the stall sample monitor that illustrates the usage of hybrid + automata monitors. It can be used to identify tasks stalled for + longer than a threshold. + + For further information, see: + Documentation/trace/rv/monitor_stall.rst
kernel/trace/rv/monitors/stall/stall.c new file +150 -0
150 lines not on this page · raw message
kernel/trace/rv/monitors/stall/stall.h new file +81 -0
81 lines not on this page · raw message
kernel/trace/rv/monitors/stall/stall_trace.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_STALL +DEFINE_EVENT (event_da_monitor_id, event_stall, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_stall, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); + +DEFINE_EVENT (error_env_da_monitor_id, error_env_stall, + TP_PROTO(int id, char *state, char *event, char *env), +TP_ARGS (id, state, event, env)); +#endif /* CONFIG_RV_MON_STALL */
kernel/trace/rv/rv_trace.h +1 -0
@@ -187,6 +187,7 @@ DECLARE_EVENT_CLASS(error_env_da_monitor_id, __get_str(env)) ); +#include <monitors/stall/stall_trace.h> // Add new monitors based on CONFIG_HA_MON_EVENTS_ID here #endif
tools/verification/models/stall.dot new file +22 -0
@@ -0,0 +1,22 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = circle] "enqueued"}; + {node [shape = plaintext, style=invis, label=""] "__init_dequeued"}; + {node [shape = doublecircle] "dequeued"}; + {node [shape = circle] "running"}; + "__init_dequeued" -> "dequeued"; + "enqueued" [label = "enqueued\nclk < threshold_jiffies"]; + "running" [label = "running"]; + "dequeued" [label = "dequeued", color = green3]; + "running" -> "running" [ label = "sched_switch_in\nsched_wakeup" ]; + "enqueued" -> "enqueued" [ label = "sched_wakeup" ]; + "enqueued" -> "running" [ label = "sched_switch_in" ]; + "running" -> "dequeued" [ label = "sched_switch_wait" ]; + "dequeued" -> "enqueued" [ label = "sched_wakeup;reset(clk)" ]; + "running" -> "enqueued" [ label = "sched_switch_preempt;reset(clk)" ]; + { rank = min ; + "__init_dequeued"; + "dequeued"; + } +}
Signature · 1 line
2.52.0
Re: [PATCH v3 06/13] rv: Add sample hybrid monitors stall
Quoted 5 lines · Gabriele Monaco
Add a sample monitor to showcase hybrid/timed automata.
The stall monitor identifies tasks stalled for longer than a threshold and reacts when that happens.Signed-off-by Gabriele Monaco <[email protected]>
Gabriele Monaco
maintainerPATCH v3 7/13 Convert the opid monitor to a hybrid automaton
In reply to Gabriele MonacoThe opid monitor validates that wakeup and need_resched events only occur with interrupts and preemption disabled by following the preemptirq tracepoints.
As reported in [1], those tracepoints might be inaccurate in some situations (e.g. NMIs).
Since the monitor doesn't validate other ordering properties, remove the dependency on preemptirq tracepoints and convert the monitor to a hybrid automaton to validate the constraint during event handling. This makes the monitor more robust by also removing the workaround for interrupts missing the preemption tracepoints, which was working on PREEMPT_RT only and allows the monitor to be built on kernels without the preemptirqs tracepoints.
[1] - https://lore.kernel.org/lkml/[email protected]
--- Documentation/trace/rv/monitor_sched.rst | 62 +++--------- kernel/trace/rv/monitors/opid/Kconfig | 11 +- kernel/trace/rv/monitors/opid/opid.c | 111 +++++++-------------- kernel/trace/rv/monitors/opid/opid.h | 86 ++++------------ kernel/trace/rv/monitors/opid/opid_trace.h | 4 + kernel/trace/rv/rv_trace.h | 2 +- tools/verification/models/sched/opid.dot | 36 ++----- 7 files changed, 82 insertions(+), 230 deletions(-)
Documentation/trace/rv/monitor_sched.rst +14 -48
@@ -346,55 +346,21 @@ Monitor opid The operations with preemption and irq disabled (opid) monitor ensures operations like ``wakeup`` and ``need_resched`` occur with interrupts and -preemption disabled or during interrupt context, in such case preemption may -not be disabled explicitly. +preemption disabled. ``need_resched`` can be set by some RCU internals functions, in which case it -doesn't match a task wakeup and might occur with only interrupts disabled:: - - | sched_need_resched - | sched_waking - | irq_entry - | +--------------------+ - v v | - +------------------------------------------------------+ - +----------- | disabled | <+ - | +------------------------------------------------------+ | - | | ^ | - | | preempt_disable sched_need_resched | - | preempt_enable | +--------------------+ | - | v | v | | - | +------------------------------------------------------+ | - | | irq_disabled | | - | +------------------------------------------------------+ | - | | | ^ | - | irq_entry irq_entry | | | - | sched_need_resched v | irq_disable | - | sched_waking +--------------+ | | | - | +----- | | irq_enable | | - | | | in_irq | | | | - | +----> | | | | | - | +--------------+ | | irq_disable - | | | | | - | irq_enable | irq_enable | | | - | v v | | - | #======================================================# | - | H enabled H | - | #======================================================# | - | | ^ ^ preempt_enable | | - | preempt_disable preempt_enable +--------------------+ | - | v | | - | +------------------+ | | - +----------> | preempt_disabled | -+ | - +------------------+ | - | | - +-------------------------------------------------------+ - -This monitor is designed to work on ``PREEMPT_RT`` kernels, the special case of -events occurring in interrupt context is a shortcut to identify valid scenarios -where the preemption tracepoints might not be visible, during interrupts -preemption is always disabled. On non- ``PREEMPT_RT`` kernels, the interrupts -might invoke a softirq to set ``need_resched`` and wake up a task. This is -another special case that is currently not supported by the monitor. +doesn't match a task wakeup and might occur with only interrupts disabled. +The interrupt and preemption status are validated by the hybrid automaton +constraints when processing the events:: + + | + | + v + #=========# sched_need_resched;irq_off == 1 + H H sched_waking;irq_off == 1 && preempt_off == 1 + H any H ------------------------------------------------+ + H H | + H H <-----------------------------------------------+ + #=========# References ----------
kernel/trace/rv/monitors/opid/Kconfig +3 -8
@@ -2,18 +2,13 @@ # config RV_MON_OPID depends on RV - depends on TRACE_IRQFLAGS - depends on TRACE_PREEMPT_TOGGLE depends on RV_MON_SCHED - default y if PREEMPT_RT - select DA_MON_EVENTS_IMPLICIT + default y + select HA_MON_EVENTS_IMPLICIT bool "opid monitor" help Monitor to ensure operations like wakeup and need resched occur with - interrupts and preemption disabled or during IRQs, where preemption - may not be disabled explicitly. - - This monitor is unstable on !PREEMPT_RT, say N unless you are testing it. + interrupts and preemption disabled. For further information, see: Documentation/trace/rv/monitor_sched.rst
kernel/trace/rv/monitors/opid/opid.c +34 -77
156 lines not on this page · raw message
kernel/trace/rv/monitors/opid/opid.h +19 -67
117 lines not on this page · raw message
kernel/trace/rv/monitors/opid/opid_trace.h +4 -0
@@ -12,4 +12,8 @@ DEFINE_EVENT(event_da_monitor, event_opid,DEFINE_EVENT (error_da_monitor, error_opid,TP_PROTO (char *state, char *event),TP_ARGS (state, event)); + +DEFINE_EVENT (error_env_da_monitor, error_env_opid, +TP_PROTO (char *state, char *event, char *env), +TP_ARGS (state, event, env));#endif /* CONFIG_RV_MON_OPID */
kernel/trace/rv/rv_trace.h +1 -1
@@ -62,7 +62,6 @@ DECLARE_EVENT_CLASS(error_da_monitor,#include <monitors/scpd/scpd_trace.h> #include <monitors/snep/snep_trace.h> #include <monitors/sts/sts_trace.h> -#include <monitors/opid/opid_trace.h> // Add new monitors based on CONFIG_DA_MON_EVENTS_IMPLICIT here #ifdef CONFIG_HA_MON_EVENTS_IMPLICIT
@@ -91,6 +90,7 @@ DECLARE_EVENT_CLASS(error_env_da_monitor, __get_str(env)) ); +#include <monitors/opid/opid_trace.h> // Add new monitors based on CONFIG_HA_MON_EVENTS_IMPLICIT here #endif
tools/verification/models/sched/opid.dot +7 -29
@@ -1,35 +1,13 @@ digraph state_automaton { center = true; size = "7,11"; - {node [shape = plaintext, style=invis, label=""] "__init_disabled"}; - {node [shape = circle] "disabled"}; - {node [shape = doublecircle] "enabled"}; - {node [shape = circle] "enabled"}; - {node [shape = circle] "in_irq"}; - {node [shape = circle] "irq_disabled"}; - {node [shape = circle] "preempt_disabled"}; - "__init_disabled" -> "disabled"; - "disabled" [label = "disabled"]; - "disabled" -> "disabled" [ label = "sched_need_resched\nsched_waking\nirq_entry" ]; - "disabled" -> "irq_disabled" [ label = "preempt_enable" ]; - "disabled" -> "preempt_disabled" [ label = "irq_enable" ]; - "enabled" [label = "enabled", color = green3]; - "enabled" -> "enabled" [ label = "preempt_enable" ]; - "enabled" -> "irq_disabled" [ label = "irq_disable" ]; - "enabled" -> "preempt_disabled" [ label = "preempt_disable" ]; - "in_irq" [label = "in_irq"]; - "in_irq" -> "enabled" [ label = "irq_enable" ]; - "in_irq" -> "in_irq" [ label = "sched_need_resched\nsched_waking\nirq_entry" ]; - "irq_disabled" [label = "irq_disabled"]; - "irq_disabled" -> "disabled" [ label = "preempt_disable" ]; - "irq_disabled" -> "enabled" [ label = "irq_enable" ]; - "irq_disabled" -> "in_irq" [ label = "irq_entry" ]; - "irq_disabled" -> "irq_disabled" [ label = "sched_need_resched" ]; - "preempt_disabled" [label = "preempt_disabled"]; - "preempt_disabled" -> "disabled" [ label = "irq_disable" ]; - "preempt_disabled" -> "enabled" [ label = "preempt_enable" ]; + {node [shape = plaintext, style=invis, label=""] "__init_any"}; + {node [shape = doublecircle] "any"}; + "__init_any" -> "any"; + "any" [label = "any", color = green3]; + "any" -> "any" [ label = "sched_need_resched;irq_off == 1\nsched_waking;irq_off == 1 && preempt_off == 1" ]; { rank = min ; - "__init_disabled"; - "disabled"; + "__init_any"; + "any"; } }
Signature · 1 line
2.52.0
Re: [PATCH v3 07/13] rv: Convert the opid monitor to a hybrid automaton
Quoted 14 lines · Gabriele Monaco
The opid monitor validates that wakeup and
need_reschedevents only occur with interrupts and preemption disabled by following the preemptirq tracepoints.
As reported in [1], those tracepoints might be inaccurate in some situations (e.g. NMIs).Since the monitor doesn't validate other ordering properties, remove the dependency on preemptirq tracepoints and convert the monitor to a hybrid automaton to validate the constraint during event handling. This makes the monitor more robust by also removing the workaround for interrupts missing the preemption tracepoints, which was working on
PREEMPT_RTonly and allows the monitor to be built on kernels without the preemptirqs tracepoints.
Quoted 3 lines
[1] - https://lore.kernel.org/lkml/[email protected]
Signed-off-by Gabriele Monaco <[email protected]>
Gabriele Monaco
maintainerPATCH v3 8/13 sched: Export hidden tracepoints to modules
In reply to Gabriele MonacoThe tracepoints sched_entry, sched_exit and sched_set_need_resched are not exported to tracefs as trace events, this allows only kernel code to access them. Helper modules like [1] can be used to still have the tracepoints available to ftrace for debugging purposes, but they do rely on the tracepoints being exported.
Export the 3 not exported tracepoints.
Note that sched_set_state is already exported as the macro is called from modules.
[1] - https://github.com/qais-yousef/sched_tp.git
--- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/sched/core.c +3 -0
@@ -119,6 +119,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_se_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_update_nr_running_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_compute_energy_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);
Signature · 1 line
2.52.0
Re: [PATCH v3 08/13] sched: Export hidden tracepoints to modules
Quoted 6 lines · On Fri, Dec 05, 2025 at 02:16:16PM +0100 Gabriele Monaco wrote:
The tracepoints
sched_entry,sched_exitandsched_set_need_reschedare not exported to tracefs as trace events, this allows only kernel code to access them. Helper modules like [1] can be used to still have the tracepoints available to ftrace for debugging purposes, but they do rely on the tracepoints being exported.
Quoted 7 lines
Export the 3 not exported tracepoints.
Note thatsched_set_stateis already exported as the macro is called from modules.[1] - https://github.com/qais-yousef/sched_tp.git
Signed-off-by Gabriele Monaco <[email protected]>
This makes sense.
Cheers,
Phil
Quoted 22 lines
--- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+)kernel/sched/core.c +3
-0@@ -119,6 +119,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_se_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_update_nr_running_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_compute_energy_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);Signature · 1 line
2.52.0
Re: [PATCH v3 08/13] sched: Export hidden tracepoints to modules
Hi Peter,
Quoted 11 lines · On Fri, Dec 05, 2025 at 08:35:52AM -0500 Phil Auld wrote:
Quoted 10 lines · On Fri, Dec 05, 2025 at 02:16:16PM +0100 Gabriele Monaco wrote:
The tracepoints
sched_entry,sched_exitandsched_set_need_reschedare not exported to tracefs as trace events, this allows only kernel code to access them. Helper modules like [1] can be used to still have the tracepoints available to ftrace for debugging purposes, but they do rely on the tracepoints being exported.Export the 3 not exported tracepoints.
Note thatsched_set_stateis already exported as the macro is called from modules.
Quoted 8 lines
Quoted 3 lines
[1] - https://github.com/qais-yousef/sched_tp.git
Signed-off-by Gabriele Monaco <[email protected]>This makes sense.
Reviewed-by Phil Auld <[email protected]>
Any chance we can get this one in even if the rest of the series needs more time?
Without this, out of tree modules fail to link.
I don't know if it's worth adding:
Cheers,
Phil
Quoted 29 lines
Cheers,
PhilQuoted 22 lines
--- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+)kernel/sched/core.c +3
-0@@ -119,6 +119,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_se_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_update_nr_running_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_compute_energy_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);Signature · 1 line
2.52.0
Re: [PATCH v3 08/13] sched: Export hidden tracepoints to modules
Ping...
Quoted 21 lines · On Fri, Dec 12, 2025 at 07:36:43AM +0900 Phil Auld wrote:
Hi Peter,
Quoted 17 lines · On Fri, Dec 05, 2025 at 08:35:52AM -0500 Phil Auld wrote:
Quoted 6 lines · On Fri, Dec 05, 2025 at 02:16:16PM +0100 Gabriele Monaco wrote:
The tracepoints
sched_entry,sched_exitandsched_set_need_reschedare not exported to tracefs as trace events, this allows only kernel code to access them. Helper modules like [1] can be used to still have the tracepoints available to ftrace for debugging purposes, but they do rely on the tracepoints being exported.Quoted 7 lines
Export the 3 not exported tracepoints.
Note thatsched_set_stateis already exported as the macro is called from modules.[1] - https://github.com/qais-yousef/sched_tp.git
Signed-off-by Gabriele Monaco <[email protected]>This makes sense.
Quoted 7 lines
Quoted 2 lines
Reviewed-by Phil Auld <[email protected]>Any chance we can get this one in even if the rest of the series needs more time?
Without this, out of tree modules fail to link.
Any thoughts on this? Please?
Anything including linux/sched.h fails to link due to these:__trace_set_need_resched __tracepoint_sched_set_need_resched_tp
Thanks,
Phil
Quoted 42 lines
I don't know if it's worth adding:
Fixes adcc3bfa8806 ("sched: Adapt sched tracepoints for RV task model")Cheers,
PhilQuoted 29 lines
Cheers,
PhilQuoted 22 lines
--- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+)kernel/sched/core.c +3
-0@@ -119,6 +119,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_se_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_update_nr_running_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_compute_energy_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);Signature · 1 line
2.52.0
[tip: sched/core] sched: Export hidden tracepoints to modules
In reply to Gabriele MonacoThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 6c125b85f3c87b4bf7dba91af6f27d9600b9dba0 Gitweb: https://git.kernel.org/tip/6c125b85f3c87b4bf7dba91af6f27d9600b9dba0 Author: Gabriele Monaco <[email protected]> AuthorDate: Fri, 05 Dec 2025 14:16:16 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 13 Jan 2026 11:37:53 +01:00
sched: Export hidden tracepoints to modules
The tracepoints sched_entry, sched_exit and sched_set_need_resched are not exported to tracefs as trace events, this allows only kernel code to access them. Helper modules like [1] can be used to still have the tracepoints available to ftrace for debugging purposes, but they do rely on the tracepoints being exported.
Export the 3 not exported tracepoints.
Note that sched_set_state is already exported as the macro is called from modules.
[1] - https://github.com/qais-yousef/sched_tp.git
--- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/sched/core.c +3 -0
@@ -119,6 +119,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_se_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_update_nr_running_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_compute_energy_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);
Gabriele Monaco
maintainerPATCH v3 9/13 sched: Add deadline tracepoints
In reply to Gabriele MonacoAdd the following tracepoints:
* sched_dl_throttle(dl_se, cpu):
Called when a deadline entity is throttled
* sched_dl_replenish(dl_se, cpu):
Called when a deadline entity's runtime is replenished
* sched_dl_server_start(dl_se, cpu):
Called when a deadline server is started
* sched_dl_server_stop(dl_se, cpu):
Called when a deadline server is stopped
Those tracepoints can be useful to validate the deadline scheduler with RV and are not exported to tracefs.
---
Notes:
V3:
* Rename dl argument to dl_se in tracepoints
include/trace/events/sched.h | 16 ++++++++++++++++ kernel/sched/core.c | 4 ++++ kernel/sched/deadline.c | 7 +++++++ 3 files changed, 27 insertions(+)
include/trace/events/sched.h +16 -0
@@ -896,6 +896,22 @@ DECLARE_TRACE(sched_set_need_resched, TP_PROTO(struct task_struct *tsk, int cpu, int tif), TP_ARGS(tsk, cpu, tif)); +DECLARE_TRACE (sched_dl_throttle, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_replenish, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_server_start, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_server_stop, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/core.c +4 -0
@@ -122,6 +122,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_throttle_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_replenish_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_server_start_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_server_stop_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);
kernel/sched/deadline.c +7 -0
@@ -733,6 +733,7 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se, dl_se->dl_throttled =1 ; dl_se->dl_defer_armed =1 ; } +trace_sched_dl_replenish_tp (dl_se,cpu_of (rq)); }/*
@@ -850,6 +851,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)if (dl_se->dl_throttled) dl_se->dl_throttled =0 ; +trace_sched_dl_replenish_tp (dl_se,cpu_of (rq)); +/* * If this is the replenishment of a deferred reservation, * clear the flag and return.
@@ -1341,6 +1344,7 @@ static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se) dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {if (unlikely (is_dl_boosted (dl_se) || !start_dl_timer (dl_se)))return ; +trace_sched_dl_throttle_tp (dl_se,cpu_of (rq)); dl_se->dl_throttled =1 ;if (dl_se->runtime >0 ) dl_se->runtime =0 ;
@@ -1504,6 +1508,7 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64 throttle:if (dl_runtime_exceeded (dl_se) || dl_se->dl_yielded) { +trace_sched_dl_throttle_tp (dl_se,cpu_of (rq)); dl_se->dl_throttled =1 ;/* If requested, inform the user about runtime overruns. */
@@ -1795,6 +1800,7 @@ void dl_server_start(struct sched_dl_entity *dl_se)if (WARN_ON_ONCE (!cpu_online (cpu_of (rq))))return ; +trace_sched_dl_server_start_tp (dl_se,cpu_of (rq)); dl_se->dl_server_active =1 ;enqueue_dl_entity (dl_se,ENQUEUE_WAKEUP );if (!dl_task (dl_se->rq->curr) ||dl_entity_preempt (dl_se, &rq->curr->dl))
@@ -1806,6 +1812,7 @@ void dl_server_stop(struct sched_dl_entity *dl_se)if (!dl_server (dl_se) || !dl_server_active (dl_se))return ; +trace_sched_dl_server_stop_tp (dl_se,cpu_of (dl_se->rq));dequeue_dl_entity (dl_se,DEQUEUE_SLEEP );hrtimer_try_to_cancel (&dl_se->dl_timer); dl_se->dl_defer_armed =0 ;
Signature · 1 line
2.52.0
Re: [PATCH v3 09/13] sched: Add deadline tracepoints
Quoted 11 lines · On Fri, Dec 05, 2025 at 02:16:17PM +0100 Gabriele Monaco wrote:
Add the following tracepoints:
*
sched_dl_throttle(dl_se, cpu):
Called when a deadline entity is throttled
*sched_dl_replenish(dl_se, cpu):
Called when a deadline entity's runtime is replenished
*sched_dl_server_start(dl_se, cpu):
Called when a deadline server is started
*sched_dl_server_stop(dl_se, cpu):
Called when a deadline server is stopped
Quoted 4 lines
Those tracepoints can be useful to validate the deadline scheduler with RV and are not exported to tracefs.
Signed-off-by Gabriele Monaco <[email protected]>
These seem like they might be useful outside of the RV context as well.
Cheers,
Phil
Quoted 110 lines
---
Notes:
V3:
* Rename dl argument todl_sein tracepointsinclude/trace/events/sched.h | 16 ++++++++++++++++ kernel/sched/core.c | 4 ++++ kernel/sched/deadline.c | 7 +++++++ 3 files changed, 27 insertions(+)include/trace/events/sched.h +16
-0@@ -896,6 +896,22 @@ DECLARE_TRACE(sched_set_need_resched, TP_PROTO(struct task_struct *tsk, int cpu, int tif), TP_ARGS(tsk, cpu, tif)); +DECLARE_TRACE (sched_dl_throttle, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_replenish, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_server_start, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); + +DECLARE_TRACE (sched_dl_server_stop, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu), +TP_ARGS (dl_se, cpu)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ kernel/sched/core.c +4
-0@@ -122,6 +122,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_entry_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_exit_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_set_need_resched_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_throttle_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_replenish_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_server_start_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (sched_dl_server_stop_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);kernel/sched/deadline.c +7
-0@@ -733,6 +733,7 @@ static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se, dl_se->dl_throttled =1 ; dl_se->dl_defer_armed =1 ; } +trace_sched_dl_replenish_tp (dl_se,cpu_of (rq)); }/* @@ -850,6 +851,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)if (dl_se->dl_throttled) dl_se->dl_throttled =0 ; +trace_sched_dl_replenish_tp (dl_se,cpu_of (rq)); +/* * If this is the replenishment of a deferred reservation, * clear the flag and return. @@ -1341,6 +1344,7 @@ static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se) dl_time_before(rq_clock(rq), dl_next_period(dl_se))) {if (unlikely (is_dl_boosted (dl_se) || !start_dl_timer (dl_se)))return ; +trace_sched_dl_throttle_tp (dl_se,cpu_of (rq)); dl_se->dl_throttled =1 ;if (dl_se->runtime >0 ) dl_se->runtime =0 ;@@ -1504,6 +1508,7 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64 throttle:if (dl_runtime_exceeded (dl_se) || dl_se->dl_yielded) { +trace_sched_dl_throttle_tp (dl_se,cpu_of (rq)); dl_se->dl_throttled =1 ;/* If requested, inform the user about runtime overruns. */ @@ -1795,6 +1800,7 @@ void dl_server_start(struct sched_dl_entity *dl_se)if (WARN_ON_ONCE (!cpu_online (cpu_of (rq))))return ; +trace_sched_dl_server_start_tp (dl_se,cpu_of (rq)); dl_se->dl_server_active =1 ;enqueue_dl_entity (dl_se,ENQUEUE_WAKEUP );if (!dl_task (dl_se->rq->curr) ||dl_entity_preempt (dl_se, &rq->curr->dl))@@ -1806,6 +1812,7 @@ void dl_server_stop(struct sched_dl_entity *dl_se)if (!dl_server (dl_se) || !dl_server_active (dl_se))return ; +trace_sched_dl_server_stop_tp (dl_se,cpu_of (dl_se->rq));dequeue_dl_entity (dl_se,DEQUEUE_SLEEP );hrtimer_try_to_cancel (&dl_se->dl_timer); dl_se->dl_defer_armed =0 ;Signature · 1 line
2.52.0
Gabriele Monaco
maintainerPATCH v3 10/13 Add support for per-object monitors in DA/HA
In reply to Gabriele MonacoRV deterministic and hybrid automata currently only support global, per-cpu and per-task monitors. It isn't possible to write a model that would follow some different type of object, like a deadline entity or a lock.
Define the generic per-object monitor implementation which shares part of the implementation with the per-task monitors.
The user needs to provide an id for the object (e.g. pid for tasks) and define the data type for the monitor_target (e.g. struct task_struct * for tasks). Both are supplied to the event handlers, as the id may not be easily available in the target.
The monitor storage (e.g. the rv monitor, pointer to the target, etc.) is stored in a hash table indexed by id. Monitor storage objects are automatically allocated unless specified otherwise (e.g. if the creation context is unsafe for allocation).
---
Notes:
V3:
* Use kmalloc_nolock for per-obj storage allocation
* Improve function name consistency
include/linux/rv.h | 1 + include/rv/da_monitor.h | 300 +++++++++++++++++++++++++++++++++++++++- include/rv/ha_monitor.h | 5 +- 3 files changed, 300 insertions(+), 6 deletions(-)
include/linux/rv.h +1 -0
@@ -13,6 +13,7 @@#define RV_MON_GLOBAL 0#define RV_MON_PER_CPU 1#define RV_MON_PER_TASK 2 +#define RV_MON_PER_OBJ 3#ifdef CONFIG_RV #include <linux/array_size.h>
include/rv/da_monitor.h +295 -5
344 lines not on this page · raw message
include/rv/ha_monitor.h +4 -1
@@ -191,7 +191,10 @@ static inline void ha_trace_error_env(struct ha_monitor *ha_mon, {CONCATENATE (trace_error_env_,MONITOR_NAME )(curr_state, event, env); } -#elif RV_MON_TYPE ==RV_MON_PER_TASK +#elif RV_MON_TYPE ==RV_MON_PER_TASK ||RV_MON_TYPE ==RV_MON_PER_OBJ + +#define ha_get_target (ha_mon) da_get_target(&ha_mon->da_mon) +static inline void ha_trace_error_env (struct ha_monitor *ha_mon,char *curr_state,char *event,char *env,da_id_type id)
Signature · 1 line
2.52.0
Re: [PATCH v3 10/13] rv: Add support for per-object monitors in DA/HA
Quoted 12 lines · Gabriele Monaco
RV deterministic and hybrid automata currently only support global, per-cpu and per-task monitors. It isn't possible to write a model that would follow some different type of object, like a deadline entity or a lock.
Define the generic per-object monitor implementation which shares part of the implementation with the per-task monitors.
The user needs to provide an id for the object (e.g. pid for tasks) and define the data type for themonitor_target(e.g. structtask_struct* for tasks). Both are supplied to the event handlers, as the id may not be easily available in the target.
Quoted 6 lines
The monitor storage (e.g. the rv monitor, pointer to the target, etc.) is stored in a hash table indexed by id. Monitor storage objects are automatically allocated unless specified otherwise (e.g. if the creation context is unsafe for allocation).
Signed-off-by Gabriele Monaco <[email protected]>
Gabriele Monaco
maintainerPATCH v3 11/13 verification/rvgen: Add support for per-obj monitors
In reply to Gabriele MonacoThe special per-object monitor type was just introduced in RV, this requires the user to define some functions and type specific to the object.
Adapt rvgen to add stub definitions for the monitor_target type and other modifications required to create per-object monitors.
---
Notes:
V3:
* Add _is_id_monitor() in dot2k to handle per-obj together with per-task
tools/verification/rvgen/rvgen/dot2k.py | 17 +++++++++++++---- tools/verification/rvgen/rvgen/generator.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-)
tools/verification/rvgen/rvgen/dot2k.py +13 -4
@@ -27,6 +27,8 @@ class dot2k(Monitor, Dot2c): def fill_monitor_type(self) -> str: buff = [ self.monitor_type.upper() ] buff += self._fill_timer_type() + if self.monitor_type == "per_obj": + buff.append("typedef /* XXX: define the target type */ *monitor_target;") return "\n".join(buff) def fill_tracepoint_handlers_skel(self) -> str:
@@ -45,6 +47,10 @@ class dot2k(Monitor, Dot2c): if self.monitor_type == "per_task": buff.append("\tstruct task_struct *p = /* XXX: how do I get p? */;"); buff.append("\tda_%s(p, %s%s);" % (handle, event, self.enum_suffix)); + elif self.monitor_type == "per_obj": + buff.append("\tint id = /* XXX: how do I get the id? */;"); + buff.append("\tmonitor_target t = /* XXX: how do I get t? */;"); + buff.append("\tda_%s(id, t, %s%s);" % (handle, event, self.enum_suffix)); else: buff.append("\tda_%s(%s%s);" % (handle, event, self.enum_suffix)); buff.append("}")
@@ -92,13 +98,16 @@ class dot2k(Monitor, Dot2c): return '\n'.join(buff) + def _is_id_monitor(self) -> bool: + return self.monitor_type in ("per_task", "per_obj") + def fill_monitor_class_type(self) -> str: - if self.monitor_type == "per_task": + if self._is_id_monitor(): return "DA_MON_EVENTS_ID" return "DA_MON_EVENTS_IMPLICIT" def fill_monitor_class(self) -> str: - if self.monitor_type == "per_task": + if self._is_id_monitor(): return "da_monitor_id" return "da_monitor"
@@ -122,7 +131,7 @@ class dot2k(Monitor, Dot2c): } tp_args_id = ("int ", "id") tp_args = tp_args_dict[tp_type] - if self.monitor_type == "per_task": + if self._is_id_monitor(): tp_args.insert(0, tp_args_id) tp_proto_c = ", ".join([a+b for a,b in tp_args]) tp_args_c = ", ".join([b for a,b in tp_args])
@@ -169,7 +178,7 @@ class ha2k(dot2k): self.__parse_constraints() def fill_monitor_class_type(self) -> str: - if self.monitor_type == "per_task": + if self._is_id_monitor(): return "HA_MON_EVENTS_ID" return "HA_MON_EVENTS_IMPLICIT"
tools/verification/rvgen/rvgen/generator.py +1 -1
@@ -243,7 +243,7 @@ obj-$(CONFIG_RV_MON_%s) += monitors/%s/%s.o class Monitor(RVGenerator): - monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3 } + monitor_types = { "global" : 1, "per_cpu" : 2, "per_task" : 3, "per_obj" : 4 } def __init__(self, extra_params={}): super().__init__(extra_params)
Signature · 1 line
2.52.0
Gabriele Monaco
maintainerPATCH v3 12/13 Add deadline monitors
In reply to Gabriele MonacoAdd the deadline monitors collection to validate the deadline scheduler, both for deadline tasks and servers.
The currently implemented monitors are:
* throttle:
validate dl entities are throttled when they use up their runtime
* nomiss:
validate dl entities run to completion before their deadiline
---
Notes:
V3:
* Adapt models to new dl server behaviour
* Rename dl argument to dl_se in tracepoints
* Use __COUNTER__ in dl monitor syscall helpers
Documentation/trace/rv/index.rst | 1 + Documentation/trace/rv/monitor_deadline.rst | 151 +++++++++ kernel/trace/rv/Kconfig | 5 + kernel/trace/rv/Makefile | 3 + kernel/trace/rv/monitors/deadline/Kconfig | 10 + kernel/trace/rv/monitors/deadline/deadline.c | 35 +++ kernel/trace/rv/monitors/deadline/deadline.h | 203 ++++++++++++ kernel/trace/rv/monitors/nomiss/Kconfig | 15 + kernel/trace/rv/monitors/nomiss/nomiss.c | 289 ++++++++++++++++++ kernel/trace/rv/monitors/nomiss/nomiss.h | 137 +++++++++ .../trace/rv/monitors/nomiss/nomiss_trace.h | 19 ++ kernel/trace/rv/monitors/throttle/Kconfig | 15 + kernel/trace/rv/monitors/throttle/throttle.c | 248 +++++++++++++++ kernel/trace/rv/monitors/throttle/throttle.h | 116 +++++++ .../rv/monitors/throttle/throttle_trace.h | 19 ++ kernel/trace/rv/rv_trace.h | 2 + tools/verification/models/deadline/nomiss.dot | 43 +++ .../verification/models/deadline/throttle.dot | 44 +++ 18 files changed, 1355 insertions(+) create mode 100644 Documentation/trace/rv/monitor_deadline.rst create mode 100644 kernel/trace/rv/monitors/deadline/Kconfig create mode 100644 kernel/trace/rv/monitors/deadline/deadline.c create mode 100644 kernel/trace/rv/monitors/deadline/deadline.h create mode 100644 kernel/trace/rv/monitors/nomiss/Kconfig create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss.c create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss.h create mode 100644 kernel/trace/rv/monitors/nomiss/nomiss_trace.h create mode 100644 kernel/trace/rv/monitors/throttle/Kconfig create mode 100644 kernel/trace/rv/monitors/throttle/throttle.c create mode 100644 kernel/trace/rv/monitors/throttle/throttle.h create mode 100644 kernel/trace/rv/monitors/throttle/throttle_trace.h create mode 100644 tools/verification/models/deadline/nomiss.dot create mode 100644 tools/verification/models/deadline/throttle.dot
Documentation/trace/rv/index.rst +1 -0
@@ -17,3 +17,4 @@ Runtime Verification monitor_sched.rst monitor_rtapp.rst monitor_stall.rst + monitor_deadline.rst
Documentation/trace/rv/monitor_deadline.rst new file +151 -0
151 lines not on this page · raw message
kernel/trace/rv/Kconfig +5 -0
@@ -79,6 +79,11 @@ source "kernel/trace/rv/monitors/sleep/Kconfig" # Add new rtapp monitors here source "kernel/trace/rv/monitors/stall/Kconfig" +source "kernel/trace/rv/monitors/deadline/Kconfig" +source "kernel/trace/rv/monitors/nomiss/Kconfig" +source "kernel/trace/rv/monitors/throttle/Kconfig" +# Add new deadline monitors here + # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +3 -0
@@ -18,6 +18,9 @@ obj-$(CONFIG_RV_MON_NRP) += monitors/nrp/nrp.o obj-$(CONFIG_RV_MON_SSSW) += monitors/sssw/sssw.o obj-$(CONFIG_RV_MON_OPID) += monitors/opid/opid.o obj-$(CONFIG_RV_MON_STALL) += monitors/stall/stall.o +obj-$(CONFIG_RV_MON_DEADLINE) += monitors/deadline/deadline.o +obj-$(CONFIG_RV_MON_NOMISS) += monitors/nomiss/nomiss.o +obj-$(CONFIG_RV_MON_THROTTLE) += monitors/throttle/throttle.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/deadline/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config RV_MON_DEADLINE + depends on RV + bool "deadline monitor" + help + Collection of monitors to check the deadline scheduler and server + behave according to specifications. Enable this to enable all + scheduler specification supported by the current kernel. + + For further information, see: + Documentation/trace/rv/monitor_deadline.rst
kernel/trace/rv/monitors/deadline/deadline.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/rv.h> + +#define MODULE_NAME "deadline" + +#include "deadline.h" + +struct rv_monitor rv_deadline = { + .name ="deadline" , + .description ="container for several deadline scheduler specifications." , + .enable =NULL , + .disable =NULL , + .reset =NULL , + .enabled =0 , +}; + +static int __init register_deadline (void ) +{ +return rv_register_monitor (&rv_deadline,NULL ); +} + +static void __exit unregister_deadline(void) +{ +rv_unregister_monitor (&rv_deadline); +} + +module_init (register_deadline); +module_exit (unregister_deadline); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Gabriele Monaco <[email protected]>" ); +MODULE_DESCRIPTION ("deadline: container for several deadline scheduler specifications." );
kernel/trace/rv/monitors/deadline/deadline.h new file +203 -0
203 lines not on this page · raw message
kernel/trace/rv/monitors/nomiss/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_NOMISS + depends on RV + depends on HAVE_SYSCALL_TRACEPOINTS + depends on RV_MON_DEADLINE + default y + select HA_MON_EVENTS_ID + bool "nomiss monitor" + help + Monitor to ensure dl entities run to completion before their deadiline. + This monitor is part of the deadline monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_deadline.rst
kernel/trace/rv/monitors/nomiss/nomiss.c new file +289 -0
289 lines not on this page · raw message
kernel/trace/rv/monitors/nomiss/nomiss.h new file +137 -0
137 lines not on this page · raw message
kernel/trace/rv/monitors/nomiss/nomiss_trace.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_NOMISS +DEFINE_EVENT (event_da_monitor_id, event_nomiss, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_nomiss, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); + +DEFINE_EVENT (error_env_da_monitor_id, error_env_nomiss, + TP_PROTO(int id, char *state, char *event, char *env), +TP_ARGS (id, state, event, env)); +#endif /* CONFIG_RV_MON_NOMISS */
kernel/trace/rv/monitors/throttle/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_THROTTLE + depends on RV + depends on HAVE_SYSCALL_TRACEPOINTS + depends on RV_MON_DEADLINE + default y + select HA_MON_EVENTS_ID + bool "throttle monitor" + help + Monitor to ensure dl entities are throttled when they use up their runtime. + This monitor is part of the deadline monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_deadline.rst
kernel/trace/rv/monitors/throttle/throttle.c new file +248 -0
248 lines not on this page · raw message
kernel/trace/rv/monitors/throttle/throttle.h new file +116 -0
116 lines not on this page · raw message
kernel/trace/rv/monitors/throttle/throttle_trace.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_THROTTLE +DEFINE_EVENT (event_da_monitor_id, event_throttle, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_throttle, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); + +DEFINE_EVENT (error_env_da_monitor_id, error_env_throttle, + TP_PROTO(int id, char *state, char *event, char *env), +TP_ARGS (id, state, event, env)); +#endif /* CONFIG_RV_MON_THROTTLE */
kernel/trace/rv/rv_trace.h +2 -0
@@ -188,6 +188,8 @@ DECLARE_EVENT_CLASS(error_env_da_monitor_id, );#include <monitors/stall/stall_trace.h> +#include <monitors/nomiss/nomiss_trace.h> +#include <monitors/throttle/throttle_trace.h> // Add new monitors based on CONFIG_HA_MON_EVENTS_ID here #endif
tools/verification/models/deadline/nomiss.dot new file +43 -0
43 lines not on this page · raw message
tools/verification/models/deadline/throttle.dot new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.52.0
Re: [PATCH v3 12/13] rv: Add deadline monitors
Quoted 10 lines · Gabriele Monaco
Add the deadline monitors collection to validate the deadline scheduler, both for deadline tasks and servers.
The currently implemented monitors are:
* throttle:
validate dl entities are throttled when they use up their runtime
* nomiss:
validate dl entities run to completion before their deadilineSigned-off-by Gabriele Monaco <[email protected]>
There are some helper functions that I am a bit uncomfortable with (e.g. pi_of, is_dl_boosted, dl_is_implicit, ...) because they are relying on implementation details of deadline scheduler which can be changed. So ideally this patch should have an Ack from the scheduler people.
I can't comment on the model, since I don't know scheduler. But from RV perspective:
Re: [PATCH v3 12/13] rv: Add deadline monitors
Quoted 10 lines · Nam Cao
Quoted 9 lines · Gabriele Monaco
Add the deadline monitors collection to validate the deadline scheduler, both for deadline tasks and servers.
The currently implemented monitors are:
* throttle:
validate dl entities are throttled when they use up their runtime
* nomiss:
validate dl entities run to completion before their deadiline
Quoted 6 lines
Quoted 1 line
Signed-off-by Gabriele Monaco <[email protected]>There are some helper functions that I am a bit uncomfortable with (e.g.
pi_of,is_dl_boosted,dl_is_implicit, ...) because they are relying on implementation details of deadline scheduler which can be changed. So ideally this patch should have an Ack from the scheduler people.
Think about this again, perhaps we should move all these helpers to include/linux/sched/deadline.h instead? The scheduler people must be aware of these functions, and maintain them. I don't want a situation where the scheduler people make changes, and something else (which they do not know exist) breaks.
Ideally, non-scheduler code should not look at private fields of scheduler's structs.
Nam
Gabriele Monaco
maintainerRe: [PATCH v3 12/13] rv: Add deadline monitors
Quoted 5 lines · Nam Cao
Quoted 4 lines · Nam Cao
There are some helper functions that I am a bit uncomfortable with (e.g.
pi_of,is_dl_boosted,dl_is_implicit, ...) because they are relying on implementation details of deadline scheduler which can be changed. So ideally this patch should have an Ack from the scheduler people.
Thanks for the review!
I'm going to ping scheduler guys some time after the holidays.
Quoted 5 lines
Think about this again, perhaps we should move all these helpers to
include/linux/sched/deadline.hinstead? The scheduler people must be aware of these functions, and maintain them. I don't want a situation where the scheduler people make changes, and something else (which they do not know exist) breaks.
That's a fair point, I just copied those functions from kernel/sched/deadline.c but that's dirty indeed.
Going to try exporting them to deadline.h and see if no one complains.
Quoted 2 lines
Ideally, non-scheduler code should not look at private fields of scheduler's structs.
Yeah, one may argue those modules shouldn't be doing what they're doing with the deadline entities. To be fair those modules are quite dependant on the data structure implementation, but the alternative would be to maintain a set of getter functions which might as well break.
Or at least I don't see a better way.
Thanks,
Gabriele
Gabriele Monaco
maintainerPATCH v3 13/13 Add dl_server specific monitors
In reply to Gabriele MonacoAdd monitors to validate the behaviour of the deadline server.
The currently implemented monitors are:
* boost
fair tasks run either independently or boosted
* laxity
deferrable servers wait for zero-laxity and run
--- Documentation/trace/rv/monitor_deadline.rst | 115 ++++++++ kernel/trace/rv/Kconfig | 2 + kernel/trace/rv/Makefile | 2 + kernel/trace/rv/monitors/boost/Kconfig | 15 + kernel/trace/rv/monitors/boost/boost.c | 279 ++++++++++++++++++ kernel/trace/rv/monitors/boost/boost.h | 159 ++++++++++ kernel/trace/rv/monitors/boost/boost_trace.h | 19 ++ kernel/trace/rv/monitors/laxity/Kconfig | 14 + kernel/trace/rv/monitors/laxity/laxity.c | 226 ++++++++++++++ kernel/trace/rv/monitors/laxity/laxity.h | 126 ++++++++ .../trace/rv/monitors/laxity/laxity_trace.h | 19 ++ kernel/trace/rv/rv_trace.h | 2 + tools/verification/models/deadline/boost.dot | 51 ++++ tools/verification/models/deadline/laxity.dot | 34 +++ 14 files changed, 1063 insertions(+) create mode 100644 kernel/trace/rv/monitors/boost/Kconfig create mode 100644 kernel/trace/rv/monitors/boost/boost.c create mode 100644 kernel/trace/rv/monitors/boost/boost.h create mode 100644 kernel/trace/rv/monitors/boost/boost_trace.h create mode 100644 kernel/trace/rv/monitors/laxity/Kconfig create mode 100644 kernel/trace/rv/monitors/laxity/laxity.c create mode 100644 kernel/trace/rv/monitors/laxity/laxity.h create mode 100644 kernel/trace/rv/monitors/laxity/laxity_trace.h create mode 100644 tools/verification/models/deadline/boost.dot create mode 100644 tools/verification/models/deadline/laxity.dot
Documentation/trace/rv/monitor_deadline.rst +115 -0
@@ -149,3 +149,118 @@ replenish on an idle CPU, meaningful only for servers:: +---------------+ <-+ ^ | | +---------------- dl_throttle;is_constr_dl == 1 -------------+ + +Monitor boost +~~~~~~~~~~~~~ + +The boost monitor ensures tasks associated to a server (e.g. fair tasks) run +either independently or boosted in a timely manner. +Unlike other models, the ``running`` state (and the ``switch_in/out`` events) +indicates that any fair task is running, this needs to happen within a +threshold that depends on server deadline and remaining runtime, whenever a +task is ready. + +The following chart is simplified to avoid confusion, several less important +self-loops on states have been removed and event names have been simplified: + +* ``idle`` (``dl_server_idle``) occurs when the CPU runs the idle task. +* ``start/stop`` (``dl_server_start/stop``) start and stop the server. +* ``switch`` (``sched_switch_in/out``) represented as a double arrow to + indicate both events are present: ``ready/throttled -- switch_in -> + running/throttled_running`` and vice versa with ``switch_out``. As stated + above this fires when any fair task starting or stopping to run. +* ``resume/resume_throttle``: a fair task woke up, potentially when the server + is throttled (no runtime left), this event is especially frequent on self + loops (no state change during a wakeup) but is removed here for clarity. +* arrows merges with an ``x`` sign to indicate they are the same event going to + the same state (but with different origins). The ``+`` sign indicates normal + crossings or corners. + +Refer to the dot file for the full specification:: + + | + v + #=========# idle +----------+ + H H <----- switch_out ----- | | + +-->H stopped H | stopping | + | H H --+ | | + | #=========# | +----------+ + | ^ | ^ + | | | stop;reset(clk) | replenish;reset(clk) + | stop | | +--+ + | | start;reset(clk) +--------------------+ | | + | | v | | v + | +--------- +---------------+ <---------- switch --------> +---------+ + | | ready | | | + | +- resume -> | | -replenish;reset(clk) | running | + | | | clk < thesh() | | | | + | | +- idle - +---------------+ <-+ +---------------- +---------+ + | | | | ^ | ^ | + | | | | | throttle | | + | | | | |replenish;reset(clk) | | | + | | | throttle | | replenish;reset(clk) | + | | | | | | | | + | | | v | v | | + | | | +---------+ switch +-------------------+ | | + x---+--+-- | | <----------> | throttled_running | --------+ | + | | | |throttled| +-------------------+ | + | | | | | -----+ | | + | | | +---------+ | | | + | | | ^ | | | + | | | resume_throttle | | | + stop | | | | | | + | | v | | | | + | +---------+ <-----------x--- idle ---x-----------------------------+ + | | | + +-- | idle | <--+ + | | | replenish;reset(clk) + +---------+ ---+ + +Monitor laxity +~~~~~~~~~~~~~~ + +The laxity monitor ensure deferrable servers go to a zero-laxity wait unless +already running and run in starvation cases. The model can stay in the +zero-laxity wait only for a limited time depending on deadline and runtime, +then the server either prepares to stop (after ``idle_wait``) or prepares to +boost a task (``running``). Boosting (``sched_switch_in``) is only allowed in +the ``running`` state:: + + | + +----- dl_server_stop -----+ | + | v v + | #=======================================# + | +------- H stopped H + | | #=======================================# + | | | ^ + | | dl_server_start_running; dl_server_stop + | | reset(clk) | + | | v | dl_replenish_running; + | | +-------------------------------------+ clk < REPLENISH_NS + | | | | -------------+ + | | | running | | + | | | | <------------+ + | | +-------------------------------------+ + | | | ^ ^ + | | dl_throttle dl_replenish_running | + | | v | | + | | +-----------------+ | | + | | | replenish_wait | -+ | + | | +-----------------+ | + | | | | + | | dl_replenish;reset(clk) | dl_replenish_running + | | dl_replenish_idle;reset(clk) | + | | v | + | dl_server_start; +--------------------------+ dl_replenish;reset(clk) + | reset(clk) | zero_laxity_wait | -------------+ + | | | clk < laxity_ns() | | + | +---------------> | | <------------+ + | +--------------------------+ + | | ^ + | dl_replenish_idle;reset(clk) | dl_replenish;reset(clk) + | v | + | +-------------------------+ | + +------------------ | idle_wait | -+ + +-------------------------+ + ^ dl_replenish_idle;reset(clk) + +-------------+
kernel/trace/rv/Kconfig +2 -0
@@ -82,6 +82,8 @@ source "kernel/trace/rv/monitors/stall/Kconfig" source "kernel/trace/rv/monitors/deadline/Kconfig" source "kernel/trace/rv/monitors/nomiss/Kconfig" source "kernel/trace/rv/monitors/throttle/Kconfig" +source "kernel/trace/rv/monitors/boost/Kconfig" +source "kernel/trace/rv/monitors/laxity/Kconfig" # Add new deadline monitors here # Add new monitors here
kernel/trace/rv/Makefile +2 -0
@@ -21,6 +21,8 @@ obj-$(CONFIG_RV_MON_STALL) += monitors/stall/stall.o obj-$(CONFIG_RV_MON_DEADLINE) += monitors/deadline/deadline.o obj-$(CONFIG_RV_MON_NOMISS) += monitors/nomiss/nomiss.o obj-$(CONFIG_RV_MON_THROTTLE) += monitors/throttle/throttle.o +obj-$(CONFIG_RV_MON_BOOST) += monitors/boost/boost.o +obj-$(CONFIG_RV_MON_LAXITY) += monitors/laxity/laxity.o # Add new monitors here obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o
kernel/trace/rv/monitors/boost/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_BOOST + depends on RV + depends on RV_MON_DEADLINE + default y + select HA_MON_EVENTS_ID + bool "boost monitor" + help + Monitor to ensure tasks associated to a server (e.g. fair tasks) run + either independently or boosted in a timely manner. + This monitor is part of the deadline monitors collection. + + For further information, see: + Documentation/trace/rv/monitor_deadline.rst
kernel/trace/rv/monitors/boost/boost.c new file +279 -0
279 lines not on this page · raw message
kernel/trace/rv/monitors/boost/boost.h new file +159 -0
159 lines not on this page · raw message
kernel/trace/rv/monitors/boost/boost_trace.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_BOOST +DEFINE_EVENT (event_da_monitor_id, event_boost, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_boost, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); + +DEFINE_EVENT (error_env_da_monitor_id, error_env_boost, + TP_PROTO(int id, char *state, char *event, char *env), +TP_ARGS (id, state, event, env)); +#endif /* CONFIG_RV_MON_BOOST */
kernel/trace/rv/monitors/laxity/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +config RV_MON_LAXITY + depends on RV + depends on RV_MON_DEADLINE + default y + select HA_MON_EVENTS_ID + bool "laxity monitor" + help + Monitor to ensure deferrable servers go to a zero-laxity wait unless + already running and run in starvation cases. + + For further information, see: + Documentation/trace/rv/monitor_deadline.rst
kernel/trace/rv/monitors/laxity/laxity.c new file +226 -0
226 lines not on this page · raw message
kernel/trace/rv/monitors/laxity/laxity.h new file +126 -0
126 lines not on this page · raw message
kernel/trace/rv/monitors/laxity/laxity_trace.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Snippet to be included in rv_trace.h +*/ + +#ifdef CONFIG_RV_MON_LAXITY +DEFINE_EVENT (event_da_monitor_id, event_laxity, + TP_PROTO(int id, char *state, char *event, char *next_state, bool final_state), +TP_ARGS (id, state, event, next_state, final_state)); + +DEFINE_EVENT (error_da_monitor_id, error_laxity, + TP_PROTO(int id, char *state, char *event), +TP_ARGS (id, state, event)); + +DEFINE_EVENT (error_env_da_monitor_id, error_env_laxity, + TP_PROTO(int id, char *state, char *event, char *env), +TP_ARGS (id, state, event, env)); +#endif /* CONFIG_RV_MON_LAXITY */
kernel/trace/rv/rv_trace.h +2 -0
@@ -190,6 +190,8 @@ DECLARE_EVENT_CLASS(error_env_da_monitor_id,#include <monitors/stall/stall_trace.h> #include <monitors/nomiss/nomiss_trace.h> #include <monitors/throttle/throttle_trace.h> +#include <monitors/boost/boost_trace.h> +#include <monitors/laxity/laxity_trace.h> // Add new monitors based on CONFIG_HA_MON_EVENTS_ID here #endif
tools/verification/models/deadline/boost.dot new file +51 -0
51 lines not on this page · raw message
tools/verification/models/deadline/laxity.dot new file +34 -0
@@ -0,0 +1,34 @@ +digraph state_automaton { + center = true; + size = "7,11"; + {node [shape = circle] "idle_wait"}; + {node [shape = circle] "replenish_wait"}; + {node [shape = circle] "running"}; + {node [shape = plaintext, style=invis, label=""] "__init_stopped"}; + {node [shape = doublecircle] "stopped"}; + {node [shape = circle] "stopped"}; + {node [shape = circle] "zero_laxity_wait"}; + "__init_stopped" -> "stopped"; + "idle_wait" [label = "idle_wait"]; + "idle_wait" -> "idle_wait" [ label = "dl_replenish_idle;reset(clk)" ]; + "idle_wait" -> "stopped" [ label = "dl_server_stop" ]; + "idle_wait" -> "zero_laxity_wait" [ label = "dl_replenish;reset(clk)" ]; + "replenish_wait" [label = "replenish_wait"]; + "replenish_wait" -> "running" [ label = "dl_replenish_running" ]; + "replenish_wait" -> "zero_laxity_wait" [ label = "dl_replenish;reset(clk)\ndl_replenish_idle;reset(clk)" ]; + "running" [label = "running"]; + "running" -> "replenish_wait" [ label = "dl_throttle" ]; + "running" -> "running" [ label = "dl_replenish_running;clk < REPLENISH_NS" ]; + "running" -> "stopped" [ label = "dl_server_stop" ]; + "stopped" [label = "stopped", color = green3]; + "stopped" -> "running" [ label = "dl_server_start_running;reset(clk)" ]; + "stopped" -> "zero_laxity_wait" [ label = "dl_server_start;reset(clk)" ]; + "zero_laxity_wait" [label = "zero_laxity_wait\nclk < laxity_ns()"]; + "zero_laxity_wait" -> "idle_wait" [ label = "dl_replenish_idle;reset(clk)" ]; + "zero_laxity_wait" -> "running" [ label = "dl_replenish_running" ]; + "zero_laxity_wait" -> "zero_laxity_wait" [ label = "dl_replenish;reset(clk)" ]; + { rank = min ; + "__init_stopped"; + "stopped"; + } +}
Signature · 1 line
2.52.0
Re: [PATCH v3 13/13] rv: Add dl_server specific monitors
Quoted 9 lines · Gabriele Monaco
Add monitors to validate the behaviour of the deadline server.
The currently implemented monitors are:
* boost
fair tasks run either independently or boosted
* laxity
deferrable servers wait for zero-laxity and runSigned-off-by Gabriele Monaco <[email protected]>
Same remarks in "[PATCH v3 12/13] rv: Add deadline monitors" apply.