From nobody Fri Feb 13 00:13:58 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 61BD21B3948 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=P40WikgmuNh1bc7PcA2GBFnDLUjP/e1q8UHdKjmwiCjuJCmsY1NJkMRh0Mq6eepk/gUkd6zbRvx6+d96867lgkduy83WHjrYxyW9EK0yR8zvNndqaEPuyLvmfx4vMK/vtBx7jj+1jMyU143AM59cZRhS/zUo/662MqENZetgU7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735831529; c=relaxed/simple; bh=UlKAYwE7yn3gd658NvD+bigwqNUx79SiWgbRpGYEq+U=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=K4yQRoMaag4XdAItfWuHNDgf+/+8JdcvXSRAlsHR5s5vWmLmo6H6jYXYWap0Ppy7buf/9xylMB2k8WsOBYChPoML4FC+YjCg5FTPmZ/TpZmtJLSEUS1MnHhf+1Gm3eBW66waEQDKp7yfpHWX89bGEw1/VHHCVHIWsjuubyU3sKM= 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 06751C4CEDC; Thu, 2 Jan 2025 15:25:29 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tTN5x-00000005D2O-24G1; Thu, 02 Jan 2025 10:26:45 -0500 Message-ID: <20250102152645.346206072@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 02 Jan 2025 10:26:26 -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 2/8] verification/dot2k: Unify main.c templates 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 dot2k has 3 templates, one per monitor type, but the only difference among them is the `DECLARE_DA_MON_*` call, keeping 3 almost identical templates requires more work whenever we introduce a change. This patch removes the 3 dot2k templates and replaces them with a generic one, we then adjust the model type from the script. Cc: Juri Lelli Cc: Thomas Gleixner Cc: John Kacur Link: https://lore.kernel.org/20241227144752.362911-3-gmonaco@redhat.com Signed-off-by: Gabriele Monaco Signed-off-by: Steven Rostedt (Google) --- tools/verification/dot2/dot2k.py | 7 +- .../dot2k_templates/{main_global.c =3D> main.c} | 2 +- .../dot2/dot2k_templates/main_per_cpu.c | 91 ------------------- .../dot2/dot2k_templates/main_per_task.c | 91 ------------------- 4 files changed, 7 insertions(+), 184 deletions(-) rename tools/verification/dot2/dot2k_templates/{main_global.c =3D> main.c}= (97%) delete mode 100644 tools/verification/dot2/dot2k_templates/main_per_cpu.c delete mode 100644 tools/verification/dot2/dot2k_templates/main_per_task.c diff --git a/tools/verification/dot2/dot2k.py b/tools/verification/dot2/dot= 2k.py index f6d02e3406a3..15d6f7048f8d 100644 --- a/tools/verification/dot2/dot2k.py +++ b/tools/verification/dot2/dot2k.py @@ -26,7 +26,7 @@ class dot2k(Dot2c): =20 self.monitor_type =3D MonitorType self.__fill_rv_templates_dir() - self.main_c =3D self.__open_file(self.monitor_templates_dir + "mai= n_" + MonitorType + ".c") + self.main_c =3D self.__open_file(self.monitor_templates_dir + "mai= n.c") self.enum_suffix =3D "_%s" % self.name =20 def __fill_rv_templates_dir(self): @@ -69,6 +69,9 @@ class dot2k(Dot2c): # cut off the last \n return string[:-1] =20 + def fill_monitor_type(self): + return self.monitor_type.upper() + def fill_tracepoint_handlers_skel(self): buff =3D [] for event in self.events: @@ -97,12 +100,14 @@ class dot2k(Dot2c): =20 def fill_main_c(self): main_c =3D self.main_c + monitor_type =3D self.fill_monitor_type() min_type =3D self.get_minimun_type() nr_events =3D len(self.events) tracepoint_handlers =3D self.fill_tracepoint_handlers_skel() tracepoint_attach =3D self.fill_tracepoint_attach_probe() tracepoint_detach =3D self.fill_tracepoint_detach_helper() =20 + main_c =3D main_c.replace("MONITOR_TYPE", monitor_type) main_c =3D main_c.replace("MIN_TYPE", min_type) main_c =3D main_c.replace("MODEL_NAME", self.name) main_c =3D main_c.replace("NR_EVENTS", str(nr_events)) diff --git a/tools/verification/dot2/dot2k_templates/main_global.c b/tools/= verification/dot2/dot2k_templates/main.c similarity index 97% rename from tools/verification/dot2/dot2k_templates/main_global.c rename to tools/verification/dot2/dot2k_templates/main.c index a5658bfb9044..2419a6f89cd8 100644 --- a/tools/verification/dot2/dot2k_templates/main_global.c +++ b/tools/verification/dot2/dot2k_templates/main.c @@ -28,7 +28,7 @@ * The rv monitor reference is needed for the monitor declaration. */ static struct rv_monitor rv_MODEL_NAME; -DECLARE_DA_MON_GLOBAL(MODEL_NAME, MIN_TYPE); +DECLARE_DA_MON_MONITOR_TYPE(MODEL_NAME, MIN_TYPE); =20 /* * This is the instrumentation part of the monitor. diff --git a/tools/verification/dot2/dot2k_templates/main_per_cpu.c b/tools= /verification/dot2/dot2k_templates/main_per_cpu.c deleted file mode 100644 index 03539a97633f..000000000000 --- a/tools/verification/dot2/dot2k_templates/main_per_cpu.c +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include -#include -#include -#include -#include - -#define MODULE_NAME "MODEL_NAME" - -/* - * XXX: include required tracepoint headers, e.g., - * #include - */ -#include - -/* - * This is the self-generated part of the monitor. Generally, there is no = need - * to touch this section. - */ -#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_PER_CPU(MODEL_NAME, MIN_TYPE); - -/* - * This is the instrumentation part of the monitor. - * - * This is the section where manual work is required. Here the kernel even= ts - * are translated into model's event. - * - */ -TRACEPOINT_HANDLERS_SKEL -static int enable_MODEL_NAME(void) -{ - int retval; - - retval =3D da_monitor_init_MODEL_NAME(); - if (retval) - return retval; - -TRACEPOINT_ATTACH - - return 0; -} - -static void disable_MODEL_NAME(void) -{ - rv_MODEL_NAME.enabled =3D 0; - -TRACEPOINT_DETACH - - da_monitor_destroy_MODEL_NAME(); -} - -/* - * This is the monitor register section. - */ -static struct rv_monitor rv_MODEL_NAME =3D { - .name =3D "MODEL_NAME", - .description =3D "auto-generated MODEL_NAME", - .enable =3D enable_MODEL_NAME, - .disable =3D disable_MODEL_NAME, - .reset =3D da_monitor_reset_all_MODEL_NAME, - .enabled =3D 0, -}; - -static int __init register_MODEL_NAME(void) -{ - rv_register_monitor(&rv_MODEL_NAME); - return 0; -} - -static void __exit unregister_MODEL_NAME(void) -{ - rv_unregister_monitor(&rv_MODEL_NAME); -} - -module_init(register_MODEL_NAME); -module_exit(unregister_MODEL_NAME); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("dot2k: auto-generated"); -MODULE_DESCRIPTION("MODEL_NAME"); diff --git a/tools/verification/dot2/dot2k_templates/main_per_task.c b/tool= s/verification/dot2/dot2k_templates/main_per_task.c deleted file mode 100644 index ffd92af87a86..000000000000 --- a/tools/verification/dot2/dot2k_templates/main_per_task.c +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include -#include -#include -#include -#include - -#define MODULE_NAME "MODEL_NAME" - -/* - * XXX: include required tracepoint headers, e.g., - * #include - */ -#include - -/* - * This is the self-generated part of the monitor. Generally, there is no = need - * to touch this section. - */ -#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_PER_TASK(MODEL_NAME, MIN_TYPE); - -/* - * This is the instrumentation part of the monitor. - * - * This is the section where manual work is required. Here the kernel even= ts - * are translated into model's event. - * - */ -TRACEPOINT_HANDLERS_SKEL -static int enable_MODEL_NAME(void) -{ - int retval; - - retval =3D da_monitor_init_MODEL_NAME(); - if (retval) - return retval; - -TRACEPOINT_ATTACH - - return 0; -} - -static void disable_MODEL_NAME(void) -{ - rv_MODEL_NAME.enabled =3D 0; - -TRACEPOINT_DETACH - - da_monitor_destroy_MODEL_NAME(); -} - -/* - * This is the monitor register section. - */ -static struct rv_monitor rv_MODEL_NAME =3D { - .name =3D "MODEL_NAME", - .description =3D "auto-generated MODEL_NAME", - .enable =3D enable_MODEL_NAME, - .disable =3D disable_MODEL_NAME, - .reset =3D da_monitor_reset_all_MODEL_NAME, - .enabled =3D 0, -}; - -static int __init register_MODEL_NAME(void) -{ - rv_register_monitor(&rv_MODEL_NAME); - return 0; -} - -static void __exit unregister_MODEL_NAME(void) -{ - rv_unregister_monitor(&rv_MODEL_NAME); -} - -module_init(register_MODEL_NAME); -module_exit(unregister_MODEL_NAME); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("dot2k: auto-generated"); -MODULE_DESCRIPTION("MODEL_NAME"); --=20 2.45.2