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 91CE11B4F0B for ; Thu, 2 Jan 2025 15:25:30 +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=1735831530; cv=none; b=dK/eT4FyiX64xt1z32F9qWwtpSyjKa/wZopJsJd0dXILDlDnWcoSinm32mhzmvtgy1S6BsKye0oBKdacTC2hdoxaGYdF+ld2ojjIHqHJ2zgqeRYjkQTvYTbfpNREMJUVc1lU3aKMKp+9PrANL3oqXcMsLEm8AP/BK0GY4YYlPtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735831530; c=relaxed/simple; bh=yiJgUPVyFoMU4d0dansubiZtLlBIGATtO9cH+gWWT2M=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=MtRTqXOkMAGDIpmJh2pE08hUah6Kc4ValowoNLWmDq5DU9qyLtx5SM7BXmgkR5zYqffl8PkEIu3QyPnadSDIbM+71IQXJJSMrskhZZbJZaJl2gWnB3SU4SSDWszHJV1j8WxI/khEe6shrdwJR1JfPtPQlF4WMCBL51fruAQ9auw= 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 1E045C4CEE3; Thu, 2 Jan 2025 15:25:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tTN5y-00000005D5L-2AWk; Thu, 02 Jan 2025 10:26:46 -0500 Message-ID: <20250102152646.368523593@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 02 Jan 2025 10:26:32 -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 8/8] verification/dot2k: Implement event type detection 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 Currently dot2k treats all events equally and registers them with a general da_handle_event. This is however just part of the work because some events are necessary to understand when the monitor is entering the initial state. Specifically, the da_handle_start_event takes care of setting the monitor in the initial state and da_handle_start_run_event also registers the current event in the newly enabled monitor. da_handle_start_event can be used on events that only lead to the initial state (as it is currently done in the example monitors), while da_handle_start_run_event could be used on events that are only valid from the initial one. Failing to set at least one of those functions to handle events makes the monitor useless, since it will never be activated. This patch adapts dot2k to parse the events that surely lead to the initial state and set da_handle_start_event for those, if no such event is found but some events are only valid in the initial event, we instead set da_handle_start_run_event (it isn't necessary to set both). We still add a comment to warn the user to make sure this change is matching the model definition. Cc: Juri Lelli Cc: Thomas Gleixner Cc: John Kacur Link: https://lore.kernel.org/20241227144752.362911-9-gmonaco@redhat.com Signed-off-by: Gabriele Monaco Signed-off-by: Steven Rostedt (Google) --- tools/verification/dot2/automata.py | 32 +++++++++++++++++++++++++++++ tools/verification/dot2/dot2k.py | 11 ++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tools/verification/dot2/automata.py b/tools/verification/dot2/= automata.py index f6921cf3c914..d9a3fe2b74bf 100644 --- a/tools/verification/dot2/automata.py +++ b/tools/verification/dot2/automata.py @@ -26,6 +26,7 @@ class Automata: self.states, self.initial_state, self.final_states =3D self.__get_= state_variables() self.events =3D self.__get_event_variables() self.function =3D self.__create_matrix() + self.events_start, self.events_start_run =3D self.__store_init_eve= nts() =20 def __get_model_name(self): basename =3D ntpath.basename(self.__dot_path) @@ -172,3 +173,34 @@ class Automata: cursor +=3D 1 =20 return matrix + + def __store_init_events(self): + events_start =3D [False] * len(self.events) + events_start_run =3D [False] * len(self.events) + for i, _ in enumerate(self.events): + curr_event_will_init =3D 0 + curr_event_from_init =3D False + curr_event_used =3D 0 + for j, _ in enumerate(self.states): + if self.function[j][i] !=3D self.invalid_state_str: + curr_event_used +=3D 1 + if self.function[j][i] =3D=3D self.initial_state: + curr_event_will_init +=3D 1 + if self.function[0][i] !=3D self.invalid_state_str: + curr_event_from_init =3D True + # this event always leads to init + if curr_event_will_init and curr_event_used =3D=3D curr_event_= will_init: + events_start[i] =3D True + # this event is only called from init + if curr_event_from_init and curr_event_used =3D=3D 1: + events_start_run[i] =3D True + return events_start, events_start_run + + def is_start_event(self, event): + return self.events_start[self.events.index(event)] + + def is_start_run_event(self, event): + # prefer handle_start_event if there + if any(self.events_start): + return False + return self.events_start_run[self.events.index(event)] diff --git a/tools/verification/dot2/dot2k.py b/tools/verification/dot2/dot= 2k.py index 83f4d49853a2..7547eb290b7d 100644 --- a/tools/verification/dot2/dot2k.py +++ b/tools/verification/dot2/dot2k.py @@ -110,11 +110,18 @@ class dot2k(Dot2c): for event in self.events: buff.append("static void handle_%s(void *data, /* XXX: fill he= ader */)" % event) buff.append("{") + handle =3D "handle_event" + if self.is_start_event(event): + buff.append("\t/* XXX: validate that this event always lea= ds to the initial state */") + handle =3D "handle_start_event" + elif self.is_start_run_event(event): + buff.append("\t/* XXX: validate that this event is only va= lid in the initial state */") + handle =3D "handle_start_run_event" if self.monitor_type =3D=3D "per_task": buff.append("\tstruct task_struct *p =3D /* XXX: how do I = get p? */;"); - buff.append("\tda_handle_event_%s(p, %s%s);" % (self.name,= event, self.enum_suffix)); + buff.append("\tda_%s_%s(p, %s%s);" % (handle, self.name, e= vent, self.enum_suffix)); else: - buff.append("\tda_handle_event_%s(%s%s);" % (self.name, ev= ent, self.enum_suffix)); + buff.append("\tda_%s_%s(%s%s);" % (handle, self.name, even= t, self.enum_suffix)); buff.append("}") buff.append("") return self.__buff_to_string(buff) --=20 2.45.2