Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp169310rbe; Wed, 28 Feb 2024 16:20:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMDYL/3AnMJQQHi2os1SqCjnL/2mbHn4DaOuMNqlUOaZZQOuO/C0UdYHymPkNAgtGspMHrRoHj44U2y9fjV+yK3HMqacVkaii+H0UdaQ== X-Google-Smtp-Source: AGHT+IGpJkeUcO2E8WLV037VE6xdhgvxZwo+i50Yep1QsrP2fIbcoZ2SfPVnpdahTuhBcEzCP6kU X-Received: by 2002:a17:906:3502:b0:a3d:bb68:be30 with SMTP id r2-20020a170906350200b00a3dbb68be30mr306895eja.6.1709166055475; Wed, 28 Feb 2024 16:20:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166055; cv=pass; d=google.com; s=arc-20160816; b=L/nAUjZ3snnVPoEhuMw3ADAs7BfojaaTsVAJVXjhQC4Vkv0AzDTWALIKHaQxA7viAD DUj+044laKWrYGwRJRwBFf3NVGtrEJlA29l0adbYMk7R7P6lVkMHweyqdyamasqBy7pr LJN4wIkcYOAvwh+LrE1fxlstnPsBQnFuO+QEQPehNSWHxzpNjHotZaDJEAqj1NPxwCaD HZHK4MbV6/j6PqGfkutjEZXJuYroMZUhfMj/lQFSXbVVa7pjTrwFe4OJqz+s18Z3FUI4 2gWk/wmm/5i1nPUem6D4Si9hd2Vag4xmKkVg2Mb12W5+Grt/PUvGD3O2RFTDigYPgBjg 0BkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; fh=5aNj+EhbvvmXqkLBgWzuVSTPSYkEM0smVDXLH6mreHA=; b=UnWNnNZ932zYlrATNl4QT2XtytXwonjJvAiJytEe0azRiPSOXOx+23HhSNuLTY2NxO OzI7tuPHGZ2cYwSEXLQa01k5eWrRy+YtNNCk9S9guimmComKXvqLeD3Z76ggzLahAm7d EKQF9wBnBaEqY1k1tztIF6DPNPSqO+J21OE2CA8LTvPe3czAFspRxXTgWUajIkG6EQUI F9axrC8fNtc/SbKIF6HfKcChKCxy5G18kseKTQ9w/io2WJYjXqbtM8oqgDq+63oZgFmm nrXshAp+LQlvPLaCGyLZbW2GaGqVEVi0T/tFgIA9gLFhMUE422su44KQDPOfdOSy1XNs biQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TXbLB6zI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85899-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fy26-20020a170906b7da00b00a442761c963si52799ejb.644.2024.02.28.16.20.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:20:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TXbLB6zI; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85899-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85899-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3DA071F22A38 for ; Thu, 29 Feb 2024 00:20:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D32B51C59; Thu, 29 Feb 2024 00:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TXbLB6zI" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B7DE3612D for ; Thu, 29 Feb 2024 00:18:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165922; cv=none; b=YxjNBhgfoilh8njZa2akJ8HH8Sg/IvXhnG3T2Po2zP2m6yRYFsfp/ERj3+h0egdpbfTCG3sThN6UlABsc8dBN2SRyz4saOj/CtyjdafENaskvCo7M1VsRbyH55wJgyGgUStfeN1j8C3KpFhyU51zb2FjFNSZCci4uGaEv5ABFt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165922; c=relaxed/simple; bh=yjVC8LCNIc1SkJJNK1huvdVoLuihBnJ8/xrqhZCq4ak=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=eBNxNGGeld5pOFhE5fREmNnLrOcTNkgenYXEo6soIer3xbFTP8ed1YCEjkLbuxEoLyY570l+LOj7PtLtxceExIbqdB8W3fzNV7B5yvbtRpgm+5RvlKfWU4cwAYwlIuGfnEnd/2TMrf/ZB2mO79Z1Ey8AhAPRKZq+8dOUBkXcJ5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TXbLB6zI; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6b26783b4so555114276.0 for ; Wed, 28 Feb 2024 16:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165920; x=1709770720; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; b=TXbLB6zI+0/6+6vGkPpMthp8Vsxif4X0xxUustURUo4Ess3YNY0eTvkuNQgS3r8zrY 6tlSV5TwfJrVlkb2PNv6N2pmo6e/TfPgtzYAVWl5m5j2odk4t4guhryu4+IbHnSLrj92 hrFDri20zNOA+nBXBbIMxat0QybrWMIEJBprb6UIarzcJlbERzpMlijNb4tEY68XAR8I 8Y0vo1TH8e1VI/6Cr7bO2quv70VLeeHdfdzzIugHyLdoblgX6BWnqWhG0mMaOGoicXk+ 16FuSWbkmuopilPWZY2FZiiajN9CaXBAAjN82uasqnF7GQLiYixrnjRl1HCfMF+5xwhq nUYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165920; x=1709770720; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KevBgsY4J/pffn7xcpMTC+4LgPUcMPV9xIrPsMU+9Ks=; b=ChhEais+obh0hyWhmwR/wBPEXj+wGPabVpiyTXS9ZhRzvgaPjGGm+Qm97ESnBK8AnT ukFwJzcTb4mYqROvkeezxYwEyS5j6JWMp30pb2BMEM7+ffZueX0sT5O1MVighKuDh9sX affxzmYHrDFCde5GvF+3sz3vsMJ0VcvPI1GBTQVNPnCCAPko8yYZ7eVYE5skNCoAknlm 2dFF/mj2tbuFs/7avBDcfXX9vrWW8eIaeZpwSz4unS/WLJ7gmaI6SONFOw34sVDcD+jI IO1IHHZWQIG83sRvD6kgVuEzUOOBB8cpCzoy/h0YybFyL34DbBUSbTCBn2r4t5zyi3il 0cBQ== X-Forwarded-Encrypted: i=1; AJvYcCWyeWuLuaPbp0kQiGCPIYQriuZd6C0X1A8+nDZAAzp1EE4VvP5wVOt/NguT4NjUU2zI0P7i1UtQHSSDwiF+AYr547qASHTp6ljfWadr X-Gm-Message-State: AOJu0YwMATyLp8bMP5yFoTaExqreGM92geYBDNvHJZ/9Cvkr6xy4E1OS h3ys9EcWoGiH8sV8+z/BvDjTxtMLu8d5DkwFqHXL3i29Gx/ILO8Vrr9YD6PXz5WeDzRKTjMsET8 l8ycHjw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:e90:b0:dc6:b813:5813 with SMTP id dg16-20020a0569020e9000b00dc6b8135813mr41854ybb.9.1709165920173; Wed, 28 Feb 2024 16:18:40 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:52 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001806.4158429-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 07/20] perf jevents: Add ports metric group giving utilization on Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Andi Kleen , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian Content-Type: text/plain; charset="UTF-8" The ports metric group contains a metric for each port giving its utilization as a ratio of cycles. The metrics are created by looking for UOPS_DISPATCHED.PORT events. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index f11273e9935c..63d46ee1dca9 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, - JsonEncodeMetricGroupDescriptions, LoadEvents, Metric, - MetricGroup, MetricRef, Select) + JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, + Metric, MetricGroup, MetricRef, Select) import argparse import json import math import os +import re from typing import Optional parser = argparse.ArgumentParser(description="Intel perf json generator") @@ -18,6 +19,11 @@ directory = f"{os.path.dirname(os.path.realpath(__file__))}/arch/x86/{args.model LoadEvents(directory) interval_sec = Event("duration_time") +core_cycles = Event("CPU_CLK_UNHALTED.THREAD_P_ANY", + "CPU_CLK_UNHALTED.DISTRIBUTED", + "cycles") +# Number of CPU cycles scaled for SMT. +smt_cycles = Select(core_cycles / 2, Literal("#smt_on"), core_cycles) def Idle() -> Metric: @@ -265,6 +271,28 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelPorts() -> Optional[MetricGroup]: + pipeline_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/pipeline.json")) + + metrics = [] + for x in pipeline_events: + if "EventName" in x and re.search("^UOPS_DISPATCHED.PORT", x["EventName"]): + name = x["EventName"] + port = re.search(r"(PORT_[0-9].*)", name).group(0).lower() + if name.endswith("_CORE"): + cyc = core_cycles + else: + cyc = smt_cycles + metrics.append(Metric(port, f"{port} utilization (higher is better)", + d_ratio(Event(name), cyc), "100%")) + if len(metrics) == 0: + return None + + return MetricGroup("ports", metrics, "functional unit (port) utilization -- " + "fraction of cycles each port is utilized (higher is better)") + + def IntelSwpf() -> Optional[MetricGroup]: ins = Event("instructions") try: @@ -335,6 +363,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelPorts(), IntelSwpf(), ]) -- 2.44.0.278.ge034bb2e1d-goog