Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp243481pxm; Wed, 2 Mar 2022 14:25:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyj5E5H3odcnXm13WVR74AJLzn9sH4XE+Vdsf4hsV9N79Jh+sF0KKAdCIMzNXoQ3tV5eai6 X-Received: by 2002:a62:7554:0:b0:4e1:5898:4fbb with SMTP id q81-20020a627554000000b004e158984fbbmr34906768pfc.2.1646259941586; Wed, 02 Mar 2022 14:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646259941; cv=none; d=google.com; s=arc-20160816; b=y6Dtu0n3Rb0SfYZo5tE/hwRbplId4997xoWCq6V1o4RbgROPu8u5w18+ddgofg1KqX LotRxoM0CoAeRZ/FHuEGJgYqr4yThM/1QVB7ebXwOhcc0QkCxHZ/C1ZispGpGVi0nvET +BAT4XLCvZhQsMiS726kiXIYlG8ujruP4VUpOTh1C29bIV/pAV33lmqaoKuWFj6rV6lH A5gv5AznHTtzsAH9IkQZYK1l2QC1DLWsmnAqmD3RSilRKZkcv0XPi1OsQX2M6r5OYHjK ceFT8c38UoKvEaInUAdOMU4k1iaQjlxgeZFxJ2C2Mlj3yuNd/B1IdgxxG/rtAE+UfOeM awmg== 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=LwP1CjM8oYYR1YonXppao9gqwLD0K32olEHTF2tYGb0=; b=w8GWJZU8fzH+Mx4jTCNI1iRHnlLHl34N6yp8+l2Q/Y2Rzd6o0b9JEIOLA3JewIlsaB XnIE6MG1yCZJml7WrCzsq3IiaNFPN2ajb0bJQ0GRXMr5O+wFeCAOREHNna4EJCa92XpG +/qCvTkDRZ22m41hnnlz28qKodTEpLqgnPPbclFidLiXsxvV6kJFEnGaivs08KNSb4wG WPTfDCI5jWU/ujUeRdQfGK/1UfJVj9jAJEZC67AvmKJkGUrYMYwBlHYy/56Tt4/y36dD ur1sPuUqMM2ggMUmPs5CEA7eNXhMtd2TAM2/Sb5fvMznLCH+m9FewApv+paRjbWxeRjD xofw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 14-20020a63114e000000b003713a2e32d1si275599pgr.285.2022.03.02.14.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:25:41 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6E413E4D18; Wed, 2 Mar 2022 14:24:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244887AbiCBTFC convert rfc822-to-8bit (ORCPT + 99 others); Wed, 2 Mar 2022 14:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244883AbiCBTE7 (ORCPT ); Wed, 2 Mar 2022 14:04:59 -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 AF92F44774 for ; Wed, 2 Mar 2022 11:04:09 -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-654-6mHa1rCaPEmsm4-0OR0J3g-1; Wed, 02 Mar 2022 14:04:00 -0500 X-MC-Unique: 6mHa1rCaPEmsm4-0OR0J3g-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 AA3A5501E8; Wed, 2 Mar 2022 19:03:58 +0000 (UTC) Received: from x1.com (unknown [10.22.32.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC66A19C59; Wed, 2 Mar 2022 19:03:55 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Jonathan Corbet , Clark Williams , Juri Lelli , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH V3 12/15] rtla: Check for trace off also in the trace instance Date: Wed, 2 Mar 2022 20:01:37 +0100 Message-Id: <59fc7c6f23dddd5c8b7ef1782cf3da51ea2ce0f5.1646247211.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=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 With the addition of --trigger option, it is also possible to stop the trace from the -t tracing instance using the traceoff trigger. Make rtla tools to check if the trace is stopped also in the trace instance, stopping the execution of the tool. Cc: Daniel Bristot de Oliveira Cc: Steven Rostedt Cc: Jonathan Corbet Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/osnoise_hist.c | 4 ++-- tools/tracing/rtla/src/osnoise_top.c | 4 ++-- tools/tracing/rtla/src/timerlat_hist.c | 4 ++-- tools/tracing/rtla/src/timerlat_top.c | 4 ++-- tools/tracing/rtla/src/trace.c | 19 +++++++++++++++++++ tools/tracing/rtla/src/trace.h | 1 + 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c index f86b5fb94efd..b73b919bd6b4 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -848,7 +848,7 @@ int osnoise_hist_main(int argc, char *argv[]) goto out_hist; } - if (!tracefs_trace_is_on(trace->inst)) + if (trace_is_off(&tool->trace, &record->trace)) break; }; @@ -858,7 +858,7 @@ int osnoise_hist_main(int argc, char *argv[]) return_value = 0; - if (!tracefs_trace_is_on(trace->inst)) { + if (trace_is_off(&tool->trace, &record->trace)) { printf("rtla timelat hit stop tracing\n"); if (params->trace_output) { printf(" Saving trace to %s\n", params->trace_output); diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c index c3d75ee456a5..fd29a4049322 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -629,7 +629,7 @@ int osnoise_top_main(int argc, char **argv) if (!params->quiet) osnoise_print_stats(params, tool); - if (!tracefs_trace_is_on(trace->inst)) + if (trace_is_off(&tool->trace, &record->trace)) break; } while (!stop_tracing); @@ -638,7 +638,7 @@ int osnoise_top_main(int argc, char **argv) return_value = 0; - if (!tracefs_trace_is_on(trace->inst)) { + if (trace_is_off(&tool->trace, &record->trace)) { printf("osnoise hit stop tracing\n"); if (params->trace_output) { printf(" Saving trace to %s\n", params->trace_output); diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 8341f38fd0b1..17188ccb6e8b 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -861,7 +861,7 @@ int timerlat_hist_main(int argc, char *argv[]) goto out_hist; } - if (!tracefs_trace_is_on(trace->inst)) + if (trace_is_off(&tool->trace, &record->trace)) break; }; @@ -869,7 +869,7 @@ int timerlat_hist_main(int argc, char *argv[]) return_value = 0; - if (!tracefs_trace_is_on(trace->inst)) { + if (trace_is_off(&tool->trace, &record->trace)) { printf("rtla timelat hit stop tracing\n"); if (params->trace_output) { printf(" Saving trace to %s\n", params->trace_output); diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index 9ce5a09664bc..bf2a50350e61 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -655,7 +655,7 @@ int timerlat_top_main(int argc, char *argv[]) if (!params->quiet) timerlat_print_stats(params, top); - if (!tracefs_trace_is_on(trace->inst)) + if (trace_is_off(&top->trace, &record->trace)) break; }; @@ -664,7 +664,7 @@ int timerlat_top_main(int argc, char *argv[]) return_value = 0; - if (!tracefs_trace_is_on(trace->inst)) { + if (trace_is_off(&top->trace, &record->trace)) { printf("rtla timelat hit stop tracing\n"); if (params->trace_output) { printf(" Saving trace to %s\n", params->trace_output); diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index 8249ec4d77cc..5784c9f9e570 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -516,3 +516,22 @@ void trace_events_destroy(struct trace_instance *instance, trace_events_disable(instance, events); trace_events_free(events); } + +int trace_is_off(struct trace_instance *tool, struct trace_instance *trace) +{ + /* + * The tool instance is always present, it is the one used to collect + * data. + */ + if (!tracefs_trace_is_on(tool->inst)) + return 1; + + /* + * The trace instance is only enabled when -t is set. IOW, when the system + * is tracing. + */ + if (trace && !tracefs_trace_is_on(trace->inst)) + return 1; + + return 0; +} diff --git a/tools/tracing/rtla/src/trace.h b/tools/tracing/rtla/src/trace.h index 51ad344c600b..2e9a89a25615 100644 --- a/tools/tracing/rtla/src/trace.h +++ b/tools/tracing/rtla/src/trace.h @@ -47,3 +47,4 @@ int trace_events_enable(struct trace_instance *instance, int trace_event_add_filter(struct trace_events *event, char *filter); int trace_event_add_trigger(struct trace_events *event, char *trigger); +int trace_is_off(struct trace_instance *tool, struct trace_instance *trace); -- 2.34.1