From nobody Fri Feb 13 00:14:25 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F1AA1B412C for ; Thu, 2 Jan 2025 15:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735831529; cv=none; b=ET4HsvT00pHuxze4XgX1lR28AZ3HrXpMNFY9t4rNv5NKzylPUVczxmfkPqPol6iAruJm3Ve5LeQTCWqRsJk8PcAPkR6oc03vKoOlNd+/++wWju4JctwjMjLNcgkwEMCT6AyWBRQVccjRmM9TLLuBYF7FbuugaMWHkKrWTuCaA3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735831529; c=relaxed/simple; bh=LBOHGZpVehDCuyKUErCi9gCSV9N6E47fko0aozH5fOw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aPUr99KrpD6jgRFcSQtTkyfIY/hPpmpmP3SUmIPNQjqvtzQNE2M4lbbJYyrE6xejZvPDmGMrJeVABgzoVrJMmKV+hhYoTIU/68xTGagM6PtZ4EYaMj94/VrAHRpPdHpIZ85B2EdYP6j5LSQxi3oam/7R9dZJAOlBniyIdCBspeg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E13C4CED0; Thu, 2 Jan 2025 15:25:29 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tTN5x-00000005D3M-3VSY; Thu, 02 Jan 2025 10:26:45 -0500 Message-ID: <20250102152645.685427023@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 02 Jan 2025 10:26:28 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur , Juri Lelli , Thomas Gleixner , Gabriele Monaco Subject: [for-next][PATCH 4/8] verification/dot2k: Add support for name and description options References: <20250102152624.158129997@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriele Monaco The dot2k command includes options to set a model name with -n and a description with -D, however those are not used in practice. This patch allows to specify a custom model name (by default the name of the dot file without extension) and a description which overrides the one in the C file. Cc: Juri Lelli Cc: Thomas Gleixner Cc: John Kacur Link: https://lore.kernel.org/20241227144752.362911-5-gmonaco@redhat.com Signed-off-by: Gabriele Monaco Signed-off-by: Steven Rostedt (Google) --- tools/verification/dot2/automata.py | 4 ++-- tools/verification/dot2/dot2c.py | 4 ++-- tools/verification/dot2/dot2k | 6 +----- tools/verification/dot2/dot2k.py | 8 +++++--- tools/verification/dot2/dot2k_templates/main.c | 4 ++-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/verification/dot2/automata.py b/tools/verification/dot2/= automata.py index bdeb98baa8b0..f6921cf3c914 100644 --- a/tools/verification/dot2/automata.py +++ b/tools/verification/dot2/automata.py @@ -19,9 +19,9 @@ class Automata: =20 invalid_state_str =3D "INVALID_STATE" =20 - def __init__(self, file_path): + def __init__(self, file_path, model_name=3DNone): self.__dot_path =3D file_path - self.name =3D self.__get_model_name() + self.name =3D model_name or self.__get_model_name() self.__dot_lines =3D self.__open_dot() self.states, self.initial_state, self.final_states =3D self.__get_= state_variables() self.events =3D self.__get_event_variables() diff --git a/tools/verification/dot2/dot2c.py b/tools/verification/dot2/dot= 2c.py index 87d8a1e1470c..fa2816ac7b61 100644 --- a/tools/verification/dot2/dot2c.py +++ b/tools/verification/dot2/dot2c.py @@ -22,8 +22,8 @@ class Dot2c(Automata): struct_automaton_def =3D "automaton" var_automaton_def =3D "aut" =20 - def __init__(self, file_path): - super().__init__(file_path) + def __init__(self, file_path, model_name=3DNone): + super().__init__(file_path, model_name) self.line_length =3D 100 =20 def __buff_to_string(self, buff): diff --git a/tools/verification/dot2/dot2k b/tools/verification/dot2/dot2k index d4d7e52d549e..827b62b8d5e1 100644 --- a/tools/verification/dot2/dot2k +++ b/tools/verification/dot2/dot2k @@ -25,16 +25,12 @@ if __name__ =3D=3D '__main__': =20 print("Opening and parsing the dot file %s" % params.dot_file) try: - monitor=3Ddot2k(params.dot_file, params.monitor_type) + monitor=3Ddot2k(params.dot_file, params.monitor_type, vars(params)) except Exception as e: print('Error: '+ str(e)) print("Sorry : :-(") sys.exit(1) =20 - # easier than using argparse action. - if params.model_name !=3D None: - print(params.model_name) - print("Writing the monitor into the directory %s" % monitor.name) monitor.print_files() print("Almost done, checklist") diff --git a/tools/verification/dot2/dot2k.py b/tools/verification/dot2/dot= 2k.py index c88b3c011706..d48ad86a035a 100644 --- a/tools/verification/dot2/dot2k.py +++ b/tools/verification/dot2/dot2k.py @@ -17,17 +17,18 @@ class dot2k(Dot2c): monitor_templates_dir =3D "dot2/dot2k_templates/" monitor_type =3D "per_cpu" =20 - def __init__(self, file_path, MonitorType): - super().__init__(file_path) + def __init__(self, file_path, MonitorType, extra_params=3D{}): + super().__init__(file_path, extra_params.get("model_name")) =20 self.monitor_type =3D self.monitor_types.get(MonitorType) if self.monitor_type is None: - raise Exception("Unknown monitor type: %s" % MonitorType) + raise ValueError("Unknown monitor type: %s" % MonitorType) =20 self.monitor_type =3D MonitorType self.__fill_rv_templates_dir() self.main_c =3D self.__open_file(self.monitor_templates_dir + "mai= n.c") self.enum_suffix =3D "_%s" % self.name + self.description =3D extra_params.get("description", self.name) or= "auto-generated" =20 def __fill_rv_templates_dir(self): =20 @@ -114,6 +115,7 @@ class dot2k(Dot2c): main_c =3D main_c.replace("%%TRACEPOINT_HANDLERS_SKEL%%", tracepoi= nt_handlers) main_c =3D main_c.replace("%%TRACEPOINT_ATTACH%%", tracepoint_atta= ch) main_c =3D main_c.replace("%%TRACEPOINT_DETACH%%", tracepoint_deta= ch) + main_c =3D main_c.replace("%%DESCRIPTION%%", self.description) =20 return main_c =20 diff --git a/tools/verification/dot2/dot2k_templates/main.c b/tools/verific= ation/dot2/dot2k_templates/main.c index 4a05fef7f3c7..704617168578 100644 --- a/tools/verification/dot2/dot2k_templates/main.c +++ b/tools/verification/dot2/dot2k_templates/main.c @@ -65,7 +65,7 @@ static void disable_%%MODEL_NAME%%(void) */ static struct rv_monitor rv_%%MODEL_NAME%% =3D { .name =3D "%%MODEL_NAME%%", - .description =3D "auto-generated %%MODEL_NAME%%", + .description =3D "%%DESCRIPTION%%", .enable =3D enable_%%MODEL_NAME%%, .disable =3D disable_%%MODEL_NAME%%, .reset =3D da_monitor_reset_all_%%MODEL_NAME%%, @@ -88,4 +88,4 @@ module_exit(unregister_%%MODEL_NAME%%); =20 MODULE_LICENSE("GPL"); MODULE_AUTHOR("dot2k: auto-generated"); -MODULE_DESCRIPTION("%%MODEL_NAME%%"); +MODULE_DESCRIPTION("%%MODEL_NAME%%: %%DESCRIPTION%%"); --=20 2.45.2