Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2509545pxb; Thu, 3 Feb 2022 08:06:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNznXkVMGCOfO/4MKaFB/kTFHeLxJgPMY07cCvuZGmpjpjIn/Vt7X7NjuesrzXbf5IavtD X-Received: by 2002:a63:e70b:: with SMTP id b11mr29231273pgi.203.1643904364464; Thu, 03 Feb 2022 08:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643904364; cv=none; d=google.com; s=arc-20160816; b=rpyiVSIihetUi78ktsT9QGqbOBSmBsBYXCaV5trjw6ULCLeTfj66yQhWxUzoQHXw27 lVzKVdp62+Fn6q2YeAMwsCX/rAwmeFo0H+b+HjurNsPF6Mt2n95s9q6AZgS3ga0KMaPu N4uZ3nRCt0XN5e2kLllmHoYQ115/WqJFyQ/sNwPIzp/+wlkKdc/t4mtXMkZaIVT461ew rbLmgRn4yUWkAO3RLChdPXaes4QdcUZM2sqmU4fXvMQJbrhL0jf9occ0wRA9twbqZfp5 7UfB6tTTof7ZibVflykKFmbH5vyfhBUmQJsKmAxVIhgzq4rX04pWEchNm7BGCuwUebWu 5GHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CS7orvxd0yaq2qirfh5FnjK8IvxzbYon4IZglTTvZWk=; b=QgaIMEMxeDuQmkuxn5fAyat4G/ECdA/R50TMKCIkPl3rrHxLAqYx7dBNzWtgH0nP+d Kq+nU+w46zFAzwGw+YA44bSqUmQB+pchbhLXQhkWrEo22O7mL+sMP/drHGFFLzbRSFAJ +oQI+YyvTzbU5U50ZuLqkl0iqXA0/r5GCiGRqlqMs5xvP9nQkSpoqXlfFk3rPRa84QgX 9qVNLuv0EZLN+RBmPwK7y4To7CT+T/g+iNCWhh9DnmtKbWy4RTidD/UjC6o6FbayL3Bl oOfAcHqHOHVUZIC9OIanFZ7JNd1IfabibSXbHuc1+qUD0VT6efoW7C+RC3Mayn/+6Qo6 0Zjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VscWcCui; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16si23741900plh.531.2022.02.03.08.05.45; Thu, 03 Feb 2022 08:06:04 -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=@intel.com header.s=Intel header.b=VscWcCui; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349272AbiBCEAB (ORCPT + 99 others); Wed, 2 Feb 2022 23:00:01 -0500 Received: from mga02.intel.com ([134.134.136.20]:10261 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbiBCD7z (ORCPT ); Wed, 2 Feb 2022 22:59:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643860795; x=1675396795; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ZYA57xTbdJSnrx2D/xliMGotRPM9NQFUEpYWCzlWsRA=; b=VscWcCuin4AzDLUTgMZkhemyCyvSVWO4zcGwG0qhXWvatBalwK14ArVa jpz7luKY0RIJW/mljaQms92LH+kMb8r16QLfr8k5jETKu+JqkWJW+cHtl Cq6X7SIn0N/FqfP8yA4/DgQcX11fJAgq1Gyz4aOrNmIoY8yJ0GWyjcWDW X7zkhZB5VjeMpPwvkkgUcL/J5hwFLXjy2b63jG3X0sOWX0eWvXCteBnpx +p2+P3Q3MQOeoHWN/61Fqrq7/XfomTZERVV5/ZubBIpK4ae2fpk86v/PO H+A1flYmNZ2MPYCa1EFkaejIhIK4dPYeGjWJqECAyUInUq25UR10efq3O Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="235471461" X-IronPort-AV: E=Sophos;i="5.88,338,1635231600"; d="scan'208";a="235471461" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2022 19:59:53 -0800 X-IronPort-AV: E=Sophos;i="5.88,338,1635231600"; d="scan'208";a="631213682" Received: from akleen-mobl1.amr.corp.intel.com (HELO [10.209.76.239]) ([10.209.76.239]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2022 19:59:52 -0800 Message-ID: Date: Wed, 2 Feb 2022 19:59:52 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH] perf metrics: Add literal for system TSC frequency Content-Language: en-US To: Ian Rogers , vineet.singh@intel.com, perry.taylor@intel.com, caleb.biggers@intel.com, asaf.yaffe@intel.com, kshipra.bopardikar@intel.com, Kan Liang , Zhengjun Xing , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Maxime Coquelin , Alexandre Torgue , James Clark , John Garry , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian References: <20220203010746.610494-1-irogers@google.com> From: Andi Kleen In-Reply-To: <20220203010746.610494-1-irogers@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/2022 5:07 PM, Ian Rogers wrote: > Such a literal is useful to calculate things like the average frequency > [1]. The TSC frequency isn't exposed by sysfs although some experimental > drivers look to add it [2]. This change computes the value using the > frequency in /proc/cpuinfo which is accruate at least on Intel > processors. FWIW the information in /proc/cpuinfo is going away. You should really use CPUID for this, which has a new leaf for this. Unfortunately there were a few systems were it was inaccurate, but I suppose you could still prefer /proc/cpuinfo Also your method will not work when the metrics are used through perf stat report or perf script and run on another system. For the perf script case there is support for putting the TSC into perf.data (that is needed for PT), but the header is not dumped by default unfortunately. So likely you would need some new mechanism for that. -Andi