Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2922538iob; Fri, 6 May 2022 13:25:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuUpVbzibrfCGgK049eyTrCII5LBtfry78N2XCRCazY3Ax5OqB235zxDWIwXY+xWRcW0cw X-Received: by 2002:a17:907:8a0c:b0:6f4:7fc2:b0b0 with SMTP id sc12-20020a1709078a0c00b006f47fc2b0b0mr4591584ejc.251.1651868749625; Fri, 06 May 2022 13:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651868749; cv=none; d=google.com; s=arc-20160816; b=ZgOgi5T7Nf+OiviRZTPUqTP2IiGAHVq1iOArmaeiE9Yw5PheDaM+wfd3gbypHGqpxd MqdFgjkfQNnxtEpXIlSNRkGe2l/b/OhTEAteMSqlRsNjHEj0LbSjspp2mQQxGLSTZJe1 XmSnblG6wV5iliL8NAXIahBAYCs1ZHKLrwFIRzxiIOKMkJhYXOxazoEF4iNHVQfQameT Yxo6+ZEZ21MnBaFy3emMdrgyTwIDrjjAVJQo6kvtkWZZI08kZOi4RBt/FNd7lMXPqotV AR5slVcxh4gcL+URBtg+XpVWkn+lD1xRA8Smgl7RQZN+89HCJXxh9BXRFz36s+i6n6NP oioA== 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=aAKJce/swdmFbT2QCrauPo04Rkj4HdjDR52+nyl6kTg=; b=heQ/z5XZCseWZkZue7zMAaA7RLGV0BFgqfo3vdjK/CMv5ZFjrGO13H/DsCoWYT1nBi ZJP/mjxOWy304drNtMXFsfMC8TXpHQPvhpnUTPVAejzavAoTrVLDm744V8APJWf7Yf6I dXIYdavAKHCOufir2mq1mL4DR2kJb1khbCblCApAAPJHgw72Q3NI0DXbIc6ffKd7Zr1c gL9nleOvZOKzFBIZaKvknveKjo41tk/EuhZFEa1mSYWk7OH8j8SHoTUogmqF40RzwXyy KjfDwcD/pfVsoLlvban2KNmCmIWrT8UYZZyPeXmvUKJRZAolDgVcvy7aKfdQdzYBuxsR B/Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=duPvrQlg; 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 sb12-20020a1709076d8c00b006e48a4b0accsi1113201ejc.1003.2022.05.06.13.25.25; Fri, 06 May 2022 13:25:49 -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=duPvrQlg; 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 S1381762AbiEEQMU (ORCPT + 99 others); Thu, 5 May 2022 12:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381833AbiEEQMD (ORCPT ); Thu, 5 May 2022 12:12:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF0C15C862; Thu, 5 May 2022 09:08:11 -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 7B36961DCE; Thu, 5 May 2022 16:08:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B0F6C385A4; Thu, 5 May 2022 16:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651766890; bh=qPxDP6Z8HJ2cBErHMp8jTELkvnNv7AOxMZmc8BSrw2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=duPvrQlgzUbXBBWXbVSUIXEYkUxjHqOolyMu0gHgN2yrLqgqNOxscGfyD0stxlEVO ioavQ/PVCpaAKeluTZXsbwMmQE0/KNuSXvAM60CuPG7Iu9NkZGtxMvjsheL52tyBE+ Jc2mRqmqeOUlU1xNFjNtSqe92P2atqAJCRdI7O1XdY0o6rPs3Y3YhbfFgGf0v0RZdl LeJVLwhWWnsGnXjEmBhsv4hetJShsFNgfJicHrM2KDafw3xQ5KLIrz5NeIlACvcBmq rZlSR73xrtwbRP0MQirZ00Spaz2nqBEtaDV7y4aGJDyhkBNCMoHWPFPxoPDDp9eAeD 5Gl3xtp2/kP5g== From: Daniel Bristot de Oliveira To: Steven Rostedt , linux-kernel@vger.kernel.org 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-trace-devel@vger.kernel.org Subject: [RFC V3 12/20] rv/reactor: Add the printk reactor Date: Thu, 5 May 2022 18:06:52 +0200 Message-Id: <044f8f71ea66c5400ff61a7c60d02566658770c3.1651766361.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.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,T_SCC_BODY_TEXT_LINE 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 Sample reactor that printks the reaction message. 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 101d565cb53d..8c54ae473846 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 + bool "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..6a7bbf3fc03f --- /dev/null +++ b/kernel/trace/rv/reactor_printk.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Printk RV reactor: + * Prints the exception msg to the kernel message log. + * + * Copyright (C) 2019-2022 Daniel Bristot de Oliveira + * + */ +#include +#include +#include +#include +#include +#include + +static void rv_printk_reaction(char *msg) +{ + printk_deferred(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"); +MODULE_AUTHOR("Daniel Bristot de Oliveira"); +MODULE_DESCRIPTION("printk rv reactor: printk if an exception is hit"); -- 2.35.1