Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5683847pxb; Mon, 14 Feb 2022 05:17:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJztmD0rFLYTh7xU42HzFsnDQVg2QP4S4GoMzz2QWYKkJMeH1t+tAfQMk0Uy1NsSlSqCQS2E X-Received: by 2002:a17:902:7ec2:: with SMTP id p2mr14131317plb.168.1644844626480; Mon, 14 Feb 2022 05:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644844626; cv=none; d=google.com; s=arc-20160816; b=FHNaVf1Y5Re/GZZkoeHSnCxXitoI5US9u+Zp/otqWbYK7IwPMAn17bjVq7kbouCZa7 EPIvvcz0QbMiQAwuFSqCBcyK5gEUTbub3fSWRgYHUFdzyZ+rCXXtFQGd0FdEjM3E47CU 5EzD6IuEgK1ZNDRlhSBJgtvVWzAtUMJ9+DIG57rIQuBSLhfPOTQLNh/AUJefgS67DL6u 6KvF+4mB5q3fNpXGWatHNqvULGnm9mJ21Bn8B6AYnkVtR+hIo+E4qLUeWgaPKQNwq6XO CdcmFfS34N9ERi8rxWCClDbLj6fdNZBdBmL9pLyz0rLZvE4tPQorz/m3lTR/0Zypi6au kybg== 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; bh=x4TP3GWzWH39X4XBqmmtoWVAMM8WFcdRwgdI4O8xKLY=; b=gQ1lPGhCTOSIXrW43/XYLmOzpNt5l1CrbnEr6fwmRE0ZyLzNZYYXs33CMT8OVTG7jc Gpe1doQBlmPbcc0zvi+q7YQwTSUzXrUytEaqU/siJsroY2Y702GsO4TQLZwgJoTmOv81 9Nux8qDK7LGBspsBMYgocoeE+jvdOTVlVrXtncZzrE58L0gf89G0AWpvz3HOt0eVDUzh fFwsjsK5FEBh+nZ4YUVhNYoosgU2FcZca2FeoUB/qzxwbaCxLZ6OHQJFtltU5ogZo3WP sD/jEczSC3l1O1a90jp+yvhBLuE2+J/uXYhnkCv/AyV2xv/2bk930IvdQOOCThrXQl4b 75zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 e125si4145086pgc.165.2022.02.14.05.16.51; Mon, 14 Feb 2022 05:17:06 -0800 (PST) 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; 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 S1350687AbiBNLYf convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Feb 2022 06:24:35 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350751AbiBNLXi (ORCPT ); Mon, 14 Feb 2022 06:23:38 -0500 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 C6AF36B0AC for ; Mon, 14 Feb 2022 02:59:02 -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-133-1ECy17Y0NLSO6ddK7ESVew-1; Mon, 14 Feb 2022 05:47:26 -0500 X-MC-Unique: 1ECy17Y0NLSO6ddK7ESVew-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 895DC2F26; Mon, 14 Feb 2022 10:47:24 +0000 (UTC) Received: from x1.com (unknown [10.22.16.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48DC626DFB; Mon, 14 Feb 2022 10:47:14 +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 12/21] rv/reactor: Add the printk reactor Date: Mon, 14 Feb 2022 11:45:03 +0100 Message-Id: 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no 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 Sample reactor that printks the reaction message. Note: do not use this reactor with rq_lock taken, it will lock the system until printk can handle that. 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 | 8 ++++++ kernel/trace/rv/Makefile | 3 ++- kernel/trace/rv/reactor_printk.c | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 kernel/trace/rv/reactor_printk.c diff --git a/kernel/trace/rv/Kconfig b/kernel/trace/rv/Kconfig index f2d0bed05a55..490f1417def9 100644 --- a/kernel/trace/rv/Kconfig +++ b/kernel/trace/rv/Kconfig @@ -37,4 +37,12 @@ config RV_REACTORS tracing reactions, printing the monitor output via tracepoints, but other reactions can be added (on-demand) via this interface. +config RV_REACT_PRINTK + tristate "Printk reactor" + depends on RV_REACTORS + default y if RV_REACTORS + help + Enables the printk reactor. The printk reactor emmits a printk() + message if an exception is found. + endif # RV diff --git a/kernel/trace/rv/Makefile b/kernel/trace/rv/Makefile index edad01bb2b5d..d86ceb103ef2 100644 --- a/kernel/trace/rv/Makefile +++ b/kernel/trace/rv/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 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 +obj-$(CONFIG_RV_REACTORS) += rv_reactors.o +obj-$(CONFIG_RV_REACT_PRINTK) += reactor_printk.o diff --git a/kernel/trace/rv/reactor_printk.c b/kernel/trace/rv/reactor_printk.c new file mode 100644 index 000000000000..9f9c9bb2d304 --- /dev/null +++ b/kernel/trace/rv/reactor_printk.c @@ -0,0 +1,43 @@ +/* + * Printk RV reactor: + * Prints the exception msg to the kernel message log. + * + * Copyright (C) 2019-2022 Daniel Bristot de Oliveira + * + * SPDX-License-Identifier: GPL-2.0 + */ +#include +#include +#include +#include +#include +#include + +static void rv_printk_reaction(char *msg) +{ + printk(msg); +} + +struct rv_reactor rv_printk = { + .name = "printk", + .description = "prints the exception msg to the kernel message log", + .react = rv_printk_reaction +}; + +int register_react_printk(void) +{ + rv_register_reactor(&rv_printk); + return 0; +} + +void unregister_react_printk(void) +{ + rv_unregister_reactor(&rv_printk); +} + +module_init(register_react_printk); +module_exit(unregister_react_printk); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Daniel Bristot de Oliveira"); +MODULE_DESCRIPTION("printk rv reactor: printk if an exception is hit"); -- 2.33.1