Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp318029lqo; Thu, 16 May 2024 07:15:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQ7v4B+e0SQUWPHXNwk2w4vb7AS38suMRvfr0otdwpDF9pmewvQOqloyiVZI9lJDSOCCySuTDpnmq/A4baox72YrInYYstUCZZ8nuQSA== X-Google-Smtp-Source: AGHT+IFKPwKPfLLyfoITkNB6PM+rn6t6RU96/glTVmu00O+GU+2guPyWK5nZUo3eHuAvLDoknnQp X-Received: by 2002:a17:903:234b:b0:1f0:9395:751c with SMTP id d9443c01a7336-1f09395772fmr50117685ad.61.1715868941181; Thu, 16 May 2024 07:15:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715868941; cv=pass; d=google.com; s=arc-20160816; b=pnKzCoBgXQ/OkA1WJD7taatGT9toZWIh5OpBgcFN3nHEe9DtjNIb7QZwSJoKSi8Xiv CQAfsE82AkrYD0EBYTHqitrzSS74ThtojSbF4kQVzEynzT6yEXMW+D8D87uo1QB87Ej3 /nkYlBQa5gB3lJoZIs1HD48Vqvtzc2FKsY4nGAw4SOqFEsPL9CMnuoc1qE5DDKPbh49I HtF/VqFlL0isr9J9NwQ27ZexS1A2ylFh+9BLhjvP414P/1K/ebWHXVma/pPxabCkYlDC vKY8VJivc+44BZrvnnLnCfhwJMLu/zMXeXFH9PORs2IaGAQisFnSziDbt1nLqrJBmmcb 533Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=6Sg/EyCQHeG+px4T3E4Bw6dqry9ua2RE0LSIYSHrMIE=; fh=HiCmF1TcrJ86j7wakWiQ3IgZHXFnWwwDLwcpFPQTOG8=; b=BW4qHIy161aE5z9c5Q2GF2aW7NnDDRXRKWF0YagiQ2GTTZCIy+pF3Zy3Ycxo4yEYIy rEHUbAXbkLjTst5Ac1IAo0U6x6Sm5TN8IHI1qZDtjs19pNC8fa75/J/lf3Au9J/BNlR3 7lZXKJfdj6XTUjJ/69o4L2ua3IIKUD8gEANjp5AzKADuG4E530kI6kr0N98q4A3NtpnS LfuLenb0sD/a3tKMwWfj6zm+unE0AhHxuO5azyE7xN9VA9uqX2LgZxkPd64nWJlGgDBD o6TOItTpkyYJnk1vODV26LXYOit4aDfmmfAXOkOZxDN0j8uDuCC8/qgyce2ZgK7Smkhd 1FwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fCF7Jiok; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f097de9845si24587445ad.646.2024.05.16.07.15.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 07:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fCF7Jiok; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-181162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AE7D7281312 for ; Thu, 16 May 2024 14:15:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9F6E14A097; Thu, 16 May 2024 14:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fCF7Jiok" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9681F1474C6; Thu, 16 May 2024 14:15:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715868933; cv=none; b=APOMvhMyHzkW6twalgyU4JxJepqERDNSPrS7if+fsLcdx7E/9JuWwR4oslF8g/jz9txbkP2HZhp2Qm9dt1Mfk7QWbYOZY03BQ2t+5X9IjN9GvHH+KQ0JCqB5Xv9Qggng5bLLm2QCLTxk9SSsMX2k/lSy0xBpR2kijqG/Xu2BxQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715868933; c=relaxed/simple; bh=xJWLHXVj/UusIjMRA+9xpHvtDGqx1XYjqLJwQKL4ogo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uSFkz/ZC8YRkn7UbYTOIKjuaK62mnMUN+w3JtQvJ5sosj5Bro/Ztzhx0HqYKDmN9P3zreD218F14e7QkJ/LoBh9u0sUGaSrtRe9G29fGagIlMhSAONdENFEkMxipRv2t1HYnd9+VHZX2shggX1JRKnTU19MPM3CqcxPSIJNgJbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fCF7Jiok; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 605C0C113CC; Thu, 16 May 2024 14:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715868933; bh=xJWLHXVj/UusIjMRA+9xpHvtDGqx1XYjqLJwQKL4ogo=; h=From:To:Cc:Subject:Date:From; b=fCF7JiokGKzaMT0oqC2YC26FhUVpm4zbfPysWisxdYbvYQBhvbSTTDgQ8CxuxmgeK 6Zc4nUSYZHW52vey3c1PIRkW0EtQ7rU7YnPV8wdI9FIhTdC6tjkc4xXg6bBCUKVsGY stWAMpaD56HNDIKHpwEelTf5skswdXqAEZc4VYKDLFxlVpYVJ0H9obOeOtHl+SmR56 EfzcKoPP+CswA8mtEwX4rlEKsvNTeT3Hk9R5HxYTEjWs53CUNp4w3EppMyrAyXc4UN AldMTHm1j2QDkcUW3R7qqJzsXWfk+h3b6VzIxbcdR/lLflsKebACBVrHVCqsT/3e0b 5nz0B5AMcnXoA== From: Daniel Bristot de Oliveira To: Daniel Bristot de Oliveira , Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Juri Lelli , John Kacur Subject: [PATCH V2] rtla: Add --trace-buffer-size option Date: Thu, 16 May 2024 16:15:22 +0200 Message-ID: X-Mailer: git-send-email 2.45.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add the option allow the users to set a different buffer size for the trace. For example, in large systems, the user might be interested on reducing the trace buffer to avoid large tracing files. The buffer size is specified in kB, and it is only affecting the tracing instance. The function trace_set_buffer_size() appears on libtracefs v1.6, so increase the minimum required version on Makefile.config. Signed-off-by: Daniel Bristot de Oliveira --- Changes from V1: Increase minimum libtracefs version (jkacur). Link: https://lkml.kernel.org/r/0281bfbd3b3fed11a0150a8645a1f9941a423c7a.1713968967.git.bristot@kernel.org Documentation/tools/rtla/common_options.rst | 3 +++ tools/tracing/rtla/Makefile.config | 2 +- tools/tracing/rtla/src/osnoise_hist.c | 13 ++++++++++++- tools/tracing/rtla/src/osnoise_top.c | 14 +++++++++++++- tools/tracing/rtla/src/timerlat_hist.c | 14 +++++++++++++- tools/tracing/rtla/src/timerlat_top.c | 14 +++++++++++++- tools/tracing/rtla/src/trace.c | 15 +++++++++++++++ tools/tracing/rtla/src/trace.h | 1 + 8 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Documentation/tools/rtla/common_options.rst b/Documentation/tools/rtla/common_options.rst index a96ea0ed662e..7ac7b7581466 100644 --- a/Documentation/tools/rtla/common_options.rst +++ b/Documentation/tools/rtla/common_options.rst @@ -54,6 +54,9 @@ After starting the workload, let it run for *s* seconds before starting collecting the data, allowing the system to warm-up. Statistical data generated during warm-up is discarded. +**--trace-buffer-size** *kB* + Set the per-cpu trace buffer size in kB for the tracing output. + **-h**, **--help** Print help menu. diff --git a/tools/tracing/rtla/Makefile.config b/tools/tracing/rtla/Makefile.config index 6d4ba77847b6..0b7ecfb30d19 100644 --- a/tools/tracing/rtla/Makefile.config +++ b/tools/tracing/rtla/Makefile.config @@ -3,7 +3,7 @@ STOP_ERROR := LIBTRACEEVENT_MIN_VERSION = 1.5 -LIBTRACEFS_MIN_VERSION = 1.3 +LIBTRACEFS_MIN_VERSION = 1.6 define lib_setup $(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c index c6100ff46a7f..198a17a3ea2e 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -43,6 +43,7 @@ struct osnoise_hist_params { int bucket_size; int entries; int warmup; + int buffer_size; }; struct osnoise_hist_cpu { @@ -469,6 +470,7 @@ static void osnoise_hist_usage(char *usage) " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period", " in nanoseconds", " --warm-up: let the workload run for s seconds before collecting data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; @@ -533,13 +535,14 @@ static struct osnoise_hist_params {"trigger", required_argument, 0, '4'}, {"filter", required_argument, 0, '5'}, {"warm-up", required_argument, 0, '6'}, + {"trace-buffer-size", required_argument, 0, '7'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:", + c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:", long_options, &option_index); /* detect the end of the options. */ @@ -685,6 +688,9 @@ static struct osnoise_hist_params case '6': params->warmup = get_llong_from_str(optarg); break; + case '7': + params->buffer_size = get_llong_from_str(optarg); + break; default: osnoise_hist_usage("Invalid option"); } @@ -891,6 +897,11 @@ int osnoise_hist_main(int argc, char *argv[]) goto out_hist; } + if (params->buffer_size > 0) { + retval = trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_hist; + } } /* diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c index 53a074c1222e..7e5aab22727d 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -41,6 +41,7 @@ struct osnoise_top_params { int cgroup; int hk_cpus; int warmup; + int buffer_size; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -309,6 +310,7 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage) " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period", " in nanoseconds", " --warm-up s: let the workload run for s seconds before collecting data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; @@ -384,13 +386,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv) {"trigger", required_argument, 0, '0'}, {"filter", required_argument, 0, '1'}, {"warm-up", required_argument, 0, '2'}, + {"trace-buffer-size", required_argument, 0, '3'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:", + c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, &option_index); /* Detect the end of the options. */ @@ -517,6 +520,9 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv) case '2': params->warmup = get_llong_from_str(optarg); break; + case '3': + params->buffer_size = get_llong_from_str(optarg); + break; default: osnoise_top_usage(params, "Invalid option"); } @@ -725,6 +731,12 @@ int osnoise_top_main(int argc, char **argv) if (retval) goto out_top; } + + if (params->buffer_size > 0) { + retval = trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_top; + } } /* diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 6eb6e38d4a05..d4bab86ca1b9 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -54,6 +54,7 @@ struct timerlat_hist_params { int bucket_size; int entries; int warmup; + int buffer_size; }; struct timerlat_hist_cpu { @@ -669,6 +670,7 @@ static void timerlat_hist_usage(char *usage) " -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload", " --warm-up s: let the workload run for s seconds before collecting data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; @@ -745,13 +747,14 @@ static struct timerlat_hist_params {"no-aa", no_argument, 0, '9'}, {"dump-task", no_argument, 0, '\1'}, {"warm-up", required_argument, 0, '\2'}, + {"trace-buffer-size", required_argument, 0, '\3'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:", + c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3", long_options, &option_index); /* detect the end of the options. */ @@ -926,6 +929,9 @@ static struct timerlat_hist_params case '\2': params->warmup = get_llong_from_str(optarg); break; + case '\3': + params->buffer_size = get_llong_from_str(optarg); + break; default: timerlat_hist_usage("Invalid option"); } @@ -1179,6 +1185,12 @@ int timerlat_hist_main(int argc, char *argv[]) if (retval) goto out_hist; } + + if (params->buffer_size > 0) { + retval = trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_hist; + } } if (!params->no_aa) { diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index 0acfefe151f7..3a23e8d481c6 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -47,6 +47,7 @@ struct timerlat_top_params { int kernel_workload; int pretty_output; int warmup; + int buffer_size; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -479,6 +480,7 @@ static void timerlat_top_usage(char *usage) " -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload", " --warm-up s: let the workload run for s seconds before collecting data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; @@ -547,13 +549,14 @@ static struct timerlat_top_params {"dump-tasks", no_argument, 0, '4'}, {"aa-only", required_argument, 0, '5'}, {"warm-up", required_argument, 0, '6'}, + {"trace-buffer-size", required_argument, 0, '7'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:", + c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:", long_options, &option_index); /* detect the end of the options. */ @@ -716,6 +719,9 @@ static struct timerlat_top_params case '6': params->warmup = get_llong_from_str(optarg); break; + case '7': + params->buffer_size = get_llong_from_str(optarg); + break; default: timerlat_top_usage("Invalid option"); } @@ -973,6 +979,12 @@ int timerlat_top_main(int argc, char *argv[]) if (retval) goto out_top; } + + if (params->buffer_size > 0) { + retval = trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_top; + } } if (!params->no_aa) { diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index e1ba6d9f4265..170a706248ab 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -540,3 +540,18 @@ int trace_is_off(struct trace_instance *tool, struct trace_instance *trace) return 0; } + +/* + * trace_set_buffer_size - set the per-cpu tracing buffer size. + */ +int trace_set_buffer_size(struct trace_instance *trace, int size) +{ + int retval; + + debug_msg("Setting trace buffer size to %d Kb\n", size); + retval = tracefs_instance_set_buffer_size(trace->inst, size, -1); + if (retval) + err_msg("Error setting trace buffer size\n"); + + return retval; +} diff --git a/tools/tracing/rtla/src/trace.h b/tools/tracing/rtla/src/trace.h index 2e9a89a25615..c7c92dc9a18a 100644 --- a/tools/tracing/rtla/src/trace.h +++ b/tools/tracing/rtla/src/trace.h @@ -48,3 +48,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); +int trace_set_buffer_size(struct trace_instance *trace, int size); -- 2.43.0