Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4661136imw; Tue, 19 Jul 2022 10:44:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sb6WSR/zYcrtc/1FQ+iPDWdFPuh5c9vKYaV+ovPykJmhpS9IDd0OFR1uevRcFNkPT/0Kim X-Received: by 2002:a17:907:2cf6:b0:72b:9d9b:2404 with SMTP id hz22-20020a1709072cf600b0072b9d9b2404mr31338889ejc.171.1658252690170; Tue, 19 Jul 2022 10:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658252690; cv=none; d=google.com; s=arc-20160816; b=mGKFdXVmGi0/BzSrodpHPYXCbcbYhBJZvG5DOONqBVeS16V0T0EYDJLdNqSHWBZTEA BRVzcOjDKH+sEu6Qx2i7SCX3FJhg1+QquIsOw8CDmYh2OvNaf3365tqSPbSvndC+smwL nakVZZKH1kB2jwF9KDXWzLDU6e4mhaSd55V/MCnAIuCPp3hXpDMckzkGIhVSewpBeCEb rICVcZIw4Lh3b7h4o2rzo8XoAauk5uBjR08s9XGFc0M3MAzWa9FKneapXqbwEjLdgpzi 97IV5zOzj9viRQUdjkp7Tl7joVpVCrEtolitDHUN7gzmzqdvLYGUh5fTd0+fuS3bBBCR 2l3Q== 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=qJde/6wm4MdKSDaEunjdUYLpU3pZmD6+h6mMMwAwLzM=; b=q961IxULEpZFLsOHKdG+Cazvau1axBqa63b3k9naKl5GNaK6rJSbQvAyVtiljINdK9 fEMtn13T6css5qdRRBKax2zDSNHzrXntMbokImKdgutvelvUYihkUT3Ohv2WUo2HB37W Hv1ZtMDcE6F+oruwm4i6z3CEvHqOMrZ+oFU288IYFojdcs3+4K7jWSDpix4lt90nw8Lr LhnPTb+J1PNSmxB5Btqejb7q4igYS4fwgnIn5Bny6RltoVTjE1sdWYAtKotIHGUUqa/O QwYhEdg+PcjvebGyNQks2DCu5SkHxfhop9AFCcXlhQD6X5bsHEykXOJRazZ3yPCGfp6i IhGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RydTGFMe; 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 cw18-20020a170906479200b0072f390774a6si7488365ejc.769.2022.07.19.10.44.24; Tue, 19 Jul 2022 10:44: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=RydTGFMe; 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 S238260AbiGSRbL (ORCPT + 99 others); Tue, 19 Jul 2022 13:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239378AbiGSR2v (ORCPT ); Tue, 19 Jul 2022 13:28:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1AE4564D7; Tue, 19 Jul 2022 10:28:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id 4B4FBB81C87; Tue, 19 Jul 2022 17:28:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BE45C385A2; Tue, 19 Jul 2022 17:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658251715; bh=aL55Ew5FOalu5k/bgXDQmio5/FDliY3L69FBD3KfmNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RydTGFMesUWHsH2Sc0U0WbaVWkH+5LbVdBmunrstc9e3jV3BryN1fToE10UZFxxaK 4DElqWeFxiOir6WFYxvky1tGPPOg2fL8HBwew1qXlVppV7P1RrOdTZYU6sZ5Nycrv+ jHnUawnI27RuE5e1VRVKCDL7qDBczsLM+lSDGKne2hs2O9pG6WqJrpowSlAcA39rN4 GH2aMEk2FMuHq8FviLWuca86o2+aqaVG09Lsr/7Dj/jQF/dDQ9bDqm/AHj5zvOocaM PA7qbOWsPoqZM+7suPLS99Mp+5e2bRTgX5LxSP7KndNGc41kWi5acOxJSB9OcnGGbu fKsl+1Z6GHElw== 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 V6 12/16] rv/monitor: Add the wip monitor skeleton created by dot2k Date: Tue, 19 Jul 2022 19:27:17 +0200 Message-Id: <485b0d220164b5d2d3567190ac02f23c94cba344.1658244826.git.bristot@kernel.org> 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.8 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 | 112 +++++++++++++++++++++++++++++ kernel/trace/rv/monitors/wip/wip.h | 46 ++++++++++++ 2 files changed, 158 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..7a06b841db0f --- /dev/null +++ b/kernel/trace/rv/monitors/wip/wip.c @@ -0,0 +1,112 @@ +// 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) +{ + if (rv_wip.enabled) + disable_wip(); + + 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