From patchwork Thu Jun 16 08:44:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bristot de Oliveira X-Patchwork-Id: 12883560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA64CCA47D for ; Thu, 16 Jun 2022 08:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376276AbiFPIqy (ORCPT ); Thu, 16 Jun 2022 04:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359719AbiFPIqM (ORCPT ); Thu, 16 Jun 2022 04:46:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6900E5DBE3; Thu, 16 Jun 2022 01:46:09 -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 142C6B822A7; Thu, 16 Jun 2022 08:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72F85C36AE3; Thu, 16 Jun 2022 08:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655369166; bh=q2Nr0Do4T+VNYLHE7CNjZGMYVNS+vUVZnmunR/+50Bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJVathLlY3OD6ZpvCxIhusEa0wKl7DfZl2hmahA85dBfvkwSZMRr848G5H3M/D3I4 WYLpEnGcX9vbipHbR6zdmVE7tckIrY1MqK8Zb2BMfZ29RDwK8C4izI5Dn7Q0LXFzih etj5tlof1DhAz74Jcw43VJwu19gSSc6ph8UbQPwyBVZSTJQKpg5bJqmhnSy+pt98GK y/zyUYcbgEIt/FyWVIUgpDzJJfoVwBio2itHw2AimTVWGGawPr6rGnbGgDeW9fythz WeIKDZC1Lq/iLIRisM2vovWbP1v8fNBRc7IgE11nlBUjHU6utqR+AWXoX9Ryc1uxUH vLduASJbhVUuA== 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 , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH V4 11/20] rv/monitor: wwnr instrumentation and Makefile/Kconfig entries Date: Thu, 16 Jun 2022 10:44:53 +0200 Message-Id: <944694879f67c0e635815ac57154be477a1b9108.1655368610.git.bristot@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Adds the instrumentation to the previously created wwnr monitor, as an example of the developer work. It also adds a Makefile, Kconfig and tracepoint entries. 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: 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 Reported-by: kernel test robot --- include/trace/events/rv.h | 12 +++++++++ kernel/trace/rv/Kconfig | 8 ++++++ kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitors/wwnr/wwnr.c | 38 ++++++++++++---------------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/include/trace/events/rv.h b/include/trace/events/rv.h index 4e0dabffcf29..00f11a8dac3b 100644 --- a/include/trace/events/rv.h +++ b/include/trace/events/rv.h @@ -122,6 +122,18 @@ DECLARE_EVENT_CLASS(error_da_monitor_id, __entry->event, __entry->state) ); + +#ifdef CONFIG_RV_MON_WWNR +/* id is the pid of the task */ +DEFINE_EVENT(event_da_monitor_id, event_wwnr, + TP_PROTO(int id, char *state, char *event, char *next_state, bool safe), + TP_ARGS(id, state, event, next_state, safe)); + +DEFINE_EVENT(error_da_monitor_id, error_wwnr, + TP_PROTO(int id, char *state, char *event), + TP_ARGS(id, state, event)); +#endif /* CONFIG_RV_MON_WWNR */ + #endif /* CONFIG_DA_MON_EVENTS_ID */ #endif /* _TRACE_RV_H */ diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index e9246b0bec9d..fba2ace2a22b 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -34,6 +34,14 @@ config RV_MON_WIP Enable WIP sample monitor, this is a sample monitor that illustrates the usage of per-cpu monitors. +config RV_MON_WWNR + select DA_MON_EVENTS_ID + bool "WWNR monitor" + help + Enable WWNR sample monitor, this is a sample monitor that + illustrates the usage of per-task monitor. The model is + broken on purpose: it serves to test reactors. + config RV_REACTORS bool "Runtime verification reactors" default y if RV diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index b41109d2750a..af0ff9a46418 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_RV) += rv.o obj-$(CONFIG_RV_REACTORS) += rv_reactors.o obj-$(CONFIG_RV_MON_WIP) += monitors/wip/wip.o +obj-$(CONFIG_RV_MON_WWNR) += monitors/wwnr/wwnr.o diff --git a/kernel/trace/rv/monitors/wwnr/wwnr.c b/kernel/trace/rv/monitors/wwnr/wwnr.c index 8ba01f0f0df8..3fe1ad9125d3 100644 --- a/kernel/trace/rv/monitors/wwnr/wwnr.c +++ b/kernel/trace/rv/monitors/wwnr/wwnr.c @@ -10,11 +10,8 @@ #define MODULE_NAME "wwnr" -/* - * XXX: include required tracepoint headers, e.g., - * #include - */ #include +#include /* * This is the self-generated part of the monitor. Generally, there is no need @@ -37,21 +34,20 @@ DECLARE_DA_MON_PER_TASK(wwnr, char); * are translated into model's event. * */ -static void handle_switch_in(void *data, /* XXX: fill header */) +static void handle_switch(void *data, bool preempt, struct task_struct *p, + struct task_struct *n, unsigned int prev_state) { - struct task_struct *p = /* XXX: how do I get p? */; - da_handle_event_wwnr(p, switch_in_wwnr); -} + /* start monitoring only after the first suspension */ + if (prev_state == TASK_INTERRUPTIBLE) + da_handle_init_event_wwnr(p, switch_out_wwnr); + else + da_handle_event_wwnr(p, switch_out_wwnr); -static void handle_switch_out(void *data, /* XXX: fill header */) -{ - struct task_struct *p = /* XXX: how do I get p? */; - da_handle_event_wwnr(p, switch_out_wwnr); + da_handle_event_wwnr(n, switch_in_wwnr); } -static void handle_wakeup(void *data, /* XXX: fill header */) +static void handle_wakeup(void *data, struct task_struct *p) { - struct task_struct *p = /* XXX: how do I get p? */; da_handle_event_wwnr(p, wakeup_wwnr); } @@ -63,9 +59,8 @@ static int start_wwnr(void) if (retval) return retval; - rv_attach_trace_probe("wwnr", /* XXX: tracepoint */, handle_switch_in); - rv_attach_trace_probe("wwnr", /* XXX: tracepoint */, handle_switch_out); - rv_attach_trace_probe("wwnr", /* XXX: tracepoint */, handle_wakeup); + rv_attach_trace_probe("wwnr", sched_switch, handle_switch); + rv_attach_trace_probe("wwnr", sched_wakeup, handle_wakeup); return 0; } @@ -74,9 +69,8 @@ static void stop_wwnr(void) { rv_wwnr.enabled = 0; - rv_detach_trace_probe("wwnr", /* XXX: tracepoint */, handle_switch_in); - rv_detach_trace_probe("wwnr", /* XXX: tracepoint */, handle_switch_out); - rv_detach_trace_probe("wwnr", /* XXX: tracepoint */, handle_wakeup); + rv_detach_trace_probe("wwnr", sched_switch, handle_switch); + rv_detach_trace_probe("wwnr", sched_wakeup, handle_wakeup); da_monitor_destroy_wwnr(); } @@ -111,5 +105,5 @@ module_init(register_wwnr); module_exit(unregister_wwnr); MODULE_LICENSE("GPL"); -MODULE_AUTHOR("dot2k: auto-generated"); -MODULE_DESCRIPTION("wwnr"); +MODULE_AUTHOR("Daniel Bristot de Oliveira "); +MODULE_DESCRIPTION("wwnr: wakeup while not running monitor.");