Refactor and cleanup
Subsystems (3)
Gabriele Monaco
maintainercover Refactor and cleanup
This series contains reviewed preparation patches included in [1].
These are namely: refactor to minimise macros, including cleanup and documentation, python script annotations and cleanup, removal of superfluous assignments and declarations in monitors code.
The series is based on linux-next and the first two patches had minor conflicts, mainly resulting from 4f739ed19d22 ("rv: Pass va_list to reactors").
[1] - https://lore.kernel.org/linux-trace-kernel/[email protected]
To: Steven Rostedt <[email protected]>
To: Nam Cao <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: [email protected]
Gabriele Monaco (8):
rv: Refactor da_monitor to minimise macros
rv: Cleanup da_monitor after refactor
Documentation/rv: Adapt documentation after da_monitor refactoring verification/rvgen: Adapt dot2k and templates after refactoring
da_monitor.h
verification/rvgen: Annotate DA functions with types verification/dot2c: Remove __buff_to_string() and cleanup verification/dot2c: Remove superfluous enum assignment and add last
comma
verification/rvgen: Remove unused variable declaration from containers
Documentation/trace/rv/monitor_synthesis.rst | 44 +- include/linux/rv.h | 4 + include/rv/automata.h | 132 +-- include/rv/da_monitor.h | 885 +++++++++--------- kernel/trace/rv/monitors/nrp/nrp.c | 30 +- kernel/trace/rv/monitors/nrp/nrp.h | 22 +- kernel/trace/rv/monitors/opid/opid.c | 40 +- kernel/trace/rv/monitors/opid/opid.h | 24 +- kernel/trace/rv/monitors/rtapp/rtapp.c | 2 - kernel/trace/rv/monitors/sched/sched.c | 2 - kernel/trace/rv/monitors/sco/sco.c | 26 +- kernel/trace/rv/monitors/sco/sco.h | 14 +- kernel/trace/rv/monitors/scpd/scpd.c | 28 +- kernel/trace/rv/monitors/scpd/scpd.h | 14 +- kernel/trace/rv/monitors/snep/snep.c | 28 +- kernel/trace/rv/monitors/snep/snep.h | 18 +- kernel/trace/rv/monitors/snroc/snroc.c | 26 +- kernel/trace/rv/monitors/snroc/snroc.h | 14 +- kernel/trace/rv/monitors/sssw/sssw.c | 38 +- kernel/trace/rv/monitors/sssw/sssw.h | 22 +- kernel/trace/rv/monitors/sts/sts.c | 34 +- kernel/trace/rv/monitors/sts/sts.h | 28 +- kernel/trace/rv/monitors/wip/wip.c | 26 +- kernel/trace/rv/monitors/wip/wip.h | 14 +- kernel/trace/rv/monitors/wwnr/wwnr.c | 28 +- kernel/trace/rv/monitors/wwnr/wwnr.h | 14 +- tools/verification/rvgen/rvgen/automata.py | 20 +- tools/verification/rvgen/rvgen/dot2c.py | 111 +-- tools/verification/rvgen/rvgen/dot2k.py | 26 +- .../rvgen/rvgen/templates/container/main.c | 2 - .../rvgen/rvgen/templates/dot2k/main.c | 25 +- 31 files changed, 834 insertions(+), 907 deletions(-)
base-commit: 663d0d1af3faefe673cabf4b6b077149a87ad71f
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 1/8 Refactor da_monitor to minimise macros
The da_monitor helper functions are generated from macros of the type:
DECLARE_DA_FUNCTION(name, type) \
static void da_func_x_##name(type arg) {} \
static void da_func_y_##name(type arg) {} \
This is good to minimise code duplication but the long macros made of skipped end of lines is rather hard to parse. Since functions are static, the advantage of naming them differently for each monitor is minimal.
Refactor the da_monitor.h file to minimise macros, instead of declaring functions from macros, we simply declare them with the same name for all monitors (e.g. da_func_x) and for any remaining reference to the monitor name (e.g. tracepoints, enums, global variables) we use the CONCATENATE macro.
In this way the file is much easier to maintain while keeping the same generality.
Functions depending on the monitor types are now conditionally compiled according to the value of RV_MON_TYPE, which must be defined in the monitor source.
The monitor type can be specified as in the original implementation, although it's best to keep the default implementation (unsigned char) as not all parts of code support larger data types, and likely there's no need.
We keep the empty macro definitions to ease review of this change with diff tools, but cleanup is required.
Also adapt existing monitors to keep the build working.
--- include/linux/rv.h | 4 + include/rv/automata.h | 132 ++-- include/rv/da_monitor.h | 898 ++++++++++++------------- kernel/trace/rv/monitors/nrp/nrp.c | 30 +- kernel/trace/rv/monitors/nrp/nrp.h | 2 + kernel/trace/rv/monitors/opid/opid.c | 40 +- kernel/trace/rv/monitors/opid/opid.h | 2 + kernel/trace/rv/monitors/sco/sco.c | 26 +- kernel/trace/rv/monitors/sco/sco.h | 2 + kernel/trace/rv/monitors/scpd/scpd.c | 28 +- kernel/trace/rv/monitors/scpd/scpd.h | 2 + kernel/trace/rv/monitors/snep/snep.c | 28 +- kernel/trace/rv/monitors/snep/snep.h | 2 + kernel/trace/rv/monitors/snroc/snroc.c | 26 +- kernel/trace/rv/monitors/snroc/snroc.h | 2 + kernel/trace/rv/monitors/sssw/sssw.c | 38 +- kernel/trace/rv/monitors/sssw/sssw.h | 2 + kernel/trace/rv/monitors/sts/sts.c | 34 +- kernel/trace/rv/monitors/sts/sts.h | 2 + kernel/trace/rv/monitors/wip/wip.c | 26 +- kernel/trace/rv/monitors/wip/wip.h | 2 + kernel/trace/rv/monitors/wwnr/wwnr.c | 28 +- kernel/trace/rv/monitors/wwnr/wwnr.h | 2 + 23 files changed, 682 insertions(+), 676 deletions(-)
include/linux/rv.h +4 -0
@@ -10,6 +10,10 @@#define MAX_DA_NAME_LEN 32#define MAX_DA_RETRY_RACING_EVENTS 3 +#define RV_MON_GLOBAL 0 +#define RV_MON_PER_CPU 1 +#define RV_MON_PER_TASK 2 +#ifdef CONFIG_RV #include <linux/array_size.h> #include <linux/bitops.h>
include/rv/automata.h +73 -59
142 lines not on this page · raw message
include/rv/da_monitor.h +443 -455
957 lines not on this page · raw message
kernel/trace/rv/monitors/nrp/nrp.c +14 -16
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "nrp"
@@ -15,17 +14,16 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_TASK#include "nrp.h" - -static struct rv_monitor rv_nrp; -DECLARE_DA_MON_PER_TASK(nrp, unsigned char); +#include <rv/da_monitor.h> #ifdef CONFIG_X86_LOCAL_APIC #include <asm/trace/irq_vectors.h> static void handle_vector_irq_entry (void *data,int vector) { -da_handle_event_nrp (current, irq_entry_nrp); +da_handle_event (current, irq_entry_nrp); }static void attach_vector_irq (void )
@@ -60,7 +58,7 @@ static void detach_vector_irq(void) { }static void handle_irq_entry (void *data,int irq,struct irqaction *action) { -da_handle_event_nrp (current, irq_entry_nrp); +da_handle_event (current, irq_entry_nrp); } static void handle_sched_need_resched(void *data, struct task_struct *tsk,
@@ -72,22 +70,22 @@ static void handle_sched_need_resched(void *data, struct task_struct *tsk,* which may not mirror the system state but makes the monitor simpler, */ if (tif ==TIF_NEED_RESCHED ) -da_handle_start_event_nrp (tsk, sched_need_resched_nrp); +da_handle_start_event (tsk, sched_need_resched_nrp); }static void handle_schedule_entry (void *data,bool preempt) {if (preempt) -da_handle_event_nrp (current, schedule_entry_preempt_nrp); +da_handle_event (current, schedule_entry_preempt_nrp);else -da_handle_event_nrp (current, schedule_entry_nrp); +da_handle_event (current, schedule_entry_nrp); }static int enable_nrp (void ) {int retval; - retval =da_monitor_init_nrp (); + retval =da_monitor_init ();if (retval)return retval;
@@ -101,33 +99,33 @@ static int enable_nrp(void)static void disable_nrp (void ) { - rv_nrp.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("nrp" , irq_handler_entry, handle_irq_entry);rv_detach_trace_probe ("nrp" , sched_set_need_resched_tp, handle_sched_need_resched);rv_detach_trace_probe ("nrp" , sched_entry_tp, handle_schedule_entry);detach_vector_irq (); -da_monitor_destroy_nrp (); +da_monitor_destroy (); } -static struct rv_monitor rv_nrp = { +static struct rv_monitor rv_this = { .name ="nrp" , .description ="need resched preempts." , .enable = enable_nrp, .disable = disable_nrp, - .reset = da_monitor_reset_all_nrp, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_nrp (void ) { -return rv_register_monitor (&rv_nrp, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_nrp(void) { -rv_unregister_monitor (&rv_nrp); +rv_unregister_monitor (&rv_this); }module_init (register_nrp);
kernel/trace/rv/monitors/nrp/nrp.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME nrp +enum states_nrp { preempt_irq_nrp =0 , any_thread_running_nrp,
kernel/trace/rv/monitors/opid/opid.c +19 -21
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "opid"
@@ -16,17 +15,16 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "opid.h" - -static struct rv_monitor rv_opid; -DECLARE_DA_MON_PER_CPU(opid, unsigned char); +#include <rv/da_monitor.h> #ifdef CONFIG_X86_LOCAL_APIC #include <asm/trace/irq_vectors.h> static void handle_vector_irq_entry (void *data,int vector) { -da_handle_event_opid (irq_entry_opid); +da_handle_event (irq_entry_opid); }static void attach_vector_irq (void )
@@ -61,52 +59,52 @@ static void detach_vector_irq(void) { }static void handle_irq_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_opid (irq_disable_opid); +da_handle_event (irq_disable_opid); }static void handle_irq_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_opid (irq_enable_opid); +da_handle_event (irq_enable_opid); }static void handle_irq_entry (void *data,int irq,struct irqaction *action) { -da_handle_event_opid (irq_entry_opid); +da_handle_event (irq_entry_opid); }static void handle_preempt_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_opid (preempt_disable_opid); +da_handle_event (preempt_disable_opid); }static void handle_preempt_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_opid (preempt_enable_opid); +da_handle_event (preempt_enable_opid); }static void handle_sched_need_resched (void *data,struct task_struct *tsk,int cpu,int tif) {/* The monitor's intitial state is not in_irq */ if (this_cpu_read (hardirq_context)) -da_handle_event_opid (sched_need_resched_opid); +da_handle_event (sched_need_resched_opid);else -da_handle_start_event_opid (sched_need_resched_opid); +da_handle_start_event (sched_need_resched_opid); }static void handle_sched_waking (void *data,struct task_struct *p) {/* The monitor's intitial state is not in_irq */ if (this_cpu_read (hardirq_context)) -da_handle_event_opid (sched_waking_opid); +da_handle_event (sched_waking_opid);else -da_handle_start_event_opid (sched_waking_opid); +da_handle_start_event (sched_waking_opid); }static int enable_opid (void ) {int retval; - retval =da_monitor_init_opid (); + retval =da_monitor_init ();if (retval)return retval;
@@ -124,7 +122,7 @@ static int enable_opid(void)static void disable_opid (void ) { - rv_opid.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("opid" , irq_disable, handle_irq_disable);rv_detach_trace_probe ("opid" , irq_enable, handle_irq_enable);
@@ -135,29 +133,29 @@ static void disable_opid(void)rv_detach_trace_probe ("opid" , sched_waking, handle_sched_waking);detach_vector_irq (); -da_monitor_destroy_opid (); +da_monitor_destroy (); }/* * This is the monitor register section. */ -static struct rv_monitor rv_opid = { +static struct rv_monitor rv_this = { .name ="opid" , .description ="operations with preemption and irq disabled." , .enable = enable_opid, .disable = disable_opid, - .reset = da_monitor_reset_all_opid, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_opid (void ) { -return rv_register_monitor (&rv_opid, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_opid(void) { -rv_unregister_monitor (&rv_opid); +rv_unregister_monitor (&rv_this); }module_init (register_opid);
kernel/trace/rv/monitors/opid/opid.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME opid +enum states_opid { disabled_opid =0 , enabled_opid,
kernel/trace/rv/monitors/sco/sco.c +12 -14
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "sco"
@@ -14,31 +13,30 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "sco.h" - -static struct rv_monitor rv_sco; -DECLARE_DA_MON_PER_CPU(sco, unsigned char); +#include <rv/da_monitor.h> static void handle_sched_set_state (void *data,struct task_struct *tsk,int state) { -da_handle_start_event_sco (sched_set_state_sco); +da_handle_start_event (sched_set_state_sco); }static void handle_schedule_entry (void *data,bool preempt) { -da_handle_event_sco (schedule_entry_sco); +da_handle_event (schedule_entry_sco); }static void handle_schedule_exit (void *data,bool is_switch) { -da_handle_start_event_sco (schedule_exit_sco); +da_handle_start_event (schedule_exit_sco); }static int enable_sco (void ) {int retval; - retval =da_monitor_init_sco (); + retval =da_monitor_init ();if (retval)return retval;
@@ -51,32 +49,32 @@ static int enable_sco(void)static void disable_sco (void ) { - rv_sco.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("sco" , sched_set_state_tp, handle_sched_set_state);rv_detach_trace_probe ("sco" , sched_entry_tp, handle_schedule_entry);rv_detach_trace_probe ("sco" , sched_exit_tp, handle_schedule_exit); -da_monitor_destroy_sco (); +da_monitor_destroy (); } -static struct rv_monitor rv_sco = { +static struct rv_monitor rv_this = { .name ="sco" , .description ="scheduling context operations." , .enable = enable_sco, .disable = disable_sco, - .reset = da_monitor_reset_all_sco, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_sco (void ) { -return rv_register_monitor (&rv_sco, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_sco(void) { -rv_unregister_monitor (&rv_sco); +rv_unregister_monitor (&rv_this); }module_init (register_sco);
kernel/trace/rv/monitors/sco/sco.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME sco +enum states_sco { thread_context_sco =0 , scheduling_context_sco,
kernel/trace/rv/monitors/scpd/scpd.c +13 -15
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "scpd"
@@ -15,36 +14,35 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "scpd.h" - -static struct rv_monitor rv_scpd; -DECLARE_DA_MON_PER_CPU(scpd, unsigned char); +#include <rv/da_monitor.h> static void handle_preempt_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_scpd (preempt_disable_scpd); +da_handle_event (preempt_disable_scpd); }static void handle_preempt_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_start_event_scpd (preempt_enable_scpd); +da_handle_start_event (preempt_enable_scpd); }static void handle_schedule_entry (void *data,bool preempt) { -da_handle_event_scpd (schedule_entry_scpd); +da_handle_event (schedule_entry_scpd); }static void handle_schedule_exit (void *data,bool is_switch) { -da_handle_event_scpd (schedule_exit_scpd); +da_handle_event (schedule_exit_scpd); }static int enable_scpd (void ) {int retval; - retval =da_monitor_init_scpd (); + retval =da_monitor_init ();if (retval)return retval;
@@ -58,33 +56,33 @@ static int enable_scpd(void)static void disable_scpd (void ) { - rv_scpd.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("scpd" , preempt_disable, handle_preempt_disable);rv_detach_trace_probe ("scpd" , preempt_enable, handle_preempt_enable);rv_detach_trace_probe ("scpd" , sched_entry_tp, handle_schedule_entry);rv_detach_trace_probe ("scpd" , sched_exit_tp, handle_schedule_exit); -da_monitor_destroy_scpd (); +da_monitor_destroy (); } -static struct rv_monitor rv_scpd = { +static struct rv_monitor rv_this = { .name ="scpd" , .description ="schedule called with preemption disabled." , .enable = enable_scpd, .disable = disable_scpd, - .reset = da_monitor_reset_all_scpd, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_scpd (void ) { -return rv_register_monitor (&rv_scpd, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_scpd(void) { -rv_unregister_monitor (&rv_scpd); +rv_unregister_monitor (&rv_this); }module_init (register_scpd);
kernel/trace/rv/monitors/scpd/scpd.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME scpd +enum states_scpd { cant_sched_scpd =0 , can_sched_scpd,
kernel/trace/rv/monitors/snep/snep.c +13 -15
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "snep"
@@ -15,36 +14,35 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "snep.h" - -static struct rv_monitor rv_snep; -DECLARE_DA_MON_PER_CPU(snep, unsigned char); +#include <rv/da_monitor.h> static void handle_preempt_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_start_event_snep (preempt_disable_snep); +da_handle_start_event (preempt_disable_snep); }static void handle_preempt_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_start_event_snep (preempt_enable_snep); +da_handle_start_event (preempt_enable_snep); }static void handle_schedule_entry (void *data,bool preempt) { -da_handle_event_snep (schedule_entry_snep); +da_handle_event (schedule_entry_snep); }static void handle_schedule_exit (void *data,bool is_switch) { -da_handle_start_event_snep (schedule_exit_snep); +da_handle_start_event (schedule_exit_snep); }static int enable_snep (void ) {int retval; - retval =da_monitor_init_snep (); + retval =da_monitor_init ();if (retval)return retval;
@@ -58,33 +56,33 @@ static int enable_snep(void)static void disable_snep (void ) { - rv_snep.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("snep" , preempt_disable, handle_preempt_disable);rv_detach_trace_probe ("snep" , preempt_enable, handle_preempt_enable);rv_detach_trace_probe ("snep" , sched_entry_tp, handle_schedule_entry);rv_detach_trace_probe ("snep" , sched_exit_tp, handle_schedule_exit); -da_monitor_destroy_snep (); +da_monitor_destroy (); } -static struct rv_monitor rv_snep = { +static struct rv_monitor rv_this = { .name ="snep" , .description ="schedule does not enable preempt." , .enable = enable_snep, .disable = disable_snep, - .reset = da_monitor_reset_all_snep, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_snep (void ) { -return rv_register_monitor (&rv_snep, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_snep(void) { -rv_unregister_monitor (&rv_snep); +rv_unregister_monitor (&rv_this); }module_init (register_snep);
kernel/trace/rv/monitors/snep/snep.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME snep +enum states_snep { non_scheduling_context_snep =0 , scheduling_contex_snep,
kernel/trace/rv/monitors/snroc/snroc.c +12 -14
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "snroc"
@@ -14,14 +13,13 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_TASK#include "snroc.h" - -static struct rv_monitor rv_snroc; -DECLARE_DA_MON_PER_TASK(snroc, unsigned char); +#include <rv/da_monitor.h> static void handle_sched_set_state (void *data,struct task_struct *tsk,int state) { -da_handle_event_snroc (tsk, sched_set_state_snroc); +da_handle_event (tsk, sched_set_state_snroc); } static void handle_sched_switch(void *data, bool preempt,
@@ -29,15 +27,15 @@ static void handle_sched_switch(void *data, bool preempt,struct task_struct *next, unsigned int prev_state) { -da_handle_start_event_snroc (prev ,sched_switch_out_snroc ); -da_handle_event_snroc (next, sched_switch_in_snroc); +da_handle_start_event (prev ,sched_switch_out_snroc ); +da_handle_event (next, sched_switch_in_snroc); }static int enable_snroc (void ) {int retval; - retval =da_monitor_init_snroc (); + retval =da_monitor_init ();if (retval)return retval;
@@ -49,31 +47,31 @@ static int enable_snroc(void)static void disable_snroc (void ) { - rv_snroc.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("snroc" , sched_set_state_tp, handle_sched_set_state);rv_detach_trace_probe ("snroc" , sched_switch, handle_sched_switch); -da_monitor_destroy_snroc (); +da_monitor_destroy (); } -static struct rv_monitor rv_snroc = { +static struct rv_monitor rv_this = { .name ="snroc" , .description ="set non runnable on its own context." , .enable = enable_snroc, .disable = disable_snroc, - .reset = da_monitor_reset_all_snroc, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_snroc (void ) { -return rv_register_monitor (&rv_snroc, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_snroc(void) { -rv_unregister_monitor (&rv_snroc); +rv_unregister_monitor (&rv_this); }module_init (register_snroc);
kernel/trace/rv/monitors/snroc/snroc.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME snroc +enum states_snroc { other_context_snroc =0 , own_context_snroc,
kernel/trace/rv/monitors/sssw/sssw.c +18 -20
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "sssw"
@@ -15,17 +14,16 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_TASK#include "sssw.h" - -static struct rv_monitor rv_sssw; -DECLARE_DA_MON_PER_TASK(sssw, unsigned char); +#include <rv/da_monitor.h> static void handle_sched_set_state (void *data,struct task_struct *tsk,int state) {if (state ==TASK_RUNNING ) -da_handle_start_event_sssw (tsk, sched_set_state_runnable_sssw); +da_handle_start_event (tsk, sched_set_state_runnable_sssw);else -da_handle_event_sssw (tsk, sched_set_state_sleepable_sssw); +da_handle_event (tsk, sched_set_state_sleepable_sssw); } static void handle_sched_switch(void *data, bool preempt,
@@ -34,15 +32,15 @@ static void handle_sched_switch(void *data, bool preempt, unsigned int prev_state) {if (preempt) -da_handle_event_sssw (prev, sched_switch_preempt_sssw); +da_handle_event (prev, sched_switch_preempt_sssw);else if (prev_state ==TASK_RUNNING ) -da_handle_event_sssw (prev, sched_switch_yield_sssw); +da_handle_event (prev, sched_switch_yield_sssw);else if (prev_state ==TASK_RTLOCK_WAIT )/* special case of sleeping task with racy conditions */ -da_handle_event_sssw (prev, sched_switch_blocking_sssw); +da_handle_event (prev, sched_switch_blocking_sssw);else -da_handle_event_sssw (prev, sched_switch_suspend_sssw); -da_handle_event_sssw (next, sched_switch_in_sssw); +da_handle_event (prev, sched_switch_suspend_sssw); +da_handle_event (next, sched_switch_in_sssw); }static void handle_sched_wakeup (void *data,struct task_struct *p)
@@ -51,21 +49,21 @@ static void handle_sched_wakeup(void *data, struct task_struct *p)* Wakeup can also lead to signal_wakeup although the system is * actually runnable. The monitor can safely start with this event. */ -da_handle_start_event_sssw (p, sched_wakeup_sssw); +da_handle_start_event (p, sched_wakeup_sssw); }static void handle_signal_deliver (void *data,int sig,struct kernel_siginfo *info,struct k_sigaction *ka) { -da_handle_event_sssw (current, signal_deliver_sssw); +da_handle_event (current, signal_deliver_sssw); }static int enable_sssw (void ) {int retval; - retval =da_monitor_init_sssw (); + retval =da_monitor_init ();if (retval)return retval;
@@ -79,33 +77,33 @@ static int enable_sssw(void)static void disable_sssw (void ) { - rv_sssw.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("sssw" , sched_set_state_tp, handle_sched_set_state);rv_detach_trace_probe ("sssw" , sched_switch, handle_sched_switch);rv_detach_trace_probe ("sssw" , sched_wakeup, handle_sched_wakeup);rv_detach_trace_probe ("sssw" , signal_deliver, handle_signal_deliver); -da_monitor_destroy_sssw (); +da_monitor_destroy (); } -static struct rv_monitor rv_sssw = { +static struct rv_monitor rv_this = { .name ="sssw" , .description ="set state sleep and wakeup." , .enable = enable_sssw, .disable = disable_sssw, - .reset = da_monitor_reset_all_sssw, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_sssw (void ) { -return rv_register_monitor (&rv_sssw, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_sssw(void) { -rv_unregister_monitor (&rv_sssw); +rv_unregister_monitor (&rv_this); }module_init (register_sssw);
kernel/trace/rv/monitors/sssw/sssw.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME sssw +enum states_sssw { runnable_sssw =0 , signal_wakeup_sssw,
kernel/trace/rv/monitors/sts/sts.c +16 -18
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "sts"
@@ -16,17 +15,16 @@#include <rv_trace.h> #include <monitors/sched/sched.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "sts.h" - -static struct rv_monitor rv_sts; -DECLARE_DA_MON_PER_CPU(sts, unsigned char); +#include <rv/da_monitor.h> #ifdef CONFIG_X86_LOCAL_APIC #include <asm/trace/irq_vectors.h> static void handle_vector_irq_entry (void *data,int vector) { -da_handle_event_sts (irq_entry_sts); +da_handle_event (irq_entry_sts); }static void attach_vector_irq (void )
@@ -61,17 +59,17 @@ static void detach_vector_irq(void) { }static void handle_irq_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_sts (irq_disable_sts); +da_handle_event (irq_disable_sts); }static void handle_irq_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_sts (irq_enable_sts); +da_handle_event (irq_enable_sts); }static void handle_irq_entry (void *data,int irq,struct irqaction *action) { -da_handle_event_sts (irq_entry_sts); +da_handle_event (irq_entry_sts); } static void handle_sched_switch(void *data, bool preempt,
@@ -79,24 +77,24 @@ static void handle_sched_switch(void *data, bool preempt,struct task_struct *next, unsigned int prev_state) { -da_handle_event_sts (sched_switch_sts ); +da_handle_event (sched_switch_sts ); }static void handle_schedule_entry (void *data,bool preempt) { -da_handle_event_sts (schedule_entry_sts); +da_handle_event (schedule_entry_sts); }static void handle_schedule_exit (void *data,bool is_switch) { -da_handle_start_event_sts (schedule_exit_sts); +da_handle_start_event (schedule_exit_sts); }static int enable_sts (void ) {int retval; - retval =da_monitor_init_sts (); + retval =da_monitor_init ();if (retval)return retval;
@@ -113,7 +111,7 @@ static int enable_sts(void)static void disable_sts (void ) { - rv_sts.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("sts" , irq_disable, handle_irq_disable);rv_detach_trace_probe ("sts" , irq_enable, handle_irq_enable);
@@ -123,29 +121,29 @@ static void disable_sts(void)rv_detach_trace_probe ("sts" , sched_exit_tp, handle_schedule_exit);detach_vector_irq (); -da_monitor_destroy_sts (); +da_monitor_destroy (); }/* * This is the monitor register section. */ -static struct rv_monitor rv_sts = { +static struct rv_monitor rv_this = { .name ="sts" , .description ="schedule implies task switch." , .enable = enable_sts, .disable = disable_sts, - .reset = da_monitor_reset_all_sts, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_sts (void ) { -return rv_register_monitor (&rv_sts, &rv_sched); +return rv_register_monitor (&rv_this, &rv_sched); } static void __exit unregister_sts(void) { -rv_unregister_monitor (&rv_sts); +rv_unregister_monitor (&rv_this); }module_init (register_sts);
kernel/trace/rv/monitors/sts/sts.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME sts +enum states_sts { can_sched_sts =0 , cant_sched_sts,
kernel/trace/rv/monitors/wip/wip.c +12 -14
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "wip"
@@ -14,31 +13,30 @@#include <trace/events/sched.h> #include <trace/events/preemptirq.h> +#define RV_MON_TYPE RV_MON_PER_CPU#include "wip.h" - -static struct rv_monitor rv_wip; -DECLARE_DA_MON_PER_CPU(wip, unsigned char); +#include <rv/da_monitor.h> static void handle_preempt_disable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_event_wip (preempt_disable_wip); +da_handle_event (preempt_disable_wip); }static void handle_preempt_enable (void *data,unsigned long ip,unsigned long parent_ip) { -da_handle_start_event_wip (preempt_enable_wip); +da_handle_start_event (preempt_enable_wip); }static void handle_sched_waking (void *data,struct task_struct *task) { -da_handle_event_wip (sched_waking_wip); +da_handle_event (sched_waking_wip); }static int enable_wip (void ) {int retval; - retval =da_monitor_init_wip (); + retval =da_monitor_init ();if (retval)return retval;
@@ -51,32 +49,32 @@ static int enable_wip(void)static void disable_wip (void ) { - rv_wip.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("wip" , preempt_disable, handle_preempt_disable);rv_detach_trace_probe ("wip" , preempt_enable, handle_preempt_enable);rv_detach_trace_probe ("wip" , sched_waking, handle_sched_waking); -da_monitor_destroy_wip (); +da_monitor_destroy (); } -static struct rv_monitor rv_wip = { +static struct rv_monitor rv_this = { .name ="wip" , .description ="wakeup in preemptive per-cpu testing monitor." , .enable = enable_wip, .disable = disable_wip, - .reset = da_monitor_reset_all_wip, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_wip (void ) { -return rv_register_monitor (&rv_wip,NULL ); +return rv_register_monitor (&rv_this,NULL ); } static void __exit unregister_wip(void) { -rv_unregister_monitor (&rv_wip); +rv_unregister_monitor (&rv_this); }module_init (register_wip);
kernel/trace/rv/monitors/wip/wip.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME wip +enum states_wip { preemptive_wip =0 , non_preemptive_wip,
kernel/trace/rv/monitors/wwnr/wwnr.c +13 -15
@@ -6,40 +6,38 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "wwnr"#include <rv_trace.h> #include <trace/events/sched.h> +#define RV_MON_TYPE RV_MON_PER_TASK#include "wwnr.h" - -static struct rv_monitor rv_wwnr; -DECLARE_DA_MON_PER_TASK(wwnr, unsigned char); +#include <rv/da_monitor.h> static void handle_switch (void *data,bool preempt,struct task_struct *p,struct task_struct *n,unsigned int prev_state) {/* start monitoring only after the first suspension */ if (prev_state ==TASK_INTERRUPTIBLE ) -da_handle_start_event_wwnr (p, switch_out_wwnr); +da_handle_start_event (p, switch_out_wwnr);else -da_handle_event_wwnr (p, switch_out_wwnr); +da_handle_event (p, switch_out_wwnr); -da_handle_event_wwnr (n, switch_in_wwnr); +da_handle_event (n, switch_in_wwnr); }static void handle_wakeup (void *data,struct task_struct *p) { -da_handle_event_wwnr (p, wakeup_wwnr); +da_handle_event (p, wakeup_wwnr); }static int enable_wwnr (void ) {int retval; - retval =da_monitor_init_wwnr (); + retval =da_monitor_init ();if (retval)return retval;
@@ -51,31 +49,31 @@ static int enable_wwnr(void)static void disable_wwnr (void ) { - rv_wwnr.enabled =0 ; + rv_this.enabled =0 ;rv_detach_trace_probe ("wwnr" , sched_switch, handle_switch);rv_detach_trace_probe ("wwnr" , sched_wakeup, handle_wakeup); -da_monitor_destroy_wwnr (); +da_monitor_destroy (); } -static struct rv_monitor rv_wwnr = { +static struct rv_monitor rv_this = { .name ="wwnr" , .description ="wakeup while not running per-task testing model." , .enable = enable_wwnr, .disable = disable_wwnr, - .reset = da_monitor_reset_all_wwnr, + .reset = da_monitor_reset_all, .enabled =0 , };static int __init register_wwnr (void ) { -return rv_register_monitor (&rv_wwnr,NULL ); +return rv_register_monitor (&rv_this,NULL ); } static void __exit unregister_wwnr(void) { -rv_unregister_monitor (&rv_wwnr); +rv_unregister_monitor (&rv_this); }module_init (register_wwnr);
kernel/trace/rv/monitors/wwnr/wwnr.h +2 -0
@@ -5,6 +5,8 @@* Documentation/trace/rv/deterministic_automata.rst */ +#define MONITOR_NAME wwnr +enum states_wwnr { not_running_wwnr =0 , running_wwnr,
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 2/8 Cleanup da_monitor after refactor
In reply to Gabriele MonacoPrevious changes refactored the da_monitor header file to avoid using macros, however empty macros (e.g. DECLARE_DA_FUNCTION) were left to ease review with diff tools.
Most macros also get the argument type which doesn't really have a purpose since states have their own enum and the storage in struct da_monitor is fixed to unsigned int.
Remove empty and no longer required macros and substitute the type parameter with the appropriate enum.
Additionally break long line and adjust the format overall.
--- include/rv/automata.h | 24 +++------ include/rv/da_monitor.h | 107 ++++++++++++++++------------------------ 2 files changed, 50 insertions(+), 81 deletions(-)
include/rv/automata.h +8 -16
@@ -6,29 +6,19 @@* models in C generated by the dot2k tool. */ +#ifndef _RV_AUTOMATA_H +#define _RV_AUTOMATA_H +#ifndef MONITOR_NAME #error "MONITOR_NAME macro is not defined. Did you include $(MODEL_NAME).h generated by rvgen?"#endif -#ifndef type -#define type unsigned char -#endif -#define RV_AUTOMATON_NAME CONCATENATE(automaton_, MONITOR_NAME)#define EVENT_MAX CONCATENATE(event_max_, MONITOR_NAME)#define STATE_MAX CONCATENATE(state_max_, MONITOR_NAME)#define events CONCATENATE(events_, MONITOR_NAME)#define states CONCATENATE(states_, MONITOR_NAME) -/* -* DECLARE_AUTOMATA_HELPERS - define a set of helper functions for automata -* -* Define a set of helper functions for automata. The 'name' argument is used -* as suffix for the functions and data. These functions will handle automaton -* with data type 'type'. -*/ -#define DECLARE_AUTOMATA_HELPERS (name, type) -/* * model_get_state_name - return the (string) name of the given state */
@@ -54,7 +44,7 @@ static char *model_get_event_name(enum events event)/* * model_get_initial_state - return the automaton's initial state */ -static inline type model_get_initial_state (void ) +static inline enum states model_get_initial_state (void ) {return RV_AUTOMATON_NAME .initial_state; }
@@ -65,8 +55,8 @@ static inline type model_get_initial_state(void)* Given the current state (curr_state) and the event (event), returns * the next state, or INVALID_STATE in case of error. */ -static inline type model_get_next_state (enum states curr_state, -enum events event) +static inline enum states model_get_next_state (enum states curr_state, +enum events event) {if ((curr_state <0 ) || (curr_state >=STATE_MAX ))return INVALID_STATE ;
@@ -87,3 +77,5 @@ static inline bool model_is_final_state(enum states state) return RV_AUTOMATON_NAME.final_states[state]; } + +#endif
include/rv/da_monitor.h +42 -65
253 lines not on this page · raw message
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 3/8 Documentation/rv: Adapt documentation after da_monitor refactoring
In reply to Gabriele MonacoPrevious changes refactored the da_monitor header file to avoid using macros. This implies a few changes in how to import and use da_monitor helpers:
DECLARE_DA_MON_<TYPE>(name, type) is substituted by #define RV_MON_TYPE RV_MON_<TYPE>
da_handle_event_<name>() is substituted by
da_handle_event()
Update the documentation to reflect the changes.
--- Documentation/trace/rv/monitor_synthesis.rst | 44 ++++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-)
Documentation/trace/rv/monitor_synthesis.rst +21 -23
@@ -100,54 +100,52 @@ rv/da_monitor.h This initial implementation presents three different types of monitor instances: -- ``#define DECLARE_DA_MON_GLOBAL(name, type)`` -- ``#define DECLARE_DA_MON_PER_CPU(name, type)`` -- ``#define DECLARE_DA_MON_PER_TASK(name, type)`` +- ``#define RV_MON_TYPE RV_MON_GLOBAL`` +- ``#define RV_MON_TYPE RV_MON_PER_CPU`` +- ``#define RV_MON_TYPE RV_MON_PER_TASK`` -The first declares the functions for a global deterministic automata monitor, -the second for monitors with per-cpu instances, and the third with per-task -instances. +The first sets up functions declaration for a global deterministic automata +monitor, the second for monitors with per-cpu instances, and the third with +per-task instances. -In all cases, the 'name' argument is a string that identifies the monitor, and -the 'type' argument is the data type used by rvgen on the representation of -the model in C. +In all cases, the C file must include the $(MODEL_NAME).h file (generated by +`rvgen`), for example, to define the per-cpu 'wip' monitor, the `wip.c` source +file must include:: -For example, the wip model with two states and three events can be -stored in an 'unsigned char' type. Considering that the preemption control -is a per-cpu behavior, the monitor declaration in the 'wip.c' file is:: - - DECLARE_DA_MON_PER_CPU(wip, unsigned char); + #define RV_MON_TYPE RV_MON_PER_CPU + #include "wip.h" + #include <rv/da_monitor.h> The monitor is executed by sending events to be processed via the functions presented below:: - da_handle_event_$(MONITOR_NAME)($(event from event enum)); - da_handle_start_event_$(MONITOR_NAME)($(event from event enum)); - da_handle_start_run_event_$(MONITOR_NAME)($(event from event enum)); + da_handle_event($(event from event enum)); + da_handle_start_event($(event from event enum)); + da_handle_start_run_event($(event from event enum)); -The function ``da_handle_event_$(MONITOR_NAME)()`` is the regular case where +The function ``da_handle_event()`` is the regular case where the event will be processed if the monitor is processing events. When a monitor is enabled, it is placed in the initial state of the automata. However, the monitor does not know if the system is in the *initial state*. -The ``da_handle_start_event_$(MONITOR_NAME)()`` function is used to notify the +The ``da_handle_start_event()`` function is used to notify the monitor that the system is returning to the initial state, so the monitor can start monitoring the next event. -The ``da_handle_start_run_event_$(MONITOR_NAME)()`` function is used to notify +The ``da_handle_start_run_event()`` function is used to notify the monitor that the system is known to be in the initial state, so the monitor can start monitoring and monitor the current event. Using the wip model as example, the events "preempt_disable" and "sched_waking" should be sent to monitor, respectively, via [2]:: - da_handle_event_wip(preempt_disable_wip); - da_handle_event_wip(sched_waking_wip); + da_handle_event(preempt_disable_wip); + da_handle_event(sched_waking_wip); While the event "preempt_enabled" will use:: - da_handle_start_event_wip(preempt_enable_wip); + da_handle_start_event(preempt_enable_wip); To notify the monitor that the system will be returning to the initial state, so the system and the monitor should be in sync.
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 4/8 verification/rvgen: Adapt dot2k and templates after refactoring da_monitor.h
In reply to Gabriele MonacoPrevious changes refactored the da_monitor header file to avoid using macros. This implies a few changes in how to import and use da_monitor helpers:
DECLARE_DA_MON_<TYPE>(name, type) is substituted by #define RV_MON_TYPE RV_MON_<TYPE>
Update the rvgen templates to reflect the changes.
--- tools/verification/rvgen/rvgen/dot2k.py | 6 +++-- .../rvgen/rvgen/templates/dot2k/main.c | 25 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-)
tools/verification/rvgen/rvgen/dot2k.py +4 -2
@@ -38,9 +38,9 @@ class dot2k(Monitor, Dot2c): handle = "handle_start_run_event" if self.monitor_type == "per_task": buff.append("\tstruct task_struct *p = /* XXX: how do I get p? */;"); - buff.append("\tda_%s_%s(p, %s%s);" % (handle, self.name, event, self.enum_suffix)); + buff.append("\tda_%s(p, %s%s);" % (handle, event, self.enum_suffix)); else: - buff.append("\tda_%s_%s(%s%s);" % (handle, self.name, event, self.enum_suffix)); + buff.append("\tda_%s(%s%s);" % (handle, event, self.enum_suffix)); buff.append("}") buff.append("") return '\n'.join(buff)
@@ -66,6 +66,8 @@ class dot2k(Monitor, Dot2c): buff.append(" * Documentation/trace/rv/deterministic_automata.rst") buff.append(" */") buff.append("") + buff.append("#define MONITOR_NAME %s" % (self.name)) + buff.append("") return buff
tools/verification/rvgen/rvgen/templates/dot2k/main.c +9 -16
@@ -6,7 +6,6 @@#include <linux/init.h> #include <linux/rv.h> #include <rv/instrumentation.h> -#include <rv/da_monitor.h> #define MODULE_NAME "%%MODEL_NAME%%"
@@ -20,15 +19,9 @@* This is the self-generated part of the monitor. Generally, there is no need * to touch this section. */ +#define RV_MON_TYPE RV_MON_%%MONITOR_TYPE%%#include "%%MODEL_NAME%%.h" - -/* -* Declare the deterministic automata monitor. -* -* The rv monitor reference is needed for the monitor declaration. -*/ -static struct rv_monitor rv_%%MODEL_NAME%%; -DECLARE_DA_MON_%%MONITOR_TYPE%%(%%MODEL_NAME%%, %%MIN_TYPE%%); +#include <rv/da_monitor.h> /* * This is the instrumentation part of the monitor.
@@ -42,7 +35,7 @@ static int enable_%%MODEL_NAME%%(void) {int retval; - retval = da_monitor_init_%%MODEL_NAME%%(); + retval =da_monitor_init ();if (retval)return retval;
@@ -53,33 +46,33 @@ static int enable_%%MODEL_NAME%%(void) static void disable_%%MODEL_NAME%%(void) { - rv_%%MODEL_NAME%%.enabled = 0; + rv_this.enabled =0 ; %%TRACEPOINT_DETACH%% - da_monitor_destroy_%%MODEL_NAME%%(); +da_monitor_destroy (); }/* * This is the monitor register section. */ -static struct rv_monitor rv_%%MODEL_NAME%% = { +static struct rv_monitor rv_this = { .name ="%%MODEL_NAME%%" , .description ="%%DESCRIPTION%%" , .enable = enable_%%MODEL_NAME%%, .disable = disable_%%MODEL_NAME%%, - .reset = da_monitor_reset_all_%%MODEL_NAME%%, + .reset = da_monitor_reset_all, .enabled =0 , }; static int __init register_%%MODEL_NAME%%(void) { - return rv_register_monitor(&rv_%%MODEL_NAME%%, %%PARENT%%); + return rv_register_monitor(&rv_this, %%PARENT%%); } static void __exit unregister_%%MODEL_NAME%%(void) { - rv_unregister_monitor(&rv_%%MODEL_NAME%%); + rv_unregister_monitor(&rv_this); } module_init(register_%%MODEL_NAME%%);
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 5/8 verification/rvgen: Annotate DA functions with types
In reply to Gabriele MonacoFunctions in automata.py, dot2c.py and dot2k.py don't have type annotations and it can get complicated to remember how to use them.
Add minimal type annotations.
--- tools/verification/rvgen/rvgen/automata.py | 20 +++++------ tools/verification/rvgen/rvgen/dot2c.py | 42 +++++++++++----------- tools/verification/rvgen/rvgen/dot2k.py | 20 +++++------ 3 files changed, 41 insertions(+), 41 deletions(-)
tools/verification/rvgen/rvgen/automata.py +10 -10
@@ -28,7 +28,7 @@ class Automata: self.function = self.__create_matrix() self.events_start, self.events_start_run = self.__store_init_events() - def __get_model_name(self): + def __get_model_name(self) -> str: basename = ntpath.basename(self.__dot_path) if not basename.endswith(".dot") and not basename.endswith(".gv"): print("not a dot file")
@@ -40,7 +40,7 @@ class Automata: return model_name - def __open_dot(self): + def __open_dot(self) -> list[str]: cursor = 0 dot_lines = [] try:
@@ -60,13 +60,13 @@ class Automata: cursor += 1 return dot_lines - def __get_cursor_begin_states(self): + def __get_cursor_begin_states(self) -> int: cursor = 0 while self.__dot_lines[cursor].split()[0] != "{node": cursor += 1 return cursor - def __get_cursor_begin_events(self): + def __get_cursor_begin_events(self) -> int: cursor = 0 while self.__dot_lines[cursor].split()[0] != "{node": cursor += 1
@@ -76,7 +76,7 @@ class Automata: cursor += 1 return cursor - def __get_state_variables(self): + def __get_state_variables(self) -> tuple[list[str], str, list[str]]: # wait for node declaration states = [] final_states = []
@@ -116,7 +116,7 @@ class Automata: return states, initial_state, final_states - def __get_event_variables(self): + def __get_event_variables(self) -> list[str]: # here we are at the begin of transitions, take a note, we will return later. cursor = self.__get_cursor_begin_events()
@@ -140,7 +140,7 @@ class Automata: return sorted(set(events)) - def __create_matrix(self): + def __create_matrix(self) -> list[list[str]]: # transform the array into a dictionary events = self.events states = self.states
@@ -174,7 +174,7 @@ class Automata: return matrix - def __store_init_events(self): + def __store_init_events(self) -> tuple[list[bool], list[bool]]: events_start = [False] * len(self.events) events_start_run = [False] * len(self.events) for i, _ in enumerate(self.events):
@@ -196,10 +196,10 @@ class Automata: events_start_run[i] = True return events_start, events_start_run - def is_start_event(self, event): + def is_start_event(self, event: str) -> bool: return self.events_start[self.events.index(event)] - def is_start_run_event(self, event): + def is_start_run_event(self, event: str) -> bool: # prefer handle_start_event if there if any(self.events_start): return False
tools/verification/rvgen/rvgen/dot2c.py +21 -21
153 lines not on this page · raw message
tools/verification/rvgen/rvgen/dot2k.py +10 -10
@@ -21,10 +21,10 @@ class dot2k(Monitor, Dot2c): Dot2c.__init__(self, file_path, extra_params.get("model_name")) self.enum_suffix = "_%s" % self.name - def fill_monitor_type(self): + def fill_monitor_type(self) -> str: return self.monitor_type.upper() - def fill_tracepoint_handlers_skel(self): + def fill_tracepoint_handlers_skel(self) -> str: buff = [] for event in self.events: buff.append("static void handle_%s(void *data, /* XXX: fill header */)" % event)
@@ -45,19 +45,19 @@ class dot2k(Monitor, Dot2c): buff.append("") return '\n'.join(buff) - def fill_tracepoint_attach_probe(self): + def fill_tracepoint_attach_probe(self) -> str: buff = [] for event in self.events: buff.append("\trv_attach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event)) return '\n'.join(buff) - def fill_tracepoint_detach_helper(self): + def fill_tracepoint_detach_helper(self) -> str: buff = [] for event in self.events: buff.append("\trv_detach_trace_probe(\"%s\", /* XXX: tracepoint */, handle_%s);" % (self.name, event)) return '\n'.join(buff) - def fill_model_h_header(self): + def fill_model_h_header(self) -> list[str]: buff = [] buff.append("/* SPDX-License-Identifier: GPL-2.0 */") buff.append("/*")
@@ -71,7 +71,7 @@ class dot2k(Monitor, Dot2c): return buff - def fill_model_h(self): + def fill_model_h(self) -> str: # # Adjust the definition names #
@@ -85,17 +85,17 @@ class dot2k(Monitor, Dot2c): return '\n'.join(buff) - def fill_monitor_class_type(self): + def fill_monitor_class_type(self) -> str: if self.monitor_type == "per_task": return "DA_MON_EVENTS_ID" return "DA_MON_EVENTS_IMPLICIT" - def fill_monitor_class(self): + def fill_monitor_class(self) -> str: if self.monitor_type == "per_task": return "da_monitor_id" return "da_monitor" - def fill_tracepoint_args_skel(self, tp_type): + def fill_tracepoint_args_skel(self, tp_type: str) -> str: buff = [] tp_args_event = [ ("char *", "state"),
@@ -117,7 +117,7 @@ class dot2k(Monitor, Dot2c): buff.append(" TP_ARGS(%s)" % tp_args_c) return '\n'.join(buff) - def fill_main_c(self): + def fill_main_c(self) -> str: main_c = super().fill_main_c() min_type = self.get_minimun_type()
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 6/8 verification/dot2c: Remove __buff_to_string() and cleanup
In reply to Gabriele Monacostr.join() can do what __buff_to_string() does. Therefore replace __buff_to_string() to make the scripts more pythonic.
Also clean and remove some intermediate functions.
--- tools/verification/rvgen/rvgen/dot2c.py | 35 +++++-------------------- 1 file changed, 6 insertions(+), 29 deletions(-)
tools/verification/rvgen/rvgen/dot2c.py +6 -29
@@ -26,15 +26,6 @@ class Dot2c(Automata): super().__init__(file_path, model_name) self.line_length = 100 - def __buff_to_string(self, buff): - string = "" - - for line in buff: - string = string + line + "\n" - - # cut off the last \n - return string[:-1] - def __get_enum_states_content(self) -> list[str]: buff = [] buff.append("\t%s%s = 0," % (self.initial_state, self.enum_suffix))
@@ -45,14 +36,10 @@ class Dot2c(Automata): return buff - def get_enum_states_string(self): - buff = self.__get_enum_states_content() - return self.__buff_to_string(buff) - def format_states_enum(self) -> list[str]: buff = [] buff.append("enum %s {" % self.enum_states_def) - buff.append(self.get_enum_states_string()) + buff += self.__get_enum_states_content() buff.append("};\n") return buff
@@ -71,14 +58,10 @@ class Dot2c(Automata): return buff - def get_enum_events_string(self): - buff = self.__get_enum_events_content() - return self.__buff_to_string(buff) - def format_events_enum(self) -> list[str]: buff = [] buff.append("enum %s {" % self.enum_events_def) - buff.append(self.get_enum_events_string()) + buff += self.__get_enum_events_content() buff.append("};\n") return buff
@@ -127,23 +110,17 @@ class Dot2c(Automata): return string - def get_aut_init_events_string(self): - return self.__get_string_vector_per_line_content(self.events) - - def get_aut_init_states_string(self): - return self.__get_string_vector_per_line_content(self.states) - def format_aut_init_events_string(self) -> list[str]: buff = [] buff.append("\t.event_names = {") - buff.append(self.get_aut_init_events_string()) + buff.append(self.__get_string_vector_per_line_content(self.events)) buff.append("\t},") return buff def format_aut_init_states_string(self) -> list[str]: buff = [] buff.append("\t.state_names = {") - buff.append(self.get_aut_init_states_string()) + buff.append(self.__get_string_vector_per_line_content(self.states)) buff.append("\t},") return buff
@@ -178,7 +155,7 @@ class Dot2c(Automata): line += "\n\t\t}," if linetoolong else " }," buff.append(line) - return self.__buff_to_string(buff) + return '\n'.join(buff) def format_aut_init_function(self) -> list[str]: buff = []
@@ -253,4 +230,4 @@ class Dot2c(Automata): def print_model_classic(self): buff = self.format_model() - print(self.__buff_to_string(buff)) + print('\n'.join(buff))
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 7/8 verification/dot2c: Remove superfluous enum assignment and add last comma
In reply to Gabriele MonacoThe header files generated by dot2c currently create enums for states and events assigning the first element to 0. This is superfluous as it happens automatically if no value is specified.
Also it doesn't add a comma to the last enum elements, which slightly complicates the diff if states or events are added.
Remove the assignment to 0 and add a comma to last elements, this simplifies the logic for the code generator.
--- kernel/trace/rv/monitors/nrp/nrp.h | 20 +++++++------- kernel/trace/rv/monitors/opid/opid.h | 22 +++++++-------- kernel/trace/rv/monitors/sco/sco.h | 12 ++++----- kernel/trace/rv/monitors/scpd/scpd.h | 12 ++++----- kernel/trace/rv/monitors/snep/snep.h | 16 +++++------ kernel/trace/rv/monitors/snroc/snroc.h | 12 ++++----- kernel/trace/rv/monitors/sssw/sssw.h | 20 +++++++------- kernel/trace/rv/monitors/sts/sts.h | 26 +++++++++--------- kernel/trace/rv/monitors/wip/wip.h | 12 ++++----- kernel/trace/rv/monitors/wwnr/wwnr.h | 12 ++++----- tools/verification/rvgen/rvgen/dot2c.py | 36 +++++++++---------------- 11 files changed, 94 insertions(+), 106 deletions(-)
kernel/trace/rv/monitors/nrp/nrp.h +10 -10
@@ -8,21 +8,21 @@#define MONITOR_NAME nrpenum states_nrp { - preempt_irq_nrp =0 , + preempt_irq_nrp, any_thread_running_nrp, nested_preempt_nrp, rescheduling_nrp, - state_max_nrp + state_max_nrp, };#define INVALID_STATE state_max_nrpenum events_nrp { - irq_entry_nrp =0 , + irq_entry_nrp, sched_need_resched_nrp, schedule_entry_nrp, schedule_entry_preempt_nrp, - event_max_nrp + event_max_nrp, };struct automaton_nrp {
@@ -38,38 +38,38 @@ static const struct automaton_nrp automaton_nrp = {"preempt_irq" ,"any_thread_running" ,"nested_preempt" , -"rescheduling" + "rescheduling", }, .event_names = {"irq_entry" ,"sched_need_resched" ,"schedule_entry" , -"schedule_entry_preempt" + "schedule_entry_preempt", }, .function = { { preempt_irq_nrp, preempt_irq_nrp, nested_preempt_nrp, - nested_preempt_nrp + nested_preempt_nrp, }, { any_thread_running_nrp, rescheduling_nrp, any_thread_running_nrp, -INVALID_STATE +INVALID_STATE , }, { nested_preempt_nrp, preempt_irq_nrp, any_thread_running_nrp, - any_thread_running_nrp + any_thread_running_nrp, }, { preempt_irq_nrp, rescheduling_nrp, any_thread_running_nrp, - any_thread_running_nrp + any_thread_running_nrp, }, }, .initial_state = preempt_irq_nrp,
kernel/trace/rv/monitors/opid/opid.h +11 -11
@@ -8,25 +8,25 @@#define MONITOR_NAME opidenum states_opid { - disabled_opid =0 , + disabled_opid, enabled_opid, in_irq_opid, irq_disabled_opid, preempt_disabled_opid, - state_max_opid + state_max_opid, };#define INVALID_STATE state_max_opidenum events_opid { - irq_disable_opid =0 , + irq_disable_opid, irq_enable_opid, irq_entry_opid, preempt_disable_opid, preempt_enable_opid, sched_need_resched_opid, sched_waking_opid, - event_max_opid + event_max_opid, };struct automaton_opid {
@@ -43,7 +43,7 @@ static const struct automaton_opid automaton_opid = {"enabled" ,"in_irq" ,"irq_disabled" , -"preempt_disabled" + "preempt_disabled", }, .event_names = { "irq_disable",
@@ -52,7 +52,7 @@ static const struct automaton_opid automaton_opid = {"preempt_disable" ,"preempt_enable" ,"sched_need_resched" , -"sched_waking" + "sched_waking", }, .function = { {
@@ -62,7 +62,7 @@ static const struct automaton_opid automaton_opid = {INVALID_STATE , irq_disabled_opid, disabled_opid, - disabled_opid + disabled_opid, }, { irq_disabled_opid,
@@ -71,7 +71,7 @@ static const struct automaton_opid automaton_opid = { preempt_disabled_opid, enabled_opid,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, { INVALID_STATE,
@@ -80,7 +80,7 @@ static const struct automaton_opid automaton_opid = {INVALID_STATE ,INVALID_STATE , in_irq_opid, - in_irq_opid + in_irq_opid, }, { INVALID_STATE,
@@ -89,7 +89,7 @@ static const struct automaton_opid automaton_opid = { disabled_opid,INVALID_STATE , irq_disabled_opid, -INVALID_STATE +INVALID_STATE , }, { disabled_opid,
@@ -98,7 +98,7 @@ static const struct automaton_opid automaton_opid = { INVALID_STATE, enabled_opid,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, }, .initial_state = disabled_opid,
kernel/trace/rv/monitors/sco/sco.h +6 -6
@@ -8,18 +8,18 @@#define MONITOR_NAME scoenum states_sco { - thread_context_sco =0 , + thread_context_sco, scheduling_context_sco, - state_max_sco + state_max_sco, };#define INVALID_STATE state_max_scoenum events_sco { - sched_set_state_sco =0 , + sched_set_state_sco, schedule_entry_sco, schedule_exit_sco, - event_max_sco + event_max_sco, };struct automaton_sco {
@@ -33,12 +33,12 @@ struct automaton_sco {static const struct automaton_sco automaton_sco = { .state_names = {"thread_context" , -"scheduling_context" +"scheduling_context" , }, .event_names = {"sched_set_state" ,"schedule_entry" , -"schedule_exit" +"schedule_exit" , }, .function = { { thread_context_sco, scheduling_context_sco,INVALID_STATE },
kernel/trace/rv/monitors/scpd/scpd.h +6 -6
@@ -8,19 +8,19 @@#define MONITOR_NAME scpdenum states_scpd { - cant_sched_scpd =0 , + cant_sched_scpd, can_sched_scpd, - state_max_scpd + state_max_scpd, };#define INVALID_STATE state_max_scpdenum events_scpd { - preempt_disable_scpd =0 , + preempt_disable_scpd, preempt_enable_scpd, schedule_entry_scpd, schedule_exit_scpd, - event_max_scpd + event_max_scpd, };struct automaton_scpd {
@@ -34,13 +34,13 @@ struct automaton_scpd {static const struct automaton_scpd automaton_scpd = { .state_names = {"cant_sched" , -"can_sched" +"can_sched" , }, .event_names = {"preempt_disable" ,"preempt_enable" ,"schedule_entry" , -"schedule_exit" +"schedule_exit" , }, .function = { { can_sched_scpd,INVALID_STATE ,INVALID_STATE ,INVALID_STATE },
kernel/trace/rv/monitors/snep/snep.h +8 -8
@@ -8,19 +8,19 @@#define MONITOR_NAME snepenum states_snep { - non_scheduling_context_snep =0 , + non_scheduling_context_snep, scheduling_contex_snep, - state_max_snep + state_max_snep, };#define INVALID_STATE state_max_snepenum events_snep { - preempt_disable_snep =0 , + preempt_disable_snep, preempt_enable_snep, schedule_entry_snep, schedule_exit_snep, - event_max_snep + event_max_snep, };struct automaton_snep {
@@ -34,26 +34,26 @@ struct automaton_snep {static const struct automaton_snep automaton_snep = { .state_names = {"non_scheduling_context" , -"scheduling_contex" +"scheduling_contex" , }, .event_names = {"preempt_disable" ,"preempt_enable" ,"schedule_entry" , -"schedule_exit" +"schedule_exit" , }, .function = { { non_scheduling_context_snep, non_scheduling_context_snep, scheduling_contex_snep, -INVALID_STATE +INVALID_STATE , }, {INVALID_STATE ,INVALID_STATE ,INVALID_STATE , - non_scheduling_context_snep + non_scheduling_context_snep, }, }, .initial_state = non_scheduling_context_snep,
kernel/trace/rv/monitors/snroc/snroc.h +6 -6
@@ -8,18 +8,18 @@#define MONITOR_NAME snrocenum states_snroc { - other_context_snroc =0 , + other_context_snroc, own_context_snroc, - state_max_snroc + state_max_snroc, };#define INVALID_STATE state_max_snrocenum events_snroc { - sched_set_state_snroc =0 , + sched_set_state_snroc, sched_switch_in_snroc, sched_switch_out_snroc, - event_max_snroc + event_max_snroc, };struct automaton_snroc {
@@ -33,12 +33,12 @@ struct automaton_snroc {static const struct automaton_snroc automaton_snroc = { .state_names = {"other_context" , -"own_context" +"own_context" , }, .event_names = {"sched_set_state" ,"sched_switch_in" , -"sched_switch_out" +"sched_switch_out" , }, .function = { {INVALID_STATE , own_context_snroc,INVALID_STATE },
kernel/trace/rv/monitors/sssw/sssw.h +10 -10
@@ -8,17 +8,17 @@#define MONITOR_NAME ssswenum states_sssw { - runnable_sssw =0 , + runnable_sssw, signal_wakeup_sssw, sleepable_sssw, sleeping_sssw, - state_max_sssw + state_max_sssw, };#define INVALID_STATE state_max_ssswenum events_sssw { - sched_set_state_runnable_sssw =0 , + sched_set_state_runnable_sssw, sched_set_state_sleepable_sssw, sched_switch_blocking_sssw, sched_switch_in_sssw,
@@ -27,7 +27,7 @@ enum events_sssw { sched_switch_yield_sssw, sched_wakeup_sssw, signal_deliver_sssw, - event_max_sssw + event_max_sssw, }; struct automaton_sssw {
@@ -43,7 +43,7 @@ static const struct automaton_sssw automaton_sssw = {"runnable" ,"signal_wakeup" ,"sleepable" , -"sleeping" + "sleeping", }, .event_names = { "sched_set_state_runnable",
@@ -54,7 +54,7 @@ static const struct automaton_sssw automaton_sssw = {"sched_switch_suspend" ,"sched_switch_yield" ,"sched_wakeup" , -"signal_deliver" + "signal_deliver", }, .function = { {
@@ -66,7 +66,7 @@ static const struct automaton_sssw automaton_sssw = {INVALID_STATE , runnable_sssw, runnable_sssw, - runnable_sssw + runnable_sssw, }, { INVALID_STATE,
@@ -77,7 +77,7 @@ static const struct automaton_sssw automaton_sssw = {INVALID_STATE , signal_wakeup_sssw, signal_wakeup_sssw, - runnable_sssw + runnable_sssw, }, { runnable_sssw,
@@ -88,7 +88,7 @@ static const struct automaton_sssw automaton_sssw = { sleeping_sssw, signal_wakeup_sssw, runnable_sssw, - sleepable_sssw + sleepable_sssw, }, { INVALID_STATE,
@@ -99,7 +99,7 @@ static const struct automaton_sssw automaton_sssw = { INVALID_STATE,INVALID_STATE , runnable_sssw, -INVALID_STATE +INVALID_STATE , }, }, .initial_state = runnable_sssw,
kernel/trace/rv/monitors/sts/sts.h +13 -13
@@ -8,26 +8,26 @@#define MONITOR_NAME stsenum states_sts { - can_sched_sts =0 , + can_sched_sts, cant_sched_sts, disable_to_switch_sts, enable_to_exit_sts, in_irq_sts, scheduling_sts, switching_sts, - state_max_sts + state_max_sts, };#define INVALID_STATE state_max_stsenum events_sts { - irq_disable_sts =0 , + irq_disable_sts, irq_enable_sts, irq_entry_sts, sched_switch_sts, schedule_entry_sts, schedule_exit_sts, - event_max_sts + event_max_sts, };struct automaton_sts {
@@ -46,7 +46,7 @@ static const struct automaton_sts automaton_sts = {"enable_to_exit" ,"in_irq" ,"scheduling" , -"switching" + "switching", }, .event_names = { "irq_disable",
@@ -54,7 +54,7 @@ static const struct automaton_sts automaton_sts = {"irq_entry" ,"sched_switch" ,"schedule_entry" , -"schedule_exit" + "schedule_exit", }, .function = { {
@@ -63,7 +63,7 @@ static const struct automaton_sts automaton_sts = {INVALID_STATE ,INVALID_STATE , scheduling_sts, -INVALID_STATE +INVALID_STATE , }, { INVALID_STATE,
@@ -71,7 +71,7 @@ static const struct automaton_sts automaton_sts = { cant_sched_sts,INVALID_STATE ,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, { INVALID_STATE,
@@ -79,7 +79,7 @@ static const struct automaton_sts automaton_sts = { in_irq_sts, switching_sts,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, { enable_to_exit_sts,
@@ -87,7 +87,7 @@ static const struct automaton_sts automaton_sts = { enable_to_exit_sts,INVALID_STATE ,INVALID_STATE , - can_sched_sts + can_sched_sts, }, { INVALID_STATE,
@@ -95,7 +95,7 @@ static const struct automaton_sts automaton_sts = { in_irq_sts,INVALID_STATE ,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, { disable_to_switch_sts,
@@ -103,7 +103,7 @@ static const struct automaton_sts automaton_sts = {INVALID_STATE ,INVALID_STATE ,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, { INVALID_STATE,
@@ -111,7 +111,7 @@ static const struct automaton_sts automaton_sts = { INVALID_STATE,INVALID_STATE ,INVALID_STATE , -INVALID_STATE +INVALID_STATE , }, }, .initial_state = can_sched_sts,
kernel/trace/rv/monitors/wip/wip.h +6 -6
@@ -8,18 +8,18 @@#define MONITOR_NAME wipenum states_wip { - preemptive_wip =0 , + preemptive_wip, non_preemptive_wip, - state_max_wip + state_max_wip, };#define INVALID_STATE state_max_wipenum events_wip { - preempt_disable_wip =0 , + preempt_disable_wip, preempt_enable_wip, sched_waking_wip, - event_max_wip + event_max_wip, };struct automaton_wip {
@@ -33,12 +33,12 @@ struct automaton_wip {static const struct automaton_wip automaton_wip = { .state_names = {"preemptive" , -"non_preemptive" +"non_preemptive" , }, .event_names = {"preempt_disable" ,"preempt_enable" , -"sched_waking" +"sched_waking" , }, .function = { { non_preemptive_wip,INVALID_STATE ,INVALID_STATE },
kernel/trace/rv/monitors/wwnr/wwnr.h +6 -6
@@ -8,18 +8,18 @@#define MONITOR_NAME wwnrenum states_wwnr { - not_running_wwnr =0 , + not_running_wwnr, running_wwnr, - state_max_wwnr + state_max_wwnr, };#define INVALID_STATE state_max_wwnrenum events_wwnr { - switch_in_wwnr =0 , + switch_in_wwnr, switch_out_wwnr, wakeup_wwnr, - event_max_wwnr + event_max_wwnr, };struct automaton_wwnr {
@@ -33,12 +33,12 @@ struct automaton_wwnr {static const struct automaton_wwnr automaton_wwnr = { .state_names = {"not_running" , -"running" +"running" , }, .event_names = {"switch_in" ,"switch_out" , -"wakeup" +"wakeup" , }, .function = { { running_wwnr,INVALID_STATE , not_running_wwnr },
tools/verification/rvgen/rvgen/dot2c.py +12 -24
@@ -28,11 +28,11 @@ class Dot2c(Automata): def __get_enum_states_content(self) -> list[str]: buff = [] - buff.append("\t%s%s = 0," % (self.initial_state, self.enum_suffix)) + buff.append("\t%s%s," % (self.initial_state, self.enum_suffix)) for state in self.states: if state != self.initial_state: buff.append("\t%s%s," % (state, self.enum_suffix)) - buff.append("\tstate_max%s" % (self.enum_suffix)) + buff.append("\tstate_max%s," % (self.enum_suffix)) return buff
@@ -46,15 +46,10 @@ class Dot2c(Automata): def __get_enum_events_content(self) -> list[str]: buff = [] - first = True for event in self.events: - if first: - buff.append("\t%s%s = 0," % (event, self.enum_suffix)) - first = False - else: - buff.append("\t%s%s," % (event, self.enum_suffix)) + buff.append("\t%s%s," % (event, self.enum_suffix)) - buff.append("\tevent_max%s" % self.enum_suffix) + buff.append("\tevent_max%s," % self.enum_suffix) return buff
@@ -97,18 +92,11 @@ class Dot2c(Automata): buff.append("static const struct %s %s = {" % (self.struct_automaton_def, self.var_automaton_def)) return buff - def __get_string_vector_per_line_content(self, buff: list[str]) -> str: - first = True - string = "" - for entry in buff: - if first: - string = string + "\t\t\"" + entry - first = False; - else: - string = string + "\",\n\t\t\"" + entry - string = string + "\"" - - return string + def __get_string_vector_per_line_content(self, entries: list[str]) -> str: + buff = [] + for entry in entries: + buff.append(f"\t\t\"{entry}\",") + return "\n".join(buff) def format_aut_init_events_string(self) -> list[str]: buff = []
@@ -152,7 +140,7 @@ class Dot2c(Automata): if y != nr_events-1: line += ",\n" if linetoolong else ", " else: - line += "\n\t\t}," if linetoolong else " }," + line += ",\n\t\t}," if linetoolong else " }," buff.append(line) return '\n'.join(buff)
@@ -179,12 +167,12 @@ class Dot2c(Automata): line = "" first = True for state in self.states: - if first == False: + if not first: line = line + ', ' else: first = False - if self.final_states.__contains__(state): + if state in self.final_states: line = line + '1' else: line = line + '0'
Signature · 1 line
2.51.1
Gabriele Monaco
maintainerPATCH 8/8 verification/rvgen: Remove unused variable declaration from containers
In reply to Gabriele MonacoThe monitor container source files contained a declaration and a definition for the rv_monitor variable. The former is superfluous and can be removed.
Remove the variable declaration from the template as well as the existing monitor containers.
--- kernel/trace/rv/monitors/rtapp/rtapp.c | 2 -- kernel/trace/rv/monitors/sched/sched.c | 2 -- tools/verification/rvgen/rvgen/templates/container/main.c | 2 -- 3 files changed, 6 deletions(-)
kernel/trace/rv/monitors/rtapp/rtapp.c +0 -2
@@ -8,8 +8,6 @@#include "rtapp.h" -struct rv_monitor rv_rtapp; -struct rv_monitor rv_rtapp = { .name ="rtapp" , .description ="Collection of monitors for detecting problems with real-time applications" ,
kernel/trace/rv/monitors/sched/sched.c +0 -2
@@ -8,8 +8,6 @@#include "sched.h" -struct rv_monitor rv_sched; -struct rv_monitor rv_sched = { .name ="sched" , .description ="container for several scheduler monitor specifications." ,
tools/verification/rvgen/rvgen/templates/container/main.c +0 -2
@@ -8,8 +8,6 @@#include "%%MODEL_NAME%%.h" -struct rv_monitor rv_%%MODEL_NAME%%; - struct rv_monitor rv_%%MODEL_NAME%% = { .name ="%%MODEL_NAME%%" , .description ="%%DESCRIPTION%%" ,
Signature · 1 line
2.51.1