From mboxrd@z Thu Jan 1 00:00:00 1970 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 BCD35C433FE for ; Mon, 14 Feb 2022 11:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350875AbiBNLWj convert rfc822-to-8bit (ORCPT ); Mon, 14 Feb 2022 06:22:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350977AbiBNLVt (ORCPT ); Mon, 14 Feb 2022 06:21:49 -0500 X-Greylist: delayed 720 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 14 Feb 2022 02:58:01 PST Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7109327B1A for ; Mon, 14 Feb 2022 02:58:01 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-AzviTLmfNnyoGdmvJAGjjA-1; Mon, 14 Feb 2022 05:47:15 -0500 X-MC-Unique: AzviTLmfNnyoGdmvJAGjjA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFF7E814245; Mon, 14 Feb 2022 10:47:13 +0000 (UTC) Received: from x1.com (unknown [10.22.16.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976C026DFB; Mon, 14 Feb 2022 10:47:03 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , 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: [RFC V2 11/21] rv/monitor: wwnr instrumentation and Makefile/Kconfig entries Date: Mon, 14 Feb 2022 11:45:02 +0100 Message-Id: <54803ae2333e001dbe46ea9fa9f1d5064e6f0db6.1644830251.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bristot@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 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 and Kconfig entries. 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 --- kernel/trace/rv/Kconfig | 7 ++++++ kernel/trace/rv/Makefile | 1 + kernel/trace/rv/monitor_wwnr/wwnr.c | 35 +++++++++++++---------------- kernel/trace/rv/monitor_wwnr/wwnr.h | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index 7338e661d78f..f2d0bed05a55 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -20,6 +20,13 @@ 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 + tristate "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 20f30741b933..edad01bb2b5d 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) += monitor_wip/wip.o +obj-$(CONFIG_RV_MON_WWNR) += monitor_wwnr/wwnr.o diff --git a/kernel/trace/rv/monitor_wwnr/wwnr.c b/kernel/trace/rv/monitor_wwnr/wwnr.c index 91cb3b70a6a7..cb364a02639b 100644 --- a/kernel/trace/rv/monitor_wwnr/wwnr.c +++ b/kernel/trace/rv/monitor_wwnr/wwnr.c @@ -33,39 +33,34 @@ DECLARE_DA_MON_PER_TASK(wwnr, char); * */ -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) { - pid_t pid = /* XXX how do I get the pid? */; - da_handle_event_wwnr(pid, switch_in); -} + int ppid = p->pid; + int npid = n->pid; -void handle_switch_out(void *data, /* XXX: fill header */) -{ - pid_t pid = /* XXX how do I get the pid? */; - da_handle_event_wwnr(pid, switch_out); + if (ppid && ppid < MAX_PID) + da_handle_init_event_wwnr(ppid, switch_out); + + if (npid && npid < MAX_PID) + da_handle_event_wwnr(npid, switch_in); } -void handle_wakeup(void *data, /* XXX: fill header */) +static void handle_wakeup(void *data, struct task_struct *p) { - pid_t pid = /* XXX how do I get the pid? */; - da_handle_event_wwnr(pid, wakeup); + if (p->pid && p->pid < MAX_PID) + da_handle_event_wwnr(p->pid, wakeup); } -#define NR_TP 3 +#define NR_TP 2 static struct tracepoint_hook_helper tracepoints_to_hook[NR_TP] = { { - .probe = handle_switch_in, - .name = /* XXX: tracepoint name here */, - .registered = 0 - }, - { - .probe = handle_switch_out, - .name = /* XXX: tracepoint name here */, + .probe = handle_switch, + .name = "sched_switch", .registered = 0 }, { .probe = handle_wakeup, - .name = /* XXX: tracepoint name here */, + .name = "sched_wakeup", .registered = 0 }, }; diff --git a/kernel/trace/rv/monitor_wwnr/wwnr.h b/kernel/trace/rv/monitor_wwnr/wwnr.h index 4af1827d2f16..387f5a83ee7c 100644 --- a/kernel/trace/rv/monitor_wwnr/wwnr.h +++ b/kernel/trace/rv/monitor_wwnr/wwnr.h @@ -65,6 +65,6 @@ TRACE_EVENT(error_wwnr, /* This part ust be outside protection */ #undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_PATH ../kernel/trace/rv/monitor_wwnr/ #define TRACE_INCLUDE_FILE wwnr #include -- 2.33.1