Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5710499pxb; Mon, 14 Feb 2022 05:58:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7G5jjwXOUXVcLTE0WUQr+Kve/wU+QJAKDSCFeq+97U8DeENmZyujprMUTuG6dakEHmcUq X-Received: by 2002:a17:90b:1944:: with SMTP id nk4mr15089583pjb.32.1644847116013; Mon, 14 Feb 2022 05:58:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644847116; cv=none; d=google.com; s=arc-20160816; b=vWJ1vE8HxcI/lexVDk34adAZj7VzJ2bTO30npgXTa0kOHbTq8sdx5TYNVS1qaFo1le ckmCUxKynNlgTj2LVeUdQi8vd5CFlonyMk6Bhqnt/2JiFCGsWvVFZfX+4rlSPoHbZfuz g2CjGzUeqfJ/Py4FboAqOS2Ow5Vl2nXG8HcGarLndDC2ahmpTkqAqukjk6MXGi1Y27zh eBGYsZXkZtRCfeqpBTB4GRha17HH1OFLu8cDXTw9nKKr4atUNO0NhXQVRhxDBPyRrB1M C01FTUcXpR4nnyMOSOu0cXgldqL14jzo0szEx4YPnL8alBYPD4yJVf6kLat2Lew9Ho5h erpw== 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=KCZyGtRiDI7HGIRPc2RDpYSQSbmA9GNGEMDmKqult2c=; b=sjnPENVuuKp29jyLo5LFN5RisphW2iHReRbXqgn0u6fM5WUQp8JAjGQr9MlGQcOSxZ /TIP8dRu5F1NT9upC4IOO1YZr/4rcjvp7wipICVr98XpXwjsdMNQusQJagpxcfttMpX1 scgSL+wIrH2ahIlmKuicndIbSsLmv3YZEFZMtt/Zls1BzmwLQ7bsC3ZmXTGmAIpHjYSR yX4TB5YjhdUK86mB4OtODlPtz4ZvVNtM4StYk7bgcSMmnRkLvoXxs+Cz8kl7avLcgdYE DeInYfvkfauQltJ/0syCB6sq/oAAj2Q8Ngg8OKfv734H3idluUUDFC2JM12qi6LUQkM9 eRVQ== 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 t16si5899954plg.498.2022.02.14.05.58.20; Mon, 14 Feb 2022 05:58:35 -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 S236766AbiBNLQa convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Feb 2022 06:16:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350718AbiBNLPv (ORCPT ); Mon, 14 Feb 2022 06:15:51 -0500 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E172A1A4 for ; Mon, 14 Feb 2022 02:46:40 -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-223-Z48kIwZ6OBWnlfFdy6e65g-1; Mon, 14 Feb 2022 05:46:36 -0500 X-MC-Unique: Z48kIwZ6OBWnlfFdy6e65g-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 787313E741; Mon, 14 Feb 2022 10:46:34 +0000 (UTC) Received: from x1.com (unknown [10.22.16.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id C868C26DFB; Mon, 14 Feb 2022 10:46:19 +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 05/21] rv/include: Add tracing helper functions Date: Mon, 14 Feb 2022 11:44:56 +0100 Message-Id: <6b1c197c0b1dc9a27cfb71330ee2a0d670c93366.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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 Tracing helper functions to facilitate the instrumentation of auto-generated RV monitors create by dot2k. 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 --- include/rv/trace_helpers.h | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 include/rv/trace_helpers.h diff --git a/include/rv/trace_helpers.h b/include/rv/trace_helpers.h new file mode 100644 index 000000000000..440c681148a8 --- /dev/null +++ b/include/rv/trace_helpers.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Helper functions to facilitate the instrumentation of auto-generated + * RV monitors create by dot2k. + * + * The dot2k tool is available at tools/tracing/rv/dot2/ + * + * Copyright (C) 2019-2022 Daniel Bristot de Oliveira + */ + +#include + +struct tracepoint_hook_helper { + struct tracepoint *tp; + void *probe; + int registered; + char *name; +}; + +static inline void thh_compare_name(struct tracepoint *tp, void *priv) +{ + struct tracepoint_hook_helper *thh = priv; + + if (!strcmp(thh->name, tp->name)) + thh->tp = tp; +} + +static inline bool thh_fill_struct_tracepoint(struct tracepoint_hook_helper *thh) +{ + for_each_kernel_tracepoint(thh_compare_name, thh); + + return !!thh->tp; +} + +static inline void thh_unhook_probes(struct tracepoint_hook_helper *thh, int helpers_count) +{ + int i; + + for (i = 0; i < helpers_count; i++) { + if (!thh[i].registered) + continue; + + tracepoint_probe_unregister(thh[i].tp, thh[i].probe, NULL); + } +} + +static inline int thh_hook_probes(struct tracepoint_hook_helper *thh, int helpers_count) +{ + int retval; + int i; + + for (i = 0; i < helpers_count; i++) { + retval = thh_fill_struct_tracepoint(&thh[i]); + if (!retval) + goto out_err; + + retval = tracepoint_probe_register(thh[i].tp, thh[i].probe, NULL); + + if (retval) + goto out_err; + + thh[i].registered = 1; + } + return 0; + +out_err: + thh_unhook_probes(thh, helpers_count); + return -EINVAL; +} -- 2.33.1