Add Hybrid Automata monitor type, per-object and deadline monitors
Subsystems (4)
Gabriele Monaco
maintainerv8 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 nomiss monitor to validate timing aspects of the deadline scheduler, as it works for tasks and servers, it's inclusion requires also per-object monitors (for dl entities).
Note: this submission removed all patches depending on enqueue/dequeue tracepoints. The current series is ready for inclusion while the other patches will be submitted separately.
The entire series can also be found on:
git.kernel.org/pub/scm/linux/kernel/git/gmonaco/linux.git rv_hybrid_automata
Changes since V7:
* Fix wrong title in monitor_deadline docs
* Warn if kallsyms lookup fails
* Minor improvement in hybrid automata docs
* Use u8 instead of uint8_t in deadline tracepoints and models
* Drop enqueue/dequeue tracepoints and dependent patches from the series, will submit separately
[1] - https://lore.kernel.org/lkml/[email protected]
To: Steven Rostedt <[email protected]>
To: Nam Cao <[email protected]>
To: Juri Lelli <[email protected]>
Cc: Tomas Glozar <[email protected]>
Cc: Clark Williams <[email protected]>
Cc: John Kacur <[email protected]>
Cc: [email protected]
Gabriele Monaco (12):
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 monitor stall
rv: Convert the opid monitor to a hybrid automaton
rv: Add support for per-object monitors in DA/HA verification/rvgen: Add support for per-obj monitors
sched: Add deadline tracepoints
sched/deadline: Move some utility functions to deadline.h
rv: Add nomiss deadline monitor
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 | 84 +++ 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/linux/sched/deadline.h | 27 + include/rv/da_monitor.h | 644 +++++++++++++----- include/rv/ha_monitor.h | 478 +++++++++++++ include/trace/events/sched.h | 26 + kernel/sched/core.c | 5 + kernel/sched/deadline.c | 51 +- kernel/trace/rv/Kconfig | 18 + kernel/trace/rv/Makefile | 3 + kernel/trace/rv/monitors/deadline/Kconfig | 10 + kernel/trace/rv/monitors/deadline/deadline.c | 44 ++ kernel/trace/rv/monitors/deadline/deadline.h | 202 ++++++ kernel/trace/rv/monitors/nomiss/Kconfig | 15 + kernel/trace/rv/monitors/nomiss/nomiss.c | 293 ++++++++ kernel/trace/rv/monitors/nomiss/nomiss.h | 123 ++++ .../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/rv_trace.h | 67 +- tools/verification/models/deadline/nomiss.dot | 41 ++ 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 | 151 +++- tools/verification/rvgen/rvgen/dot2c.py | 47 ++ tools/verification/rvgen/rvgen/dot2k.py | 489 ++++++++++++- tools/verification/rvgen/rvgen/generator.py | 4 +- .../rvgen/rvgen/templates/dot2k/main.c | 2 +- .../rvgen/templates/dot2k/trace_hybrid.h | 16 + 44 files changed, 3605 insertions(+), 447 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/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/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/deadline/nomiss.dot create mode 100644 tools/verification/models/stall.dot create mode 100644 tools/verification/rvgen/rvgen/templates/dot2k/trace_hybrid.h
base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
Signature · 1 line
2.53.0
Gabriele Monaco
maintainerPATCH v8 1/12 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 struct while others do not.
Unify the functions, handle the difference by always passing an identifier which is the task's pid for per-task monitors but is ignored for the other types. Only keep the actual tracepoint calling separated.
--- include/rv/da_monitor.h | 303 +++++++++++++++++----------------------- 1 file changed, 132 insertions(+), 171 deletions(-)
include/rv/da_monitor.h +132 -171
@@ -28,6 +28,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,
@@ -97,90 +104,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.
@@ -335,115 +258,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); }/*
@@ -459,21 +446,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); }/*
@@ -485,19 +458,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.53.0
Gabriele Monaco
maintainerPATCH v8 2/12 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.
--- include/linux/rv.h | 38 +++ include/rv/da_monitor.h | 73 +++++- include/rv/ha_monitor.h | 475 +++++++++++++++++++++++++++++++++++++ kernel/trace/rv/Kconfig | 13 + kernel/trace/rv/rv_trace.h | 63 +++++ 5 files changed, 658 insertions(+), 4 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 +69 -4
134 lines not on this page · raw message
include/rv/ha_monitor.h new file +475 -0
475 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.53.0
Gabriele Monaco
maintainerPATCH v8 3/12 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.53.0
Gabriele Monaco
maintainerPATCH v8 4/12 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 | 146 +++++- tools/verification/rvgen/rvgen/dot2c.py | 47 ++ tools/verification/rvgen/rvgen/dot2k.py | 474 +++++++++++++++++- tools/verification/rvgen/rvgen/generator.py | 2 + .../rvgen/rvgen/templates/dot2k/main.c | 2 +- .../rvgen/templates/dot2k/trace_hybrid.h | 16 + 7 files changed, 679 insertions(+), 16 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 +136 -10
211 lines not on this page · raw message
tools/verification/rvgen/rvgen/dot2c.py +47 -0
81 lines not on this page · raw message
tools/verification/rvgen/rvgen/dot2k.py +472 -2
517 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.53.0
[email protected]
AI reviewRe: [PATCH v8 04/12] verification/rvgen: Add support for Hybrid Automata
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [High] Spurious invalidity checks generated due to naive substring matching. - [High] State-specific…
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] Spurious invalidity checks generated due to naive substring matching.
- [High] State-specific self-loop resets are applied globally, causing improper invariant timer restarts.
- [High] Incorrect tracepoint class returned by fill_monitor_class, leading to compilation failures.
- [Medium] Premature truncation of BFS algorithm in __find_inv_conflicts.
- [Medium] Regex constraint_rule fails to parse valid single-character variables and identifiers containing digits.
- [Medium] Multiple state invariants separated by logical operators are silently truncated.
- [Medium] Substring matching for clock resets in __find_inv_conflicts yields false positives. --
--- Patch [4]: [PATCH v8 04/12] verification/rvgen: Add support for Hybrid Automata --- commit 12c92be15261e4701023aceb7f2bd71c606ecce3
Author: Gabriele Monaco <[email protected]>
verification/rvgen: Add support for Hybrid Automata
Add the possibility to parse dot files as hybrid automata and generate the necessary code from rvgen.
Quoted 3 lines
tools/verification/rvgen/rvgen/automata.py +0
-0
[ ... ]
Quoted 5 lines
tools/verification/rvgen/rvgen/automata.py +5
-0+ # val can be numerical, uppercase (constant or macro), lowercase (parameter or function) + # only numerical values should have units + constraint_rule = re.compile(r""" + ^ + (?P<env>[a-zA-Z_][a-zA-Z0-9_]+) # C-like identifier for the env var
tools/verification/rvgen/rvgen/automata.py line 52
Quoted 10 lines
tools/verification/rvgen/rvgen/automata.py +10
-0+ (?P<op>[!<=>]{1,2}) # operator + (?P<val> + [0-9]+ | # numerical value + [A-Z_]+\(\) | # macro + [A-Z_]+ | # constant + [a-z_]+\(\) | # function + [a-z_]+ # parameter + ) + (?P<unit>[a-z]{1,2})? # optional unit for numerical values + """, re.VERBOSE)
[Severity: Medium]
Could this regular expression reject valid single-character variables?
The pattern requires environment variables to be at least two characters long, which rejects single-letter variables like 'x' or 't'.
Additionally, does the value matching group (?P<val> ...) correctly handle digits in constant, macro, function, or parameter names? The current character sets [a-z_]+ and [A-Z_]+ appear to exclude numbers.
[ ... ]
Quoted 12 lines
tools/verification/rvgen/rvgen/automata.py +1
-0@@ -157,6 +260,7 @@ class Automata: # declare the matrix.... matrix = [[ self.invalid_state_str for x in range(nr_event)] for y in range(nr_state)] + constraints: dict[_ConstraintKey, list[str]] = {} # and we are back! Let's fill the matrix cursor = self.__get_cursor_begin_events()@@ -166,12 +270,24 @@ class Automata: line = self.__dot_lines[cursor].split() origin_state = line[0].replace('"','').replace(',','_') dest_state = line[2].replace('"','').replace(',','_')
tools/verification/rvgen/rvgen/automata.py class Automata: · line 281
Quoted 10 lines
tools/verification/rvgen/rvgen/automata.py +8
-1- possible_events = "".join(line[line.index("label")+2:-1]).replace('"', '') + possible_events = "".join(line[line.index("label") + 2:-1]).replace('"', '') for event in possible_events.split("\\n"): + event, *constr = event.split(";") + if constr: + key = _EventConstraintKey(states_dict[origin_state], events_dict[event]) + constraints[key] = constr + # those events reset also on self loops + if origin_state == dest_state and "reset" in "".join(constr): + self.self_loop_reset_events.add(event)
[Severity: High]
Does recording these events globally create issues when the same event triggers different behavior in other states?
When an event triggers a variable reset on a self-loop, it is recorded by name in the global self_loop_reset_events set without associating it with the specific state where the reset occurs.
Quoted 3 lines
tools/verification/rvgen/rvgen/dot2k.py +0
-0
[ ... ]
Quoted 11 lines
tools/verification/rvgen/rvgen/dot2k.py +11
-0+class ha2k(dot2k): + """Hybrid automata only""" + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if not self.is_hybrid_automata(): + raise ValueError("Detected deterministic automata, use the 'da' class") + self.trace_h = self._read_template_file("trace_hybrid.h") + self.__parse_constraints() + + def fill_monitor_class_type(self) -> str: + if self.monitor_type == "per_task":
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 182
Quoted 10 lines
tools/verification/rvgen/rvgen/dot2k.py +10
-0+ return "HA_MON_EVENTS_ID" + return "HA_MON_EVENTS_IMPLICIT" + + def fill_monitor_class(self) -> str: + """ + Used for tracepoint classes, since they are shared we keep da + instead of ha (also for the ha specific tracepoints). + The tracepoint class is not visible to the tools. + """ + return super().fill_monitor_class()
[Severity: High]
Does this method return the correct tracepoint class?
The docstring mentions keeping 'da' instead of 'ha' because tracepoint classes are shared. However, calling super().fill_monitor_class() returns self.monitor_class, which is set to 'ha' for this subclass.
This generates DEFINE_EVENT(error_ha, ...) in the C code, but the error_ha tracepoint class is not declared in the kernel headers, which expect error_da. Could this lead to compilation failures?
[ ... ]
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 245
Quoted 11 lines
tools/verification/rvgen/rvgen/dot2k.py +11
-0+ def __format_guard_rules(self, rules: list[str]) -> list[str]: + """ + Merge guard constraints as a single C return statement. + If the rules include a stored env, also check its validity. + Break lines in a best effort way that tries to keep readability. + """ + if not rules: + return [] + + invalid_checks = [f"ha_monitor_env_invalid(ha_mon, {env}{self.enum_suffix}) ||" + for env in self.env_stored if any(env in rule for rule in rules)]
[Severity: High]
Can this substring check incorrectly match unrelated variables in the generated C code?
The expression "env in rule" checks if the variable name is a substring of the generated C code. If env is a short string like "i", it will match inside unrelated words like "time_ns".
This could inject spurious ha_monitor_env_invalid() checks for the wrong environment variables. If those variables are uninitialized, the condition short-circuits to true, incorrectly allowing state transitions.
[ ... ]
Quoted 7 lines
tools/verification/rvgen/rvgen/dot2k.py +7
-0+ def __parse_constraints(self) -> None: + self.guards: dict[_EventConstraintKey, str] = {} + self.invariants: dict[_StateConstraintKey, str] = {} + for key, constraint in self.constraints.items(): + rules = [] + resets = [] + for c, sep in self._split_constraint_expr(constraint):
[ ... ]
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 310
Quoted 5 lines
tools/verification/rvgen/rvgen/dot2k.py +5
-0+ if self.is_event_constraint(key): + res = self.__format_guard_rules(rules) + resets + self.guards[key] = ";".join(res) + else: + self.invariants[key] = rules[0]
[Severity: Medium]
Are subsequent rules silently ignored here?
When parsing state invariants with multiple rules separated by logical operators, this assignment only stores the first parsed rule and discards the rest.
Does this mean the generated monitor might fail to enforce all specified invariants?
[ ... ]
Quoted 20 lines
tools/verification/rvgen/rvgen/dot2k.py +20
-0+ def __find_inv_conflicts(self) -> tuple[set[tuple[int, _EventConstraintKey]], + set[tuple[int, _StateConstraintKey]]]: + """ + Run a breadth first search from all states with an invariant. + Find any conflicting constraints reachable from there, this can be + another state with an invariant or an edge with a non-reset guard. + Stop when we find a reset. + + Return the set of conflicting guards and invariants as tuples of + conflicting state and constraint key. + """ + conflict_guards: set[tuple[int, _EventConstraintKey]] = set() + conflict_invs: set[tuple[int, _StateConstraintKey]] = set() + for start_idx in self.invariants: + queue = deque([(start_idx, 0)]) # (state_idx, distance) + env = self.__get_constraint_env(self.invariants[start_idx]) + + while queue: + curr_idx, distance = queue.popleft() +
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 426
Quoted 10 lines
tools/verification/rvgen/rvgen/dot2k.py +10
-0+ # Check state condition + if curr_idx != start_idx and curr_idx in self.invariants: + conflict_invs.add((start_idx, _StateConstraintKey(curr_idx))) + continue + + # Check if we should stop + if distance > len(self.states): + break + if curr_idx != start_idx and distance > 1: + continue
[Severity: Medium]
Does this condition prematurely stop the breadth-first search?
The BFS algorithm appears designed to explore paths up to len(self.states) deep, but this check restricts the search to depth 1.
Any paths longer than 1 edge are not explored, which might cause the generator to silently miss required invariant-to-guard conversions.
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 433
Quoted 7 lines
tools/verification/rvgen/rvgen/dot2k.py +7
-0+ + for event_idx, next_state_name in enumerate(self.function[curr_idx]): + if next_state_name == self.invalid_state_str: + continue + curr_guard = self.guards.get((curr_idx, event_idx), "") + if "reset" in curr_guard and env in curr_guard: + continue
[Severity: Medium]
Could this naive substring search yield false positives?
If env is a short string like "t", and curr_guard contains a reset for a completely different variable like "time_ns" or "limit", the substring check evaluates to true.
This might wrongly signal that the target variable was reset, causing the conflict detection loop to skip generating necessary timer conversions.
[ ... ]
Quoted 4 lines
tools/verification/rvgen/rvgen/dot2k.py +4
-0+ def __fill_setup_invariants_func(self) -> list[str]: + buff = [] + if not self.invariants: + return []
tools/verification/rvgen/rvgen/dot2k.py class dot2k(Monitor, Dot2c): · line 458
Quoted 10 lines
tools/verification/rvgen/rvgen/dot2k.py +10
-0+ + buff.append( +f"""static inline void ha_setup_invariants(struct ha_monitor *ha_mon, +\t\t\t\t enum {self.enum_states_def} curr_state, enum {self.enum_events_def} event, +\t\t\t\t enum {self.enum_states_def} next_state, u64 time_ns) +{{""") + + conditions = ["next_state == curr_state"] + conditions += [f"event != {e}{self.enum_suffix}" + for e in self.self_loop_reset_events]
[Severity: High]
Could this cause unintended timer restarts?
Because the self_loop_reset_events set records events globally, if any self-loop occurs with this event name, the generated monitor bypasses the early return and restarts the invariant timer for the current state.
This means a self-loop reset intended for state A might erroneously restart the timer in state B, masking potential timing violations.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Gabriele Monaco
maintainerPATCH v8 5/12 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:
V8:
* Minor improvement in docs
.../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.53.0
Gabriele Monaco
maintainerPATCH v8 6/12 Add sample hybrid monitor 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.
--- 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,3 +16,4 @@ Runtime verification (rv) tool rv-mon-wip rv-mon-wwnr rv-mon-sched + rv-mon-stall
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.53.0
Gabriele Monaco
maintainerPATCH v8 7/12 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.53.0
Gabriele Monaco
maintainerPATCH v8 8/12 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).
--- 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
@@ -190,7 +190,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.53.0
Gabriele Monaco
maintainerPATCH v8 9/12 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:
V6:
* Use f-strings in newly added code and cleanup
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(f"\tda_{handle}(id, t, {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.53.0
Gabriele Monaco
maintainerPATCH v8 10/12 sched: Add deadline tracepoints
In reply to Gabriele MonacoAdd the following tracepoints:
* sched_dl_throttle(dl_se, cpu, type):
Called when a deadline entity is throttled
* sched_dl_replenish(dl_se, cpu, type):
Called when a deadline entity's runtime is replenished
* sched_dl_update(dl_se, cpu, type):
Called when a deadline entity updates without throttle or replenish
* sched_dl_server_start(dl_se, cpu, type):
Called when a deadline server is started
* sched_dl_server_stop(dl_se, cpu, type):
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:
V8:
* Use u8 instead of uint8_t
V7:
* Export sched_dl_update to modules and fix style V6:
* Add dl_se type to differentiate between fair and ext servers
* Add event to track dl_update_curr not firing other events
include/trace/events/sched.h | 26 ++++++++++++++++++++++++++ kernel/sched/core.c | 5 +++++ kernel/sched/deadline.c | 23 +++++++++++++++++++++++ 3 files changed, 54 insertions(+)
include/trace/events/sched.h +26 -0
@@ -896,6 +896,32 @@ DECLARE_TRACE(sched_set_need_resched, TP_PROTO(struct task_struct *tsk, int cpu, int tif), TP_ARGS(tsk, cpu, tif)); +#define DL_OTHER 0 +#define DL_TASK 1 +#define DL_SERVER_FAIR 2 +#define DL_SERVER_EXT 3 + +DECLARE_TRACE (sched_dl_throttle, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type), +TP_ARGS (dl_se, cpu, type)); + +DECLARE_TRACE (sched_dl_replenish, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type), +TP_ARGS (dl_se, cpu, type)); + +/* Call to update_curr_dl_se not involving throttle or replenish */ +DECLARE_TRACE (sched_dl_update, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type), +TP_ARGS (dl_se, cpu, type)); + +DECLARE_TRACE (sched_dl_server_start, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type), +TP_ARGS (dl_se, cpu, type)); + +DECLARE_TRACE (sched_dl_server_stop, + TP_PROTO(struct sched_dl_entity *dl_se, int cpu, u8 type), +TP_ARGS (dl_se, cpu, type)); +#endif /* _TRACE_SCHED_H */ /* This part must be outside protection */
kernel/sched/core.c +5 -0
@@ -122,6 +122,11 @@ 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_update_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 +23 -0
@@ -115,6 +115,19 @@ static inline bool is_dl_boosted(struct sched_dl_entity *dl_se) }#endif /* !CONFIG_RT_MUTEXES */ +static inline u8 dl_get_type (struct sched_dl_entity *dl_se,struct rq *rq) +{ +if (!dl_server (dl_se)) +return DL_TASK ; +if (dl_se == &rq->fair_server) +return DL_SERVER_FAIR ; +#ifdef CONFIG_SCHED_CLASS_EXT +if (dl_se == &rq->ext_server) +return DL_SERVER_EXT ; +#endif +return DL_OTHER ; +} +static inline struct dl_bw *dl_bw_of (int i) { RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
@@ -733,6 +746,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),dl_get_type (dl_se, rq)); }/*
@@ -848,6 +862,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),dl_get_type (dl_se, rq)); +/* * If this is the replenishment of a deferred reservation, * clear the flag and return.
@@ -1345,6 +1361,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_get_type (dl_se, rq)); dl_se->dl_throttled =1 ;if (dl_se->runtime >0 ) dl_se->runtime =0 ;
@@ -1508,6 +1525,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_get_type (dl_se, rq)); dl_se->dl_throttled =1 ;/* If requested, inform the user about runtime overruns. */
@@ -1532,6 +1550,8 @@ static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64if (!is_leftmost (dl_se, &rq->dl))resched_curr (rq); + }else { +trace_sched_dl_update_tp (dl_se,cpu_of (rq),dl_get_type (dl_se, rq)); }/*
@@ -1810,6 +1830,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_get_type (dl_se, 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))
@@ -1821,6 +1842,8 @@ 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), +dl_get_type (dl_se, 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.53.0
Gabriele Monaco
maintainerPATCH v8 11/12 sched/deadline: Move some utility functions to deadline.h
In reply to Gabriele MonacoSome utility functions on sched_dl_entity can be useful outside of deadline.c , for instance for modelling, without relying on raw structure fields.
Move functions like dl_task_of and dl_is_implicit to deadline.h to make them available outside.
--- include/linux/sched/deadline.h | 27 +++++++++++++++++++++++++++ kernel/sched/deadline.c | 28 +--------------------------- 2 files changed, 28 insertions(+), 27 deletions(-)
include/linux/sched/deadline.h +27 -0
@@ -37,4 +37,31 @@ extern void dl_clear_root_domain_cpu(int cpu);extern u64 dl_cookie;extern bool dl_bw_visited (int cpu,u64 cookie); +static inline bool dl_server (struct sched_dl_entity *dl_se) +{ +return dl_se->dl_server; +} + +static inline struct task_struct *dl_task_of (struct sched_dl_entity *dl_se) +{ +BUG_ON (dl_server (dl_se)); + return container_of(dl_se, struct task_struct, dl); +} + +/* +* Regarding the deadline, a task with implicit deadline has a relative +* deadline == relative period. A task with constrained deadline has a +* relative deadline <= relative period. +* +* We support constrained deadline tasks. However, there are some restrictions +* applied only for tasks which do not have an implicit deadline. See +* update_dl_entity() to know more about such restrictions. +* +* The dl_is_implicit() returns true if the task has an implicit deadline. +*/ +static inline bool dl_is_implicit (struct sched_dl_entity *dl_se) +{ +return dl_se->dl_deadline == dl_se->dl_period; +} +#endif /* _LINUX_SCHED_DEADLINE_H */
kernel/sched/deadline.c +1 -27
@@ -18,6 +18,7 @@#include <linux/cpuset.h> #include <linux/sched/clock.h> +#include <linux/sched/deadline.h> #include <uapi/linux/sched/types.h> #include "sched.h" #include "pelt.h"
@@ -57,17 +58,6 @@ static int __init sched_dl_sysctl_init(void)late_initcall (sched_dl_sysctl_init);#endif /* CONFIG_SYSCTL */ -static bool dl_server (struct sched_dl_entity *dl_se) -{ -return dl_se->dl_server; -} - -static inline struct task_struct *dl_task_of (struct sched_dl_entity *dl_se) -{ -BUG_ON (dl_server (dl_se)); - return container_of(dl_se, struct task_struct, dl); -} -static inline struct rq *rq_of_dl_rq (struct dl_rq *dl_rq) { return container_of(dl_rq, struct rq, dl);
@@ -990,22 +980,6 @@ update_dl_revised_wakeup(struct sched_dl_entity *dl_se, struct rq *rq) dl_se->runtime = (dl_se->dl_density * laxity) >>BW_SHIFT ; } -/* -* Regarding the deadline, a task with implicit deadline has a relative -* deadline == relative period. A task with constrained deadline has a -* relative deadline <= relative period. -* -* We support constrained deadline tasks. However, there are some restrictions -* applied only for tasks which do not have an implicit deadline. See -* update_dl_entity() to know more about such restrictions. -* -* The dl_is_implicit() returns true if the task has an implicit deadline. -*/ -static inline bool dl_is_implicit (struct sched_dl_entity *dl_se) -{ -return dl_se->dl_deadline == dl_se->dl_period; -} -/* * When a deadline entity is placed in the runqueue, its runtime and deadline * might need to be updated. This is done by a CBS wake up rule. There are two
Signature · 1 line
2.53.0
Gabriele Monaco
maintainerPATCH v8 12/12 Add nomiss deadline monitor
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:
* nomiss:
validate dl entities run to completion before their deadiline
---
Notes:
V8:
* Warn if kallsyms lookup fails
* Use u8 instead of uint8_t
* Drop throttle monitor, will submit separately
Documentation/trace/rv/index.rst | 1 + Documentation/trace/rv/monitor_deadline.rst | 84 +++++ kernel/trace/rv/Kconfig | 4 + kernel/trace/rv/Makefile | 2 + kernel/trace/rv/monitors/deadline/Kconfig | 10 + kernel/trace/rv/monitors/deadline/deadline.c | 44 +++ kernel/trace/rv/monitors/deadline/deadline.h | 202 ++++++++++++ kernel/trace/rv/monitors/nomiss/Kconfig | 15 + kernel/trace/rv/monitors/nomiss/nomiss.c | 293 ++++++++++++++++++ kernel/trace/rv/monitors/nomiss/nomiss.h | 123 ++++++++ .../trace/rv/monitors/nomiss/nomiss_trace.h | 19 ++ kernel/trace/rv/rv_trace.h | 1 + tools/verification/models/deadline/nomiss.dot | 41 +++ 13 files changed, 839 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 tools/verification/models/deadline/nomiss.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 +84 -0
84 lines not on this page · raw message
kernel/trace/rv/Kconfig +4 -0
@@ -79,6 +79,10 @@ 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" +# Add new deadline monitors here + # Add new monitors here config RV_REACTORS
kernel/trace/rv/Makefile +2 -0
@@ -18,6 +18,8 @@ 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 # 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 +44 -0
44 lines not on this page · raw message
kernel/trace/rv/monitors/deadline/deadline.h new file +202 -0
202 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 +293 -0
293 lines not on this page · raw message
kernel/trace/rv/monitors/nomiss/nomiss.h new file +123 -0
123 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/rv_trace.h +1 -0
@@ -188,6 +188,7 @@ DECLARE_EVENT_CLASS(error_env_da_monitor_id, );#include <monitors/stall/stall_trace.h> +#include <monitors/nomiss/nomiss_trace.h> // Add new monitors based on CONFIG_HA_MON_EVENTS_ID here #endif
tools/verification/models/deadline/nomiss.dot new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v8 12/12] rv: Add nomiss deadline monitor
Hello,
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:
* nomiss:
validate dl entities run to completion before their deadilineReviewed-by Nam Cao <[email protected]>Signed-off-by Gabriele Monaco <[email protected]>
Looks good to me.
Best,
Juri