Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp497332imn; Wed, 27 Jul 2022 11:52:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhcMHPlMmR4ITeplO3fgH5VoXOMhXI1xsBFhaKYCEHPjhtzThfypxu9wa6aQ36q3RWFdzP X-Received: by 2002:a17:907:7607:b0:72f:643d:2720 with SMTP id jx7-20020a170907760700b0072f643d2720mr18374631ejc.5.1658947970382; Wed, 27 Jul 2022 11:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658947970; cv=none; d=google.com; s=arc-20160816; b=wXP7XkLZPqNQzx8/vh4ne1SC3uqdIeF4+nNI974Sd09x32SFSK3AS+YirUG0pvjwUz rqC2/RmENDHBg2mK89IAOoO/IJCKUry48ULn9+qBBJzYzf9srnfNmCwQ1iNWnaDlWqm2 X22GxLVmXjo1shD8vLrkBCwcDvrmTroNHGg6rLWShFSt73sgORHEcEcTip3N3eFytTUe 67VGUX/LA4S6pfsn/6XnpQ9pWC3gHW3xKjzBb0gh53AKOon3OSZ5yEIqEcUY5+vxbvzQ CPzHIX7qy88wjam/3jBblipRxc7a7ECZtGM+gg6Rsnxvddj5aFBYt3Rrf+NMvakTlXS/ mYSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vff5xv3q8QobPOOC2rT4XJb9u2DgwMjfrmt4cmYVsGQ=; b=Rot3lElceC36LQbE2j7J16MqjQYB0klmKnRy/Nvqq7Xdfh+gw4555NJKIIltbi75Ec vlZth5/oCL04hKwx0Pj8WYqlMqBG6hCSCkHz/R3fe4+/5vlJV1nTFaceFbjJfYHfqGfW OpQ/QIZFMT5Uf2veIkKsVmrxSpawOxlnNcKp8CdgDMWFNNUEmQBcA0QFKhRIq6TkatLA e5C5qIS7S/c38+KoSZVisp3EszPMIPDI5NLTttOhEqxS+yWaRYrqCMdhsOI5gEjoibq4 BwPBVWhgVcAdcdHZKh6pW3Y5Cv/R1T/5HWsBNBEoiMyhDIe2dgCa64Ynm+x6sa8pJmn6 lYUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZnZQ8KFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a170906501300b0072b4b0b6908si15107133ejj.892.2022.07.27.11.52.23; Wed, 27 Jul 2022 11:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZnZQ8KFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243374AbiG0SLv (ORCPT + 99 others); Wed, 27 Jul 2022 14:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232553AbiG0SLQ (ORCPT ); Wed, 27 Jul 2022 14:11:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E514F753A0; Wed, 27 Jul 2022 10:13:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C07C619A5; Wed, 27 Jul 2022 17:13:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DAF5C433C1; Wed, 27 Jul 2022 17:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658941993; bh=GB41tQKICNtDkQFxA/QWse4BCeG2/JC8OIwADKGp+BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnZQ8KFouL/5moGfns7bN3RXFq+RyPqxtalTD4RGSFF7yKOxPxi/Z97WJEKHAKq0l GVBOzLcfNs/cfe5u8VUZsX2Ovxk+wwD6Ano5f2v1I+Cvn8suN6F83rHFfvMUZZmkNj PcpT7rRxTvUvTNUYWx2rzX7ys7hdY1hd0FyIw0EQ8u+ghSFM+3Yqk/qFr4XAiE/T9p 7eQ4AAWOIj+Tda6YicRqcvhuB9W/bof+jyRqgXqL6XqlMeV7aXgL36oZGHjTd0D7d5 RlBNDghDYXdAXmwDsahjQq3wiZCT8mqJK1Dr918Jb/CawnLrIMCM+uBmoqxXOYWkAP /BF37GRDFv9uA== From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Wim Van Sebroeck , Guenter Roeck , Jonathan Corbet , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Will Deacon , Catalin Marinas , Marco Elver , Dmitry Vyukov , "Paul E. McKenney" , Shuah Khan , Gabriele Paoloni , Juri Lelli , Clark Williams , Tao Zhou , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH V8 12/16] rv/monitor: Add the wip monitor skeleton created by dot2k Date: Wed, 27 Jul 2022 19:11:40 +0200 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org THIS CODE IS NOT LINKED TO THE MAKEFILE. This model does not compile because it lacks the instrumentation part, which will be added next. In the typical case, there will be only one patch, but it was split into two patches for educational purposes. This is the direct output this command line: $ dot2k -d tools/verification/models/wip.dot -t per_cpu Cc: Wim Van Sebroeck Cc: Guenter Roeck Cc: Jonathan Corbet Cc: Steven Rostedt Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Will Deacon Cc: Catalin Marinas Cc: Marco Elver Cc: Dmitry Vyukov Cc: "Paul E. McKenney" Cc: Shuah Khan Cc: Gabriele Paoloni Cc: Juri Lelli Cc: Clark Williams Cc: Tao Zhou Cc: Randy Dunlap Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira --- kernel/trace/rv/monitors/wip/wip.c | 109 +++++++++++++++++++++++++++++ kernel/trace/rv/monitors/wip/wip.h | 46 ++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 kernel/trace/rv/monitors/wip/wip.c create mode 100644 kernel/trace/rv/monitors/wip/wip.h diff --git a/kernel/trace/rv/monitors/wip/wip.c b/kernel/trace/rv/monitors/wip/wip.c new file mode 100644 index 000000000000..79a054ca0cde --- /dev/null +++ b/kernel/trace/rv/monitors/wip/wip.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include +#include + +#define MODULE_NAME "wip" + +/* + * 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 "wip.h" + +/* + * Declare the deterministic automata monitor. + * + * The rv monitor reference is needed for the monitor declaration. + */ +struct rv_monitor rv_wip; +DECLARE_DA_MON_PER_CPU(wip, unsigned char); + +/* + * This is the instrumentation part of the monitor. + * + * This is the section where manual work is required. Here the kernel events + * are translated into model's event. + * + */ +static void handle_preempt_disable(void *data, /* XXX: fill header */) +{ + da_handle_event_wip(preempt_disable_wip); +} + +static void handle_preempt_enable(void *data, /* XXX: fill header */) +{ + da_handle_event_wip(preempt_enable_wip); +} + +static void handle_sched_waking(void *data, /* XXX: fill header */) +{ + da_handle_event_wip(sched_waking_wip); +} + +static int enable_wip(void) +{ + int retval; + + retval = da_monitor_init_wip(); + if (retval) + return retval; + + rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable); + rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable); + rv_attach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking); + + return 0; +} + +static void disable_wip(void) +{ + rv_wip.enabled = 0; + + rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_disable); + rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_preempt_enable); + rv_detach_trace_probe("wip", /* XXX: tracepoint */, handle_sched_waking); + + da_monitor_destroy_wip(); +} + +/* + * This is the monitor register section. + */ +struct rv_monitor rv_wip = { + .name = "wip", + .description = "auto-generated wip", + .enable = enable_wip, + .disable = disable_wip, + .reset = da_monitor_reset_all_wip, + .enabled = 0, +}; + +static int register_wip(void) +{ + rv_register_monitor(&rv_wip); + return 0; +} + +static void unregister_wip(void) +{ + rv_unregister_monitor(&rv_wip); +} + +module_init(register_wip); +module_exit(unregister_wip); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("dot2k: auto-generated"); +MODULE_DESCRIPTION("wip"); diff --git a/kernel/trace/rv/monitors/wip/wip.h b/kernel/trace/rv/monitors/wip/wip.h new file mode 100644 index 000000000000..c1c47e2305ef --- /dev/null +++ b/kernel/trace/rv/monitors/wip/wip.h @@ -0,0 +1,46 @@ +/* + * Automatically generated C representation of wip automaton + * For further information about this format, see kernel documentation: + * Documentation/trace/rv/deterministic_automata.rst + */ + +enum states_wip { + preemptive_wip = 0, + non_preemptive_wip, + state_max_wip +}; + +#define INVALID_STATE state_max_wip + +enum events_wip { + preempt_disable_wip = 0, + preempt_enable_wip, + sched_waking_wip, + event_max_wip +}; + +struct automaton_wip { + char *state_names[state_max_wip]; + char *event_names[event_max_wip]; + unsigned char function[state_max_wip][event_max_wip]; + unsigned char initial_state; + bool final_states[state_max_wip]; +}; + +struct automaton_wip automaton_wip = { + .state_names = { + "preemptive", + "non_preemptive" + }, + .event_names = { + "preempt_disable", + "preempt_enable", + "sched_waking" + }, + .function = { + { non_preemptive_wip, INVALID_STATE, INVALID_STATE }, + { INVALID_STATE, preemptive_wip, non_preemptive_wip }, + }, + .initial_state = preemptive_wip, + .final_states = { 1, 0 }, +}; -- 2.35.1