From: Wander Lairson Costa <wander@redhat.com>
To: Nam Cao <namcao@linutronix.de>
Cc: Gabriele Monaco <gmonaco@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/13] verification/rvgen: Convert __fill_verify_guards_func() to Lark
Date: Fri, 15 May 2026 16:35:47 -0300 [thread overview]
Message-ID: <agd1Tb8RDUqfjaGn@wcosta-defaultstring.rmtbr.csb> (raw)
In-Reply-To: <e8a636c8ea6da554fd51b1241b9181f65af420c8.1777962130.git.namcao@linutronix.de>
On Tue, May 05, 2026 at 08:59:27AM +0200, Nam Cao wrote:
> Prepare to remove self.guards and self.__parse_constraints(), convert
> __fill_verify_guards_func() to use the parsed transitions from Lark.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> tools/verification/rvgen/rvgen/dot2k.py | 39 ++++++++++++++++++++-----
> 1 file changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/rvgen/rvgen/dot2k.py
> index 3a39ae29e41e..cf7e5ddc649c 100644
> --- a/tools/verification/rvgen/rvgen/dot2k.py
> +++ b/tools/verification/rvgen/rvgen/dot2k.py
> @@ -221,6 +221,20 @@ class ha2k(dot2k):
> def __parse_single_constraint(self, rule: dict, value: str) -> str:
> return f"ha_get_env(ha_mon, {rule["env"]}{self.enum_suffix}, time_ns) {rule["op"]} {value}"
>
> + def __parse_guard_rule(self, rule) -> str:
> + buff = []
> + for c, sep in rule.rules:
> + env = c.env + self.enum_suffix
> + op = c.op
> + val = self.__adjust_value(c.val, c.unit)
> +
> + cond = f"ha_get_env(ha_mon, {env}, time_ns) {op} {val}"
> + if sep:
> + cond += f" {sep}"
> + buff.append(cond)
> + buff[-1] += ';'
> + return buff
> +
> def __get_constraint_env(self, constr: str) -> str:
> """Extract the second argument from an ha_ function"""
> env = constr.split("(")[1].split()[1].rstrip(")").rstrip(",")
> @@ -398,8 +412,9 @@ f"""static inline void ha_convert_inv_guard(struct ha_monitor *ha_mon,
>
> def __fill_verify_guards_func(self) -> list[str]:
> buff = []
> - if not self.guards:
> - return []
> +
> + if not self.has_guard:
> + return
The signature of function says this function return a list, instead of
None.
>
> buff.append(
> f"""static inline bool ha_verify_guards(struct ha_monitor *ha_mon,
> @@ -410,14 +425,22 @@ f"""static inline bool ha_verify_guards(struct ha_monitor *ha_mon,
> """)
>
> _else = ""
> - for edge, constr in sorted(self.guards.items()):
> + for transition in self.transitions:
> + if not transition.rule and not transition.reset:
> + continue
> +
> buff.append(f"\t{_else}if (curr_state == "
> - f"{self.states[edge[0]]}{self.enum_suffix} && "
> - f"event == {self.events[edge[1]]}{self.enum_suffix})")
> - if constr.count(";") > 0:
> + f"{transition.src}{self.enum_suffix} && "
> + f"event == {transition.event}{self.enum_suffix})")
> + rule = transition.rule
> + reset = transition.reset
> + if rule and reset:
> buff[-1] += " {"
> - buff += [f"\t\t{c};" for c in constr.split(";")]
> - if constr.count(";") > 0:
> + if rule:
> + buff.append("\t\t" + self.__format_guard_rules(self.__parse_guard_rule(rule))[0])
> + if reset:
> + buff.append(f"\t\tha_reset_env(ha_mon, {reset.env}{self.enum_suffix}, time_ns);")
> + if rule and reset:
> _else = "} else "
> else:
> _else = "else "
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-05-15 19:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 6:59 [PATCH 00/13] rv: Convert rvgen to Lark Nam Cao
2026-05-05 6:59 ` [PATCH 01/13] verification/rvgen: Switch LTL parser " Nam Cao
2026-05-06 7:37 ` Gabriele Monaco
2026-05-10 18:18 ` Nam Cao
2026-05-15 15:55 ` Wander Lairson Costa
2026-05-05 6:59 ` [PATCH 02/13] verification/rvgen: Introduce a parse tree for automata using Lark Nam Cao
2026-05-15 18:37 ` Wander Lairson Costa
2026-05-05 6:59 ` [PATCH 03/13] verification/rvgen: Implement state and transition parser based on Lark Nam Cao
2026-05-06 14:48 ` Gabriele Monaco
2026-05-10 18:21 ` Nam Cao
2026-05-15 19:07 ` Wander Lairson Costa
2026-05-05 6:59 ` [PATCH 04/13] verification/rvgen: Convert __fill_verify_invariants_func() to Lark Nam Cao
2026-05-05 6:59 ` [PATCH 05/13] verification/rvgen: Convert __fill_setup_invariants_func() " Nam Cao
2026-05-05 6:59 ` [PATCH 06/13] verification/rvgen: Convert __fill_verify_guards_func() " Nam Cao
2026-05-06 14:51 ` Gabriele Monaco
2026-05-15 19:35 ` Wander Lairson Costa [this message]
2026-05-05 6:59 ` [PATCH 07/13] rv: Simply hybrid automata monitors's clock variables Nam Cao
2026-05-06 9:15 ` Gabriele Monaco
2026-05-11 11:55 ` Nam Cao
2026-05-12 9:31 ` Gabriele Monaco
2026-05-05 6:59 ` [PATCH 08/13] verification/rvgen: Simplify the generation for " Nam Cao
2026-05-05 6:59 ` [PATCH 09/13] verification/rvgen: Delete __parse_constraint() Nam Cao
2026-05-05 6:59 ` [PATCH 10/13] verification/rvgen: Switch __get_event_variables() to Lark Nam Cao
2026-05-05 6:59 ` [PATCH 11/13] verification/rvgen: Switch __create_matrix() " Nam Cao
2026-05-05 6:59 ` [PATCH 12/13] verification/rvgen: Remove the old state variables Nam Cao
2026-05-05 6:59 ` [PATCH 13/13] verification/rvgen: Remove dead code 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=agd1Tb8RDUqfjaGn@wcosta-defaultstring.rmtbr.csb \
--to=wander@redhat.com \
--cc=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.