From patchwork Thu Dec 15 15:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 33687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp431324wrn; Thu, 15 Dec 2022 07:36:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOHwEGSLi7tG8npJjWCa0+WJu9LBVn/1p6QuQqqpqt+5C7pxNM2mlrKE8mZOBWckiSeAZI X-Received: by 2002:a50:8d4d:0:b0:472:f7c1:361 with SMTP id t13-20020a508d4d000000b00472f7c10361mr4175386edt.29.1671118595201; Thu, 15 Dec 2022 07:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671118595; cv=none; d=google.com; s=arc-20160816; b=IPkAyle8J/A6nbZ0nXM/vM8gVz3d3NQxbtsqwBUajIyJBEkZFoPgDDeueHFgQNt94Z sKpWgnGuV8z1x6Y5OCHp4fw0ynK6V8xClwUwUPTwLTAWY2moo06+v5oEMGhF0KfbANB5 OA2T/bqeX9XBih0f61o7m0RY5P6TIq5mBGEtqJXhV3bHaRWNZHqRA2bSsukSUJXInnHk zcXutaTkosXnpaeMbUWAjlI9wPiTXow8x/kjuXGZYq3ohmctyhHou7DUb80Oql4pExRz 0y8ggHlJDFVJVTCGevxtaDw3xEarEClfzU6XfZPwVURcUqi7x5JxvNSBVPNilaf1f8kZ JtgA== 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:dkim-signature; bh=7KUNZyPDGe0XK6FnhpWbuMdnMhrHJ4f42gZN22/tCOo=; b=P2jrC9e2voeZUU1L41vcngxllCO2cuLWg74o+Im+/HDinpuomBK+8RJlqWkSEs7CHL vTeHn2W0kBaeLY2IHrSd3GwerYQJthCiet+MxfSgelbMAsk0drvn5Gijwra+L9cT8fB0 1MclZE0raa3We0Ssrg1T4mfIFZDSutYERYJ5UDdYDIH8suwHJazQAkehBq179w31jn9V gvOSObJVan+l1XCqcwH061G8ddzmzG3XA0EsLEnT0YEl+AMIZIyAIQ4rRXOvyxDFc0xL dPxZKWTy7BpygxG/kfFw9ED0oXrFXkYyq8T3zNaznWU85L8WwtInN+U2cb+mgL3OkKhU XxUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZ22oD5T; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a0564020e8d00b0047035379d79si5988210eda.556.2022.12.15.07.36.08; Thu, 15 Dec 2022 07:36:35 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZ22oD5T; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbiLOPUa (ORCPT + 99 others); Thu, 15 Dec 2022 10:20:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiLOPTs (ORCPT ); Thu, 15 Dec 2022 10:19:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC55430F7D for ; Thu, 15 Dec 2022 07:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671117505; 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; bh=7KUNZyPDGe0XK6FnhpWbuMdnMhrHJ4f42gZN22/tCOo=; b=aZ22oD5TagiSekw240toiH5tYcklUX/bRkEaBJD6aRd2Ss9aP0lCaIBujvGLu/mvXfgCmD 1/jCYv/x5NfTlVV3P8B6SO0QX4n6wTgnDn6A3Cfnmrf4UqKJk2MszqRINgjksmof7iEWnH ZH8t3AigejMfZqEEpyUnVBMLz+3qLIo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-hnmgHrxRMBy57xI71Rg9wg-1; Thu, 15 Dec 2022 10:18:20 -0500 X-MC-Unique: hnmgHrxRMBy57xI71Rg9wg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82B4518F0243; Thu, 15 Dec 2022 15:18:20 +0000 (UTC) Received: from prarit.7a2m.lab.eng.bos.redhat.com (prarit-guest.7a2m.lab.eng.bos.redhat.com [10.16.222.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60A3640C2064; Thu, 15 Dec 2022 15:18:20 +0000 (UTC) From: Prarit Bhargava To: linux-kernel@vger.kernel.org Cc: Prarit Bhargava , Len Brown , linux-pm@vger.kernel.org Subject: [PATCH] turbostat.c: Fix /dev/cpu_dma_latency warnings Date: Thu, 15 Dec 2022 10:18:16 -0500 Message-Id: <20221215151816.19956-1-prarit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752294852052697651?= X-GMAIL-MSGID: =?utf-8?q?1752294852052697651?= When running as non-root the following error is seen in turbostat: turbostat: fopen /dev/cpu_dma_latency : Permission denied turbostat and the man page have information on how to avoid other permission errors, so these can be fixed the same way. Provide better /dev/cpu_dma_latency warnings that provide instructions on how to avoid the error, and update the man page. Signed-off-by: Prarit Bhargava Cc: Len Brown Cc: linux-pm@vger.kernel.org --- tools/power/x86/turbostat/turbostat.8 | 2 ++ tools/power/x86/turbostat/turbostat.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8 index c7b26a3603af..3e1a4c4be001 100644 --- a/tools/power/x86/turbostat/turbostat.8 +++ b/tools/power/x86/turbostat/turbostat.8 @@ -344,6 +344,8 @@ Alternatively, non-root users can be enabled to run turbostat this way: # chmod +r /dev/cpu/*/msr +# chmod +r /dev/cpu_dma_latency + .B "turbostat " reads hardware counters, but doesn't write them. So it will not interfere with the OS or other programs, including diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index aba460410dbd..fef76ed294fc 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -5476,13 +5476,13 @@ void print_dev_latency(void) fd = open(path, O_RDONLY); if (fd < 0) { - warn("fopen %s\n", path); + warn("open failed, try chmod +r %s\n", path); return; } retval = read(fd, (void *)&value, sizeof(int)); if (retval != sizeof(int)) { - warn("read %s\n", path); + warn("read failed %s\n", path); close(fd); return; }