From nobody Tue Nov 26 14:36:26 2024 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 871501D5ABD for ; Thu, 17 Oct 2024 21:23:30 +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=1729200210; cv=none; b=oo3tWTSoZ1GAcOLn9LKgmthsuxuZrkc1Bmw9slMHz/L34q4zJelBFxmPtWInk/yOnhNrqaEpgn7jrbhVs8fWVq7IwocRoj9WQY616BrCK6GLKerIC0yabbq7yLKx0LnuIYl67Z4nEN+0no3AL+sbQhY+7yU7qnlOLorphQ5sPu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729200210; c=relaxed/simple; bh=N2942Xez6ol9ddAdVEu9X+qq29P6eprCH0C48NSQcs8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Yl3Z9S2SOYEaiEfHa4zvGCxDTtSZGyg4RaVJFvErjczGxD3mAr/QtsPYyrfE9mBc0SSVNPeKqlMOuIZnGVT+B1qL92FYLYdqJpLZpTzoqjcv+gzaTJ/9iJIhhe0ceJTNjzq3VbP5+xf9R3JW2pDGrWK8hPg1CKLm3JN+gWArNAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B64C4CED1; Thu, 17 Oct 2024 21:23:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1t1XyM-00000003wF6-3ELC; Thu, 17 Oct 2024 17:23:54 -0400 Message-ID: <20241017212354.629950130@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 17 Oct 2024 17:23:33 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur Subject: [for-next][PATCH 5/6] rtla/timerlat: Add --deepest-idle-state for hist References: <20241017212328.560060762@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tomas Glozar Support limiting deepest idle state also for timerlat-hist. Link: https://lore.kernel.org/20241017140914.3200454-6-tglozar@redhat.com Signed-off-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/src/timerlat_hist.c | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index d49c8f0855fe..01dd337da13a 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -55,6 +55,7 @@ struct timerlat_hist_params { int entries; int warmup; int buffer_size; + int deepest_idle_state; }; =20 struct timerlat_hist_cpu { @@ -655,7 +656,7 @@ static void timerlat_hist_usage(char *usage) " [-t[file]] [-e sys[:event]] [--filter ] [--trigger ] [-c cpu-list] [-H cpu-list]\\", " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [= --no-summary] \\", " [--no-index] [--with-zeros] [--dma-latency us] [-C[=3Dcgroup_name]] = [--no-aa] [--dump-task] [-u|-k]", - " [--warm-up s]", + " [--warm-up s] [--deepest-idle-state n]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us latency is hit", @@ -695,6 +696,7 @@ static void timerlat_hist_usage(char *usage) " -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", + " --deepest-idle-state n: only go down to idle state n on cpus used= by timerlat to reduce exit from idle latency", NULL, }; =20 @@ -732,6 +734,9 @@ static struct timerlat_hist_params /* disabled by default */ params->dma_latency =3D -1; =20 + /* disabled by default */ + params->deepest_idle_state =3D -2; + /* display data in microseconds */ params->output_divisor =3D 1000; params->bucket_size =3D 1; @@ -772,6 +777,7 @@ static struct timerlat_hist_params {"dump-task", no_argument, 0, '\1'}, {"warm-up", required_argument, 0, '\2'}, {"trace-buffer-size", required_argument, 0, '\3'}, + {"deepest-idle-state", required_argument, 0, '\4'}, {0, 0, 0, 0} }; =20 @@ -960,6 +966,9 @@ static struct timerlat_hist_params case '\3': params->buffer_size =3D get_llong_from_str(optarg); break; + case '\4': + params->deepest_idle_state =3D get_llong_from_str(optarg); + break; default: timerlat_hist_usage("Invalid option"); } @@ -1152,6 +1161,7 @@ int timerlat_hist_main(int argc, char *argv[]) int return_value =3D 1; pthread_t timerlat_u; int retval; + int nr_cpus, i; =20 params =3D timerlat_hist_parse_args(argc, argv); if (!params) @@ -1201,6 +1211,28 @@ int timerlat_hist_main(int argc, char *argv[]) } } =20 + if (params->deepest_idle_state >=3D -1) { + if (!have_libcpupower_support()) { + err_msg("rtla built without libcpupower, --deepest-idle-state is not su= pported\n"); + goto out_free; + } + + nr_cpus =3D sysconf(_SC_NPROCESSORS_CONF); + + for (i =3D 0; i < nr_cpus; i++) { + if (params->cpus && !CPU_ISSET(i, ¶ms->monitored_cpus)) + continue; + if (save_cpu_idle_disable_state(i) < 0) { + err_msg("Could not save cpu idle state.\n"); + goto out_free; + } + if (set_deepest_cpu_idle_state(i, params->deepest_idle_state) < 0) { + err_msg("Could not set deepest cpu idle state.\n"); + goto out_free; + } + } + } + if (params->trace_output) { record =3D osnoise_init_trace_tool("timerlat"); if (!record) { @@ -1332,6 +1364,13 @@ int timerlat_hist_main(int argc, char *argv[]) timerlat_aa_destroy(); if (dma_latency_fd >=3D 0) close(dma_latency_fd); + if (params->deepest_idle_state >=3D -1) { + for (i =3D 0; i < nr_cpus; i++) { + if (params->cpus && !CPU_ISSET(i, ¶ms->monitored_cpus)) + continue; + restore_cpu_idle_disable_state(i); + } + } trace_events_destroy(&record->trace, params->events); params->events =3D NULL; out_free: @@ -1340,6 +1379,7 @@ int timerlat_hist_main(int argc, char *argv[]) osnoise_destroy_tool(record); osnoise_destroy_tool(tool); free(params); + free_cpu_idle_disable_states(); out_exit: exit(return_value); } --=20 2.45.2