Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2716558pxb; Thu, 3 Feb 2022 12:37:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXPcyrkkZphQ3XbasEL1f+1uTD4tEO/tinjWtl4uce3cZztrEyHJ0s5i97VQf+iIV8hR5A X-Received: by 2002:a63:257:: with SMTP id 84mr5648092pgc.121.1643920631832; Thu, 03 Feb 2022 12:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643920631; cv=none; d=google.com; s=arc-20160816; b=xDa1Thwhwm+l/DSNEheQy+EdmVZg3ikqMlywNncR7HKGPVssX7f0CAuq1pgVW14TCJ 46UdND5YKtCYlHKRjsHMldzNmLg5hwGJzpJxeKiWiiXKJoqz/rVVIJ6UR2Ux18vsSIR4 8G1xaftfBvk8yfarYArPa6H/y8sahvMGIQmFZYbE6Z4fHVB1M+2aqIjoCPQpT6TcdSHM 1yNSiVPvf81t5MC+VgJF7fOoM2BTh0ZemDMRbJzLwbDRr4t3Exdh85cLGvtPt3gDSvzC rP2LND4gVgOTKN93hWl6w3zeIP5KBspT6YugpaXK0ZJjEECBQeCdiZLVPBnFOGz+8/FZ NbSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G8te9fm9uBsrUaVWugKAeTKH1DeJ7u2Cxa+zpUpsAWk=; b=wo2OK1eRMj4NOdiJ+mXdIJXOh7sXYK0Ax7pe2t1lMGiy+VMOcdnkxXdd2ETv1YjZBk /OM3wgux+stUEUp26Qep0THNhBEktU/7j8dBBCenFFKcnVoxQlmrCAf1HSNgh1GgaY9l HNbBUSABcDuFXSTjnRRPWoXR7OdwFTHCW5Yatd5vieJnnWiDhZXEd603aF8fuVTwui3G baC0UD5geXO5Kh9Fpp1UFlrAo2ZHVPRqWFlOS2JI7PxAbXyF8yK4rHHaaAFgPL5FK4fR 5eYeB/gJYsiOb7KVIVhzaFtFHgksvHpFQryvWw3LjmJYQAor9dfAJB/vvFBQZmAVH3VW 6CFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RLc26mKl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22si6550042pll.259.2022.02.03.12.37.00; Thu, 03 Feb 2022 12:37:11 -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=@google.com header.s=20210112 header.b=RLc26mKl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240342AbiBCH6U (ORCPT + 99 others); Thu, 3 Feb 2022 02:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233434AbiBCH6R (ORCPT ); Thu, 3 Feb 2022 02:58:17 -0500 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0037CC06173B for ; Wed, 2 Feb 2022 23:58:16 -0800 (PST) Received: by mail-yb1-xb36.google.com with SMTP id i62so6387474ybg.5 for ; Wed, 02 Feb 2022 23:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G8te9fm9uBsrUaVWugKAeTKH1DeJ7u2Cxa+zpUpsAWk=; b=RLc26mKlJKGqZaYbJsxgavP6u0h8bb7n9zOgi5x58ejo4XgMD9YC4BXyaVfQAdQNnq 5QWxjDPw3yasqw1Jodx+qeAAcLoq26zWwgn21daH+X9CqH/nXsCTVyd0Xcmy5ffujHUn HIGuAqzCjc5OVJ9cMp3dwzTK9f/+QjEX1TWZzzqvhZgXoeztVAM0+6k9x2PWc7va8rTR GcJxbDQszD6uMX1/GF3RCs1tjHUgDXGDZKKmEQkHFZth85kOgEY/XUQiri8DqA1jn9Ux UXBJPTSw2uS3LfDzUvSUp605Ldtqn3beQ0aYBlibra4/a0GeRL3bb25537zoOwQJSnYf 11Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G8te9fm9uBsrUaVWugKAeTKH1DeJ7u2Cxa+zpUpsAWk=; b=O7cEe6EboBjrQ1umdxAo1lvwSlvZDOZpv9YTjSL9Lx7hgxGtKcsKjOlqd4OezU1rRF AtxcwUoE17bkPAysJdqf+Rtj9VMsLFtY2viH898/a19Uk99qivFpYcTE+ndC9fYLMFWL WaYA9ugb+WvJ/sh34VyePJJb5dUau8bLNjZO0MOMB3+cQwxSbzMSTg6SZ3faQbrAuwwH XIQRjzkyY7VjJ5VxOG0Bw/sfJ8JYKsAqgWHE2errmQn4aWrghUHuGjez8lIxRBmYioDz juRshg9JPHkiTTDtGLTGEZIn0+PVCScQrpHQ8NoTwI4pBWdLrQvvbyIwLIuUZXPijhpU RJzw== X-Gm-Message-State: AOAM5302wDlSzh74IncZdSg/BT/nNes1FMwA4I63tnwiX7whynn4ubq7 8RMGLwtmmMtKxKhp9wkti2jdQuGPXhakImUiJDAUkg== X-Received: by 2002:a0d:d6c5:: with SMTP id y188mr3267883ywd.188.1643875095965; Wed, 02 Feb 2022 23:58:15 -0800 (PST) MIME-Version: 1.0 References: <20220203010746.610494-1-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 2 Feb 2022 23:58:02 -0800 Message-ID: Subject: Re: [PATCH] perf metrics: Add literal for system TSC frequency To: Andi Kleen Cc: 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, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 2, 2022 at 7:59 PM Andi Kleen wrote: > > > 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. Thanks Andi, yep metrics with perf stat record are broken on a number of fronts and this will be another that will need a fix. It looks like the cpuid approach won't work pre-Skylake so sysfs could act as a fallback, but I don't have an ETA on when that will be available. We could have additional warnings when reading /proc/cpuinfo fails. Wdyt? Thanks, Ian > -Andi >