Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1114719pxb; Wed, 27 Oct 2021 19:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmMTJ0plOwfxZI2YEMdfMf6L1ENS6vdxSfFs/YePBDxA9d3G6yA4cgpfxFlfLWOKP/jJ++ X-Received: by 2002:a17:906:912:: with SMTP id i18mr1835132ejd.131.1635389715228; Wed, 27 Oct 2021 19:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635389715; cv=none; d=google.com; s=arc-20160816; b=twR1tOfgT21exPDEMIOvvFmHWG891GtLZ5T6YGqbWhSrZlJnX2W9KR++C8xdDSQsGZ ItOIUZAL9/uUUru9WaS7jp3OFyGC0JFt0m+hAMtK1zrW7OgyIQU53sklIuS03aPJtrEf D6EBV0XnejMgL4ZKcouMSEY2QPbb6DkM+ne0VOAIWRr+YKrNYXrfzXz98n/8kTzq4mtV mFomtuzxB8Tv2lxNqDNSRuaRPphVC0gwDuHeliVGtzjHjdhnWCC7Hw+ndGzgZ/JjVWur f6a3THIl405zfHqcmbYSrYS9ouAVJKV0RifAcL/Snz1CsBz9TzIc6tr1wEcSxQ8HPPZE PsJQ== 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:subject:cc:to:from:date; bh=+2SaSPPW/jsJEc4CRuoNLoal/wACIP2XW1tZ513QT3g=; b=qDpNZdEzQxqB7SwaBmItGge3zsg1+QNXPquL4ta2j1zHdRR5euS62RhgWosjQ3QAkn 8YBB3UHm7uYSuDeoE9mvOX6hBKXy6kR3oVsSwgtibMLtsJl2Y4v7KGb6uz2AShgzpKiG TSKr4F+DWNiuPXs1M8fRpug5ejispGBavFJ1k/TDbI0M3eGZcgPWiN8V9/UOtoFKVrHE Xrr4Js1Wh4P8zrAuna77977BM52E57LUC0+3CKRdTFTUMUp+Pl3AYetjuHbs5q97qaB1 dL5e353/OFgYPvz+C15mv+LNF0LP2k7d7g/Ep0BJsLMcGnGo10TYUX7MujPakgVp07gx Gb7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du17si2964494ejc.123.2021.10.27.19.54.51; Wed, 27 Oct 2021 19:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbhJ1CxW convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Oct 2021 22:53:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbhJ1CxV (ORCPT ); Wed, 27 Oct 2021 22:53:21 -0400 Received: from rorschach.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F33B61100; Thu, 28 Oct 2021 02:50:53 +0000 (UTC) Date: Wed, 27 Oct 2021 22:50:51 -0400 From: Steven Rostedt To: Daniel Bristot de Oliveira Cc: Tao Zhou , Ingo Molnar , Tom Zanussi , Masami Hiramatsu , Juri Lelli , Clark Williams , John Kacur , Peter Zijlstra , Thomas Gleixner , Sebastian Andrzej Siewior , linux-rt-users@vger.kernel.org, linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V6 06/20] trace/osnoise: Allow multiple instances of the same tracer Message-ID: <20211027225051.20ffef90@rorschach.local.home> In-Reply-To: <69cbbd98cce2515c84127c8827d733dc87b04823.1635284863.git.bristot@kernel.org> References: <69cbbd98cce2515c84127c8827d733dc87b04823.1635284863.git.bristot@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Oct 2021 00:06:17 +0200 Daniel Bristot de Oliveira wrote: > static int osnoise_tracer_init(struct trace_array *tr) > { > - > - /* Only allow one instance to enable this */ > - if (osnoise_has_registered_instances()) > + /* > + * Only allow osnoise tracer if timerlat tracer is not running > + * already. > + */ > + if (osnoise_data.timerlat_tracer) > return -EBUSY; > This fails to build when timerlat is not enabled: /work/git/linux-trace.git/kernel/trace/trace_osnoise.c: In function ‘osnoise_tracer_init’: /work/git/linux-trace.git/kernel/trace/trace_osnoise.c:2161:18: error: ‘struct osnoise_data’ has no member named ‘timerlat_tracer’ 2161 | if (osnoise_data.timerlat_tracer) | ^ make[3]: *** [/work/git/linux-trace.git/scripts/Makefile.build:277: kernel/trace/trace_osnoise.o] Error 1 Also, I hate all the #ifdef muckery in this file. What you need is: static struct osnoise_data { u64 sample_period; /* total sampling period */ u64 sample_runtime; /* active sampling portion of period */ u64 stop_tracing; /* stop trace in the internal operation (loop/irq) */ u64 stop_tracing_total; /* stop trace in the final operation (report/thread) */ #ifdef CONFIG_TIMERLAT_TRACER u64 timerlat_period; /* timerlat period */ u64 print_stack; /* print IRQ stack if total > */ int timerlat_tracer; /* timerlat tracer */ #endif bool tainted; /* infor users and developers about a problem */ } osnoise_data = { .sample_period = DEFAULT_SAMPLE_PERIOD, .sample_runtime = DEFAULT_SAMPLE_RUNTIME, .stop_tracing = 0, .stop_tracing_total = 0, #ifdef CONFIG_TIMERLAT_TRACER .print_stack = 0, .timerlat_period = DEFAULT_TIMERLAT_PERIOD, .timerlat_tracer = 0, #endif }; #ifdef CONFIG_TIMERLAT_TRACER static bool timerlat_enbabled() { return osnoise_data.timerlat_tracer; } static void timerlat_softirq_exit(void) { struct timerlat_variables *tlat_var; tlat_var = this_cpu_tmr_var(); if (!tlat_var->tracing_thread) { osn_var->softirq.arrival_time = 0; osn_var->softirq.delta_start = 0; } } #else static inline bool timerlat_enbabled() { return false; } static void timerlat_softirq_exit(void) { } #endif Then in places like trace_softirq_exit_callback() you can have: if (unlikely(timerlat_enabled()) timerlat_softirq_exit(); And this will help in making mistakes like you did with the compile failure. So there should be no #ifdef in any functions (it's fine to wrap functions). -- Steve