Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp505488lqp; Wed, 12 Jun 2024 08:03:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVX6jZkpOVKY0vMYfVjg0jyxYWey9h8TnKLTBkk19eIXzxNfgzPWPLuks1HYgpuQSKIL/uDDRm6vkU3hJ/ahgAEuoYawpg4YlzV9kz6FA== X-Google-Smtp-Source: AGHT+IGlBb797QJr8CalMRc2GMfHcaRukZtl1ki0qkkg9Bl71YZMa8HFagANewPtULyzvU+cW7ym X-Received: by 2002:a17:902:d508:b0:1f7:19d6:fb0 with SMTP id d9443c01a7336-1f83b716593mr22875725ad.45.1718204602231; Wed, 12 Jun 2024 08:03:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718204602; cv=pass; d=google.com; s=arc-20160816; b=IyzMmAoy0J+SO4SVLKNxrgw8aeZiDFFkyf0OeA4RI0OITvGHD8hfB+r/qdR3dGgr+c 3m7Oj69WNbOvH8HLYtIlcPfiyKkzeC9bos4S0/xqVjtOcfK9OPatzzRwhZBdSb6RvXh9 E1Sf/FfiJo6pwescY0Cc7kIRE37gQfvORefoYvXUd2pVRRf8xNG1XDDXH+2WDjum8yFq GiJaI8zkGI8zLlTJxsEhEShK/t7GyCUgWpbvj+xk2IqKSbMD+Oh2K4o7oHdGX2cfMNRw T63VWiplWfj3FqcTlogv2Uc6o0xoVjIo6sJmWOJ7QudPHT8o+SgxTLi2t+5PWoybRjYG RaLQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zyKxSiReGAzS1f+PvDOw58WbPsYDECO0YwUHLpbFRrw=; fh=K8mLBiK/3C/kmCEXsUOFCCNvyk4rolfkOaiOXXuEDi8=; b=lF3HpDlrXqnYAJGUdwVALBrl/Bf7N4TxOzD9Z2GHemEnJh08hVSCaWyoQInPu39zPh cv8Lx14pPUOKkOWD6Z9pRTiICVAKDnPYdoNkzo7FsioDGLX4yYKELlx1eTlTUOjaiP0n 6DlJHSH7RF1EYvLC2u4kLGNfUqfGe//Ca1zgzFNuGnPKCRJhIJunS+ffbC/q5CfMwO+h nhTi2Tu1FyW4wpOQRJyNpi3UbT+G7FjHEEiB9zF15O8kIeNA5rtIiJL6nEkvBc3SFlAi hqC6uxyzICR2hsgApNnDr54mLW8jUtZH1kXKphBiPNxA9/eQ6L+yFgnuOmcSDyTHdk/9 8txw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R3qRHcyU; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-211717-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211717-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f8477f93c4si6259405ad.68.2024.06.12.08.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 08:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211717-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R3qRHcyU; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-211717-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211717-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D6A94B21C2A for ; Wed, 12 Jun 2024 14:56:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60B5917F4EC; Wed, 12 Jun 2024 14:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R3qRHcyU" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 0542F17FAC9 for ; Wed, 12 Jun 2024 14:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204166; cv=none; b=Bzf1MGjk94t7YnEmbC0/drorgulsh37AL5UziWP8x6QzWnwF+j455ClsQ7OYpum4rC39/nJJwksr95eufqIPjJPQACvzb/HKc+50MQSFEoGCiWD6mIx6ns01r6liz3RcAum+bsZzG1ypp6PZyCdPUXVaA+J6ccWpLungqZrm54g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204166; c=relaxed/simple; bh=DcrBBI0AkLK0hHCnSouBZza5ncgd/m5D6aKcmbPC2JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QLguBaOc/T4Rxp6XQyq+7TL99fzWxgYkcYAqCOfJAg+B7zx8Il7RLmM1BxOXoEJgUaL/Q+v5elPLpyTeXZ2+o678O8hyTRtqiLqgxvRhGeLUo3juPpyXNw/tfgSlwolZ5XWRfCPO1+EpH1wayA2pTMMi2LCwhocTXIoAE3JMZNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R3qRHcyU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718204164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zyKxSiReGAzS1f+PvDOw58WbPsYDECO0YwUHLpbFRrw=; b=R3qRHcyU5X23nFW7ymUearOHZ02OoJApzYyn0sADnhhiPustGLijgZkJJtdrtsaA5SKceF vNF//hWYuF8Sj29WW2Gmmmmgj7fzMWFbg7jHsM6CNf7yu/6sr/tImQrDq0i5U4lgh2Sg4+ nHqlMFUCQKALhwAgC1/qjWa2Bq+ixMI= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-vHB95_DONhivEPToB721jA-1; Wed, 12 Jun 2024 10:56:02 -0400 X-MC-Unique: vHB95_DONhivEPToB721jA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A36B51955D9F; Wed, 12 Jun 2024 14:56:01 +0000 (UTC) Received: from fedora.brq.redhat.com (unknown [10.43.17.68]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A0D51955E91; Wed, 12 Jun 2024 14:55:59 +0000 (UTC) From: tglozar@redhat.com To: bristot@kernel.org, rostedt@goodmis.org Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, jkacur@redhat.com, jwyatt@redhat.com, Tomas Glozar Subject: [PATCH 4/5] rtla/timerlat: Add --disable-idle-states for hist Date: Wed, 12 Jun 2024 16:54:38 +0200 Message-ID: <20240612145439.206990-5-tglozar@redhat.com> In-Reply-To: <20240612145439.206990-1-tglozar@redhat.com> References: <20240612145439.206990-1-tglozar@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 From: Tomas Glozar Support disabling idle states also for timerlat-hist. Signed-off-by: Tomas Glozar --- tools/tracing/rtla/src/timerlat_hist.c | 35 +++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index a3907c390d67..69d427841d14 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 disable_idle_states; }; 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[=cgroup_name]] [--no-aa] [--dump-task] [-u|-k]", - " [--warm-up s]", + " [--warm-up s] [--disable-idle-states]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argument 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", + " --disable-idle-states: disable all idle states for cpus used by timerlat to reduce exit from idle latency", NULL, }; @@ -732,6 +734,9 @@ static struct timerlat_hist_params /* disabled by default */ params->dma_latency = -1; + /* disabled by default */ + params->disable_idle_states = 0; + /* display data in microseconds */ params->output_divisor = 1000; params->bucket_size = 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'}, + {"disable-idle-states", no_argument, 0, '\4'}, {0, 0, 0, 0} }; @@ -960,6 +966,9 @@ static struct timerlat_hist_params case '\3': params->buffer_size = get_llong_from_str(optarg); break; + case '\4': + params->disable_idle_states = 1; + break; default: timerlat_hist_usage("Invalid option"); } @@ -1152,6 +1161,7 @@ int timerlat_hist_main(int argc, char *argv[]) int return_value = 1; pthread_t timerlat_u; int retval; + int i; params = timerlat_hist_parse_args(argc, argv); if (!params) @@ -1201,6 +1211,21 @@ int timerlat_hist_main(int argc, char *argv[]) } } + if (params->disable_idle_states) { + for (i = 0; i < sysconf(_SC_NPROCESSORS_CONF); 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_cpu_idle_disable_state(i, 1) < 0) { + err_msg("Could not disable cpu idle state.\n"); + goto out_free; + } + } + } + if (params->trace_output) { record = osnoise_init_trace_tool("timerlat"); if (!record) { @@ -1332,6 +1357,13 @@ int timerlat_hist_main(int argc, char *argv[]) timerlat_aa_destroy(); if (dma_latency_fd >= 0) close(dma_latency_fd); + if (params->disable_idle_states) { + for (i = 0; i < sysconf(_SC_NPROCESSORS_CONF); 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 = NULL; out_free: @@ -1340,6 +1372,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); } -- 2.43.0