From: Gabriele Monaco <gmonaco@redhat.com>
To: Nam Cao <namcao@linutronix.de>,
Wander Lairson Costa <wander@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 04/13] verification/rvgen: Convert __fill_verify_invariants_func() to Lark
Date: Wed, 03 Jun 2026 16:56:53 +0200 [thread overview]
Message-ID: <0a33f1104792311e738bc3fdf08037d7d3e59508.camel@redhat.com> (raw)
In-Reply-To: <d1fbbafd8af64a9663b3982845ecb2c3c5a4eded.1779956342.git.namcao@linutronix.de>
On Thu, 2026-05-28 at 10:27 +0200, Nam Cao wrote:
> Convert __fill_verify_invariants_func() to use the parsed states
> information from Lark, prepare to remove the old raw text parsing
> code.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
> ---
> v2: fix up __start_to_invariant_check()'s signature [Sashiko]
> ---
> tools/verification/rvgen/rvgen/dot2k.py | 32 ++++++++++++++++-------
> --
> 1 file changed, 21 insertions(+), 11 deletions(-)
>
> diff --git a/tools/verification/rvgen/rvgen/dot2k.py
> b/tools/verification/rvgen/rvgen/dot2k.py
> index e6f476b903b0..a344cbbcb346 100644
> --- a/tools/verification/rvgen/rvgen/dot2k.py
> +++ b/tools/verification/rvgen/rvgen/dot2k.py
> @@ -12,6 +12,7 @@ from collections import deque
> from .dot2c import Dot2c
> from .generator import Monitor
> from .automata import _EventConstraintKey, _StateConstraintKey,
> AutomataError
> +from .automata import ConstraintRule, ConstraintCondition
>
>
> class dot2k(Monitor, Dot2c):
> @@ -177,6 +178,14 @@ class ha2k(dot2k):
> raise AutomataError("Detected deterministic automaton,
> use the 'da' class")
> self.trace_h = self._read_template_file("trace_hybrid.h")
> self.__parse_constraints()
> + self.has_invariant = False
> + self.has_guard = False
> + for state in self._states:
> + if state.inv:
> + self.has_invariant = True
> + for transition in self.transitions:
> + if transition.rule or transition.reset:
> + self.has_guard = True
>
> def fill_monitor_class_type(self) -> str:
> if self._is_id_monitor():
> @@ -218,14 +227,13 @@ class ha2k(dot2k):
> assert env.rstrip(f"_{self.name}") in self.envs
> return env
>
> - def __start_to_invariant_check(self, constr: str) -> str:
> + def __start_to_invariant_check(self, inv: ConstraintCondition) -
> > str:
> # by default assume the timer has ns expiration
> - env = self.__get_constraint_env(constr)
> clock_type = "ns"
> - if self.env_types.get(env.rstrip(f"_{self.name}")) == "j":
> + if inv.unit == "j":
> clock_type = "jiffy"
>
> - return f"return ha_check_invariant_{clock_type}(ha_mon,
> {env}, time_ns)"
> + return f"return ha_check_invariant_{clock_type}(ha_mon,
> {inv.env}_{self.name}, time_ns)"
>
> def __start_to_conv(self, constr: str) -> str:
> """
> @@ -320,20 +328,22 @@ class ha2k(dot2k):
> self.invariants[key] = rules[0]
>
> def __fill_verify_invariants_func(self) -> list[str]:
> - buff = []
> - if not self.invariants:
> + if not self.has_invariant:
> return []
>
> - buff.append(
> + buff = [
> f"""static inline bool ha_verify_invariants(struct ha_monitor
> *ha_mon,
> \t\t\t\t\tenum {self.enum_states_def} curr_state, enum
> {self.enum_events_def} event,
> \t\t\t\t\tenum {self.enum_states_def} next_state, u64 time_ns)
> -{{""")
> +{{"""]
>
> _else = ""
> - for state, constr in sorted(self.invariants.items()):
> - check_str = self.__start_to_invariant_check(constr)
> - buff.append(f"\t{_else}if (curr_state ==
> {self.states[state]}{self.enum_suffix})")
> + for state in self._states:
> + if not state.inv:
> + continue
> +
> + check_str = self.__start_to_invariant_check(state.inv)
> + buff.append(f"\t{_else}if (curr_state ==
> {state.name}{self.enum_suffix})")
> buff.append(f"\t\t{check_str};")
> _else = "else "
>
next prev parent reply other threads:[~2026-06-03 14:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 8:27 [PATCH v2 00/13] rv: Convert rvgen " Nam Cao
2026-05-28 8:27 ` [PATCH v2 01/13] verification/rvgen: Switch LTL parser " Nam Cao
2026-06-03 14:49 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 02/13] verification/rvgen: Introduce a parse tree for automata using Lark Nam Cao
2026-06-03 14:55 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 03/13] verification/rvgen: Implement state and transition parser based on Lark Nam Cao
2026-06-03 14:55 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 04/13] verification/rvgen: Convert __fill_verify_invariants_func() to Lark Nam Cao
2026-06-03 14:56 ` Gabriele Monaco [this message]
2026-05-28 8:27 ` [PATCH v2 05/13] verification/rvgen: Convert __fill_setup_invariants_func() " Nam Cao
2026-06-03 15:24 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 06/13] verification/rvgen: Convert __fill_verify_guards_func() " Nam Cao
2026-06-03 16:00 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 07/13] rv: Simply hybrid automata monitors's clock variables Nam Cao
2026-06-03 9:27 ` Gabriele Monaco
2026-05-28 8:27 ` [PATCH v2 08/13] verification/rvgen: Simplify the generation for " Nam Cao
2026-05-28 8:27 ` [PATCH v2 09/13] verification/rvgen: Delete __parse_constraint() Nam Cao
2026-05-28 8:27 ` [PATCH v2 10/13] verification/rvgen: Switch __get_event_variables() to Lark Nam Cao
2026-05-28 8:27 ` [PATCH v2 11/13] verification/rvgen: Switch __create_matrix() " Nam Cao
2026-05-28 8:28 ` [PATCH v2 12/13] verification/rvgen: Remove the old state variables Nam Cao
2026-05-28 8:28 ` [PATCH v2 13/13] verification/rvgen: Remove dead code Nam Cao
2026-06-03 15:36 ` Gabriele Monaco
2026-06-08 8:29 ` Nam Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a33f1104792311e738bc3fdf08037d7d3e59508.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
--cc=wander@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome