Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4423418pxb; Mon, 21 Feb 2022 21:09:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTDhjrHmK7Q/d21NzBOYqVSD2gRYfOYmojcp8hnj7zSAS83396hYpkFiX4MNuqG0g2e9Cs X-Received: by 2002:a17:90b:3850:b0:1bc:5a7d:4a4b with SMTP id nl16-20020a17090b385000b001bc5a7d4a4bmr2368395pjb.26.1645506544837; Mon, 21 Feb 2022 21:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506544; cv=none; d=google.com; s=arc-20160816; b=oTkndCr8tPusYL4mTzCjwgXTuAY0++FpKqMUsbfoDkc9BUbRaNDH8nJeYfpY+llANu 9rmBdxNYEKMV/VE39ETtqgBBWmhy2oGJQ4LyATDCBbG4g3hpZGAAav2MrVkFanFSgwc3 cl0Wx4HeJeGC7ysbs4S9FiUBjLmgzydL7AHWQcJYhdWCsdpoKrnXbnd2Sd9HSUqvSe76 svk+tc9WlfOIoktat/QEZY2KFVcReRZtcIU9Ky0jVbkUigemcA5OtDTF6TuWijR8UaTL Y8q9+/nscYhp0HNm+vXK2tba6R9IYHZoQKKKF63bNFTec8ADm/cRuhlsVZpmeJycqg9q Dk+Q== 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=/+pZOD8OMMjWbSlmbEuEIq2yYI+hD8ys4xUBycj+GZs=; b=sJzkE2OmxTAe3gblPylrZFQW0rNrWezacl+OfNAmzS2pB+gneHbl6lvN688Kh885JG 0lA9GFzNS2VHwHiJxAQgFuAf0udAhia2nCtNTq9pwsRYqU3tFKUJ6JDtTbUGGaj4msLf oxPGZ+hVGu2WP9IW68voUPdXoOOt3xd+ULaZ9tM0JY9HifUns9qUOouypvc5p+F8Gh+r ljZUTJB+WI8PeCyK839K3g7VoT0f6fJp9YXRI6BrzaLB9U4nJCsdOuQINwQaSakBWiBy RSHleLnf/tEZ02YvRKN0yw1h1fCvLYqLP0ztOrIMqFA8NIRNSeInCyvXGIWAer6MqteY wzGQ== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q64-20020a17090a754600b001bc3872e96fsi1130848pjk.43.2022.02.21.21.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 E2EB0DF52; Mon, 21 Feb 2022 20:42:05 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235448AbiBUWSK convert rfc822-to-8bit (ORCPT + 99 others); Mon, 21 Feb 2022 17:18:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:39932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235535AbiBUWSG (ORCPT ); Mon, 21 Feb 2022 17:18:06 -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 D341522BE8 for ; Mon, 21 Feb 2022 14:17:41 -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-483-rt7nUSh1P8y_Q6hojWC9WQ-1; Mon, 21 Feb 2022 17:17:35 -0500 X-MC-Unique: rt7nUSh1P8y_Q6hojWC9WQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 541271091DA2; Mon, 21 Feb 2022 22:17:34 +0000 (UTC) Received: from x1.com (unknown [10.22.16.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 657BE5DB8F; Mon, 21 Feb 2022 22:17:31 +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 V2 08/11] rtla: Add --trigger support Date: Mon, 21 Feb 2022 23:16:53 +0100 Message-Id: <78c84d7fff6cbf8b7a97938b5cc0fc7fb452d57d.1645481500.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 Add --trigger option. This option enables a trace event trigger to the previous -e sys:event argument, allowing some advanced tracing options. For instance, in a system with CPUs 2:23 isolated, it is possible to get a stack trace of thread wakeup targeting those CPUs while running osnoise with the following command line: # osnoise top -c 2-23 -a 50 -e sched:sched_wakeup --trigger="stacktrace if target_cpu >= 2" This option is available for all current tools. Cc: Daniel Bristot de Oliveira Cc: Steven Rostedt Cc: Jonathan Corbet Signed-off-by: Daniel Bristot de Oliveira --- Documentation/tools/rtla/common_options.rst | 3 +++ tools/tracing/rtla/src/osnoise_hist.c | 19 ++++++++++++++++--- tools/tracing/rtla/src/osnoise_top.c | 17 +++++++++++++++-- tools/tracing/rtla/src/timerlat_hist.c | 19 ++++++++++++++++--- tools/tracing/rtla/src/timerlat_top.c | 17 +++++++++++++++-- 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/Documentation/tools/rtla/common_options.rst b/Documentation/tools/rtla/common_options.rst index 89d783dc3304..e5870b944334 100644 --- a/Documentation/tools/rtla/common_options.rst +++ b/Documentation/tools/rtla/common_options.rst @@ -18,6 +18,9 @@ Enable an event in the trace (**-t**) session. The argument can be a specific event, e.g., **-e** *sched:sched_switch*, or all events of a system group, e.g., **-e** *sched*. Multiple **-e** are allowed. It is only active when **-t** or **-a** are set. +**--trigger** ** + Enable a trace event trigger to the previous **-e** *sys:event*. For further information about event trigger see https://www.kernel.org/doc/html/latest/trace/events.html#event-triggers. + **-P**, **--priority** *o:prio|r:prio|f:prio|d:runtime:period* Set scheduling parameters to the osnoise tracer threads, the format to set the priority are: diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c index 10d683a98087..3e8f89b4f306 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -428,8 +428,8 @@ static void osnoise_hist_usage(char *usage) static const char * const msg[] = { "", " usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\", - " [-T us] [-t[=file]] [-e sys[:event]] [-c cpu-list] [-P priority] [-b N] [-E N] \\", - " [--no-header] [--no-summary] [--no-index] [--with-zeros]", + " [-T us] [-t[=file]] [-e sys[:event]] [--trigger ] [-c cpu-list] [-P priority] \\", + " [-b N] [-E N] [--no-header] [--no-summary] [--no-index] [--with-zeros]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit", @@ -443,6 +443,7 @@ static void osnoise_hist_usage(char *usage) " -D/--debug: print debug info", " -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]", " -e/--event : enable the in the trace instance, multiple -e are allowed", + " --trigger : enable a trace event trigger to the previous -e event", " -b/--bucket-size N: set the histogram bucket size (default 1)", " -E/--entries N: set the number of entries of the histogram (default 256)", " --no-header: do not print header", @@ -510,13 +511,14 @@ static struct osnoise_hist_params {"no-summary", no_argument, 0, '1'}, {"no-index", no_argument, 0, '2'}, {"with-zeros", no_argument, 0, '3'}, + {"trigger", required_argument, 0, '4'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhp:P:r:s:S:t::T:0123", + c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhp:P:r:s:S:t::T:01234:", long_options, &option_index); /* detect the end of the options. */ @@ -619,6 +621,17 @@ static struct osnoise_hist_params case '3': /* with zeros */ params->with_zeros = 1; break; + case '4': /* trigger */ + if (params->events) { + retval = trace_event_add_trigger(params->events, optarg); + if (retval) { + err_msg("Error adding trigger %s\n", optarg); + exit(EXIT_FAILURE); + } + } else { + osnoise_hist_usage("--trigger requires a previous -e\n"); + } + break; default: osnoise_hist_usage("Invalid option"); } diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c index 218dc1114139..d16c7ce3e9fa 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -247,7 +247,7 @@ void osnoise_top_usage(char *usage) static const char * const msg[] = { " usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\", - " [-T us] [-t[=file]] [-e sys[:event]] [-c cpu-list] [-P priority]", + " [-T us] [-t[=file]] [-e sys[:event]] [--trigger ] [-c cpu-list] [-P priority]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit", @@ -261,6 +261,7 @@ void osnoise_top_usage(char *usage) " -D/--debug: print debug info", " -t/--trace[=file]: save the stopped trace to [file|osnoise_trace.txt]", " -e/--event : enable the in the trace instance, multiple -e are allowed", + " --trigger : enable a trace event trigger to the previous -e event", " -q/--quiet print only a summary at the end", " -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters", " o:prio - use SCHED_OTHER with prio", @@ -312,13 +313,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv) {"stop-total", required_argument, 0, 'S'}, {"threshold", required_argument, 0, 'T'}, {"trace", optional_argument, 0, 't'}, + {"trigger", required_argument, 0, '0'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:d:De:hp:P:qr:s:S:t::T:", + c = getopt_long(argc, argv, "a:c:d:De:hp:P:qr:s:S:t::T:0:", long_options, &option_index); /* Detect the end of the options. */ @@ -402,6 +404,17 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv) case 'T': params->threshold = get_llong_from_str(optarg); break; + case '0': /* trigger */ + if (params->events) { + retval = trace_event_add_trigger(params->events, optarg); + if (retval) { + err_msg("Error adding trigger %s\n", optarg); + exit(EXIT_FAILURE); + } + } else { + osnoise_top_usage("--trigger requires a previous -e\n"); + } + break; default: osnoise_top_usage("Invalid option"); } diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 2bd668fd36f5..765b5a313bd2 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -430,8 +430,8 @@ static void timerlat_hist_usage(char *usage) char *msg[] = { "", " usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\", - " [-t[=file]] [-e sys[:event]] [-c cpu-list] [-P priority] [-E N] [-b N] [--no-irq] \\", - " [--no-thread] [--no-header] [--no-summary] [--no-index] [--with-zeros]", + " [-t[=file]] [-e sys[:event]] [--trigger ] [-c cpu-list] [-P priority] [-E N] \\", + " [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] [--no-index] [--with-zeros]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit", @@ -444,6 +444,7 @@ static void timerlat_hist_usage(char *usage) " -D/--debug: print debug info", " -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]", " -e/--event : enable the in the trace instance, multiple -e are allowed", + " --trigger : enable a trace event trigger to the previous -e event", " -n/--nano: display data in nanoseconds", " -b/--bucket-size N: set the histogram bucket size (default 1)", " -E/--entries N: set the number of entries of the histogram (default 256)", @@ -517,13 +518,14 @@ static struct timerlat_hist_params {"no-summary", no_argument, 0, '3'}, {"no-index", no_argument, 0, '4'}, {"with-zeros", no_argument, 0, '5'}, + {"trigger", required_argument, 0, '6'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhi:np:P:s:t::T:012345", + c = getopt_long(argc, argv, "a:c:b:d:e:E:Dhi:np:P:s:t::T:0123456:", long_options, &option_index); /* detect the end of the options. */ @@ -632,6 +634,17 @@ static struct timerlat_hist_params case '5': /* with zeros */ params->with_zeros = 1; break; + case '6': /* trigger */ + if (params->events) { + retval = trace_event_add_trigger(params->events, optarg); + if (retval) { + err_msg("Error adding trigger %s\n", optarg); + exit(EXIT_FAILURE); + } + } else { + timerlat_hist_usage("--trigger requires a previous -e\n"); + } + break; default: timerlat_hist_usage("Invalid option"); } diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index 13bd922ab147..76927d4e0dac 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -268,7 +268,7 @@ static void timerlat_top_usage(char *usage) static const char *const msg[] = { "", " usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\", - " [[-t[=file]] [-e sys[:event]] [-c cpu-list] [-P priority]", + " [[-t[=file]] [-e sys[:event]] [--trigger ] [-c cpu-list] [-P priority]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit", @@ -281,6 +281,7 @@ static void timerlat_top_usage(char *usage) " -D/--debug: print debug info", " -t/--trace[=file]: save the stopped trace to [file|timerlat_trace.txt]", " -e/--event : enable the in the trace instance, multiple -e are allowed", + " --trigger : enable a trace event trigger to the previous -e event", " -n/--nano: display data in nanoseconds", " -q/--quiet print only a summary at the end", " -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters", @@ -338,13 +339,14 @@ static struct timerlat_top_params {"stack", required_argument, 0, 's'}, {"thread", required_argument, 0, 'T'}, {"trace", optional_argument, 0, 't'}, + {"trigger", required_argument, 0, '0'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:", + c = getopt_long(argc, argv, "a:c:d:De:hi:np:P:qs:t::T:0:", long_options, &option_index); /* detect the end of the options. */ @@ -427,6 +429,17 @@ static struct timerlat_top_params else params->trace_output = "timerlat_trace.txt"; break; + case '0': /* trigger */ + if (params->events) { + retval = trace_event_add_trigger(params->events, optarg); + if (retval) { + err_msg("Error adding trigger %s\n", optarg); + exit(EXIT_FAILURE); + } + } else { + timerlat_top_usage("--trigger requires a previous -e\n"); + } + break; default: timerlat_top_usage("Invalid option"); } -- 2.34.1