X-Received: by 2002:a17:906:eb0f:b0:6af:738:3380 with SMTP id mb15-20020a170906eb0f00b006af07383380mr1140058ejb.398.1645649705492; Wed, 23 Feb 2022 12:55:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645649705; cv=none; d=google.com; s=arc-20160816; b=aV0OzQZ5mh9uMXLSBNlH3DQY1dAm98E7k4ii709ukTh2tOUx4G8aUplTqzLTwciTqE JYhyXjYpejgSzXvjIwzhazjior9Qaa2RdEloVqOqCxv73t+gq09AfKRgkdJ+KVwPlhJ8 6ElCQEjy1pLuEPLkrs9JgytgAHZaDtE4JILCx4OEBgcWuDOFldh8xPCxXA75tfZF5pIw Sbo1R6DZUIZZ4c75LBZ1sIo6GxTTywFFYLJDsgjAjmN1C99KKquyMeo1yu59+1gmkN/y v6etVF444Ot8zWpgBgda0acoCYoQqqNLWnzSJFvkjd6sEc1YdYXgPoRsUUiMt/UnJ9I2 QPBg== 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 :message-id:date:subject:cc:to:from; bh=Vrhhj6v+PBHtbC09qjtbZwoPr0J9pJzjp1YLhXfNzXU=; b=f8dM6+JbAKEy42uFTFY8it6g/0MZBMZZZGRouYorgyAvMQZcKA1YfhWtRWYITgCRcF a31keWmHsecnlF547wkKszB/qipDAsyv0jSPgRjjguSg7jf+bMQ9Dv7Fu/yEpVcJa4u+ HYvhLtbqu9HubsbRwn+Tzgv0racqDnWSmjsLSmVMAshketfOED3aM0Hbbi9q3qdtu6w3 hqPtN5CMLsGAOk5/8JKUoM2ityrc9p3E3EDFvbTIcd/HTS1wL5LFpAcoalsN2g3deXd0 WhchJiySmXSesquXIr0m3Q2f7fi/QNKwjKXY/8suAh0NiXpLF5o2zgqUlp//pCDQcFeq QRdA== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12si371740edr.305.2022.02.23.12.54.43; Wed, 23 Feb 2022 12:55:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243915AbiBWSiU convert rfc822-to-8bit (ORCPT + 99 others); Wed, 23 Feb 2022 13:38:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243981AbiBWSiS (ORCPT ); Wed, 23 Feb 2022 13:38:18 -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 4123F49243 for ; Wed, 23 Feb 2022 10:37:48 -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-601-Nc0wuXH1MGGCkCOMhI_V5w-1; Wed, 23 Feb 2022 13:37:42 -0500 X-MC-Unique: Nc0wuXH1MGGCkCOMhI_V5w-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 31D14100C609; Wed, 23 Feb 2022 18:37:41 +0000 (UTC) Received: from x1.com (unknown [10.22.8.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF6F83480F; Wed, 23 Feb 2022 18:37:39 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH] rtla: Set /dev/cpu_dma_latency to avoid exit from idle latencies Date: Wed, 23 Feb 2022 19:37:35 +0100 Message-Id: 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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL,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 Set /dev/cpu_dma_latency to 0 to avoid having exit from idle states latencies influencing in the analysis. Cc: Daniel Bristot de Oliveira Cc: Steven Rostedt Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_hist.c | 10 ++++++++ tools/tracing/rtla/src/timerlat_top.c | 10 ++++++++ tools/tracing/rtla/src/utils.c | 33 ++++++++++++++++++++++++++ tools/tracing/rtla/src/utils.h | 1 + 4 files changed, 54 insertions(+) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 237e1735afa7..3c0108ff63ab 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -732,6 +732,7 @@ int timerlat_hist_main(int argc, char *argv[]) struct osnoise_tool *record = NULL; struct osnoise_tool *tool = NULL; struct trace_instance *trace; + int dma_latency_fd = -1; int return_value = 1; int retval; @@ -767,6 +768,13 @@ int timerlat_hist_main(int argc, char *argv[]) } } + /* + * Avoid going into deep idle states. + */ + dma_latency_fd = set_cpu_dma_latency(0); + if (dma_latency_fd < 0) + err_msg("Could not set /dev/cpu_dma_latency to 0. Long IRQ latencies expected\n"); + trace_instance_start(trace); if (params->trace_output) { @@ -812,6 +820,8 @@ int timerlat_hist_main(int argc, char *argv[]) } out_hist: + if (dma_latency_fd >= 0) + close(dma_latency_fd); timerlat_free_histogram(tool->data); osnoise_destroy_tool(record); osnoise_destroy_tool(tool); diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index d4187f6534ed..f4bca0ad5de3 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -524,6 +524,7 @@ int timerlat_top_main(int argc, char *argv[]) struct osnoise_tool *record = NULL; struct osnoise_tool *top = NULL; struct trace_instance *trace; + int dma_latency_fd = -1; int return_value = 1; int retval; @@ -559,6 +560,13 @@ int timerlat_top_main(int argc, char *argv[]) } } + /* + * Avoid going into deep idle states. + */ + dma_latency_fd = set_cpu_dma_latency(0); + if (dma_latency_fd < 0) + err_msg("Could not set /dev/cpu_dma_latency. Long IRQ latencies expected.\n"); + trace_instance_start(trace); if (params->trace_output) { @@ -608,6 +616,8 @@ int timerlat_top_main(int argc, char *argv[]) } out_top: + if (dma_latency_fd >= 0) + close(dma_latency_fd); timerlat_free_top(top->data); osnoise_destroy_tool(record); osnoise_destroy_tool(top); diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c index ffaf8ec84001..da2b590edaed 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -431,3 +432,35 @@ int parse_prio(char *arg, struct sched_attr *sched_param) } return 0; } + +/* + * set_cpu_dma_latency - set the /dev/cpu_dma_latecy + * + * This is used to reduce the exit from idle latency. The value + * will be reset once the file descriptor of /dev/cpu_dma_latecy + * is closed. + * + * Return: the /dev/cpu_dma_latecy file descriptor + */ +int set_cpu_dma_latency(int32_t latency) +{ + int retval; + int fd; + + fd = open("/dev/cpu_dma_latency", O_RDWR); + if (fd < 0) { + err_msg("Error opening /dev/cpu_dma_latency\n"); + return -1; + } + + retval = write(fd, &latency, 4); + if (retval < 1) { + err_msg("Error setting /dev/cpu_dma_latency\n"); + close(fd); + return -1; + } + + debug_msg("Set /dev/cpu_dma_latency to %d\n", latency); + + return fd; +} diff --git a/tools/tracing/rtla/src/utils.h b/tools/tracing/rtla/src/utils.h index 9aa962319ca2..fa08e374870a 100644 --- a/tools/tracing/rtla/src/utils.h +++ b/tools/tracing/rtla/src/utils.h @@ -54,3 +54,4 @@ struct sched_attr { int parse_prio(char *arg, struct sched_attr *sched_param); int set_comm_sched_attr(const char *comm, struct sched_attr *attr); +int set_cpu_dma_latency(int32_t latency); -- 2.34.1