Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp170156rbe; Wed, 28 Feb 2024 16:23:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVyryjeV9UzU+El90DqnH4gN90lDoKi36zJt0VuGSfDQctCCXIyvBtILTg/A2fmDksFyQQf0WoAv7LkzYd6E6tdS8EqqVnPKffvwo6MCw== X-Google-Smtp-Source: AGHT+IHuD3t/+YDcO/EzNCbt2PZ6OSkEg/gGJm61g1cVXWanCeAcImsP3DA5ZT1RWB4V24JH5CJJ X-Received: by 2002:a17:902:7045:b0:1dc:1df6:48a0 with SMTP id h5-20020a170902704500b001dc1df648a0mr438625plt.66.1709166180171; Wed, 28 Feb 2024 16:23:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166180; cv=pass; d=google.com; s=arc-20160816; b=csP8kq0pEKrzU/9C0zMJTdMfjBzpxzWoLMs44Bc81Oy40ge5vTfeVHq/CJ31O9CRkq zpwpP5HmZHWGxviqLAfk+0jQgP0ZDvCJRwt9E6nyJVTHvFUqZ0nUwya7n/t+eeGVYlnO cD+gsGrIpHuh7yqK4ErsqqNbvMKG2XRlklm0Zk8LymHxL2Kiww2bR5urMuPOVu9YmEFO QpjgjVXNYLapagw6cWOFeTjEZtCsrocxqcE3i2FXQHIePS2aZkYYp/eaCowdoB2qVuDi 1NMRp/YWtJyCPsTvTOtJwlvYLe+vyS/oS3baZyFOb+KFjkxWZvr0yiuHYAXWnRFXxaNB 6fKg== 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; fh=SOEz11O+9ti5oznWjGihLptms8eMn3v051Qi02HickA=; b=BAhoE+A9uUB0BsJNs9ktM7GeV8eJBoO25jeSjvtaAjN+VAT+o6Z9E5DhjX0zAgoV/j KNtCcv6ru0YRD9RVAhCEr40hOB/W15xKcaU1EBwvJH6NqAG20cZgTFuDWaT0uc6PryUq LvEOnjbaisaiSnEoJ8rtEgB/QblvAdM6KYPo1TZixPDLEFJSPT/7gKCyOIJRrmyZUfzm pjowbrhNAo9kb06a3O3oNxgXbw//X2o03Su18rzU7oxZyt47BXxhmNUdoXjzLMimB72F Bm54xaq8S1BiFXd9KMMgCGwtOpowOCzb2p1NwdLfh8iA/YBRzZJMkheGHh/aNbFsnSGz ap3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RR0zNOB8; 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-85901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z8-20020a170902d54800b001db8cd7492asi143023plf.86.2024.02.28.16.22.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RR0zNOB8; 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-85901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85901-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CCAB1B25380 for ; Thu, 29 Feb 2024 00:21:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C47157899; Thu, 29 Feb 2024 00:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RR0zNOB8" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 9794F56B88 for ; Thu, 29 Feb 2024 00:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165927; cv=none; b=APDdpS37ho+mMleXaKR1DiyrIQNnYMb8YXRpaOXB1gBfME7tAGMS+BlE4lSMO4EFwd62JsKF0NZGfSCpJlKXWRFN7ir+ZuxPxEX9zGibj7/j08FjFpFNf86bLBJtuEk9k0UeKEEK9LGlZj0ifNZwCqe2WS5QqPZYxXXKJAaoL+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165927; c=relaxed/simple; bh=UjJzZnr6R5qqlP0DPOq4yMkAe+ITwoRcLwikAmtf/Vw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mflPjHg7I1dol5iy0SfrinEk29AuM1OzMjUTru4/HiSvpaOquFZIrEASZdWBsv7dPNzxC3u0GFq9338bswOM7TfUV8XvIshm8TkT85t50oKdGf4OsxbpxSo2aC2VemQdxQAoftDm/bDHgeFTmyYB62A1tG74BycrpBTUjSxu+Dc= 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=RR0zNOB8; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-60904453110so4401937b3.2 for ; Wed, 28 Feb 2024 16:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165924; x=1709770724; 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; b=RR0zNOB8QeKKDr9zT4ymzlehbUTq4Ui15grlGIksHGrCfIyyjAOYOiJOt4DcJh6ajy c6XTjZVtqxJrmvEs6J5P1xYa+Brie3id9EWJhH6Xan+7DjDFe6gkOz4RdPJnsXIXF+YG SpNn25aecQvBbZKxdv9/kbSGDYI/2mYDHzVz0a/CitmuVtZG6ZgOiRstDx9hY+7B4fzE 2A9ufSdW2NwyB9YQyEKK0l/iJm/lOl0uQgZOEwaJrueL0U+0LkBGeL385WQw3/+WqHS3 kc2iK5c0Kqk7Zp/d1gfLPaFRtyJFTn+Zg0XCV+J0ikkDTJK6oF7tLaMM9XrYwGo7s5i0 Cbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165924; x=1709770724; 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=LvXKnLjoS9aTofIk7NbrGOXPtcvKKSLx7CVRKwsuqGc=; b=i23guB+MTQUrGIH/1XUJnId3jNu+3QPVoiRxCRovHr4aFuDny7Si6YUSbjjGtIit8W hjasm19Klvb0F+3kbW0o9rd5NQ8uHfDda1X3jtd4rv9vkeqTWoRoo1OTvr2bvH7XFQt2 1RNJPRapuHpyrMiiLmhEE7eLi70dRYAaocDP70zxygA4rG7iEdtZ+L6/w7VhzY5toVDa yIQzSyoU9o+QFrA//1nTthKhfpyO81OvMSGHCcb0wfpm6ca+g71Btv0YoJ96Mh5xIv05 zb7HaAMprGALQLZZlyirw0NK5YDsnQJq5ESOXbmkLH3neTLwIuFGbRLgnkhC92l7pEJB 7whg== X-Forwarded-Encrypted: i=1; AJvYcCUpXj5yDoC96P44hiog6UuSs+b+7x3yzAWDxBeA2t9mJyUN4LvF1kO9DRJkD8bTkovTlRISTqJgVg7QLqriqShLFEyQkIURK6k65Ji9 X-Gm-Message-State: AOJu0Yw8Men9zjQzDg+ZoeMVCnFsBoRaJMJnk0LX0zPq5A0zt9gk88Fk raKsq8nou2GxX1ophHCCS1GpB4jtLEixjtfxBtIpSjL3VmBc49fb1++UZlvm3X8f1aGsdzpnxQv lTBrbDw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:690c:a90:b0:609:185:67da with SMTP id ci16-20020a05690c0a9000b00609018567damr155415ywb.10.1709165924681; Wed, 28 Feb 2024 16:18:44 -0800 (PST) Date: Wed, 28 Feb 2024 16:17:54 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-10-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 09/20] perf jevents: Add load store breakdown metrics ldst for 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" Give breakdown of number of instructions. Use the counter mask (cmask) to show the number of cycles taken to retire the instructions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 86 +++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index d22a1abca8d9..0035e2441d6b 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) from metric import (d_ratio, has_event, max, Event, JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, Literal, LoadEvents, - Metric, MetricGroup, MetricRef, Select) + Metric, MetricConstraint, MetricGroup, MetricRef, Select) import argparse import json import math @@ -514,6 +514,89 @@ def IntelSwpf() -> Optional[MetricGroup]: ], description="Sofware prefetch instruction breakdown") +def IntelLdSt() -> Optional[MetricGroup]: + if args.model in [ + "bonnell", + "nehalemep", + "nehalemex", + "westmereep-dp", + "westmereep-sp", + "westmereex", + ]: + return None + LDST_LD = Event("MEM_INST_RETIRED.ALL_LOADS", "MEM_UOPS_RETIRED.ALL_LOADS") + LDST_ST = Event("MEM_INST_RETIRED.ALL_STORES", "MEM_UOPS_RETIRED.ALL_STORES") + LDST_LDC1 = Event(f"{LDST_LD.name}/cmask=1/") + LDST_STC1 = Event(f"{LDST_ST.name}/cmask=1/") + LDST_LDC2 = Event(f"{LDST_LD.name}/cmask=2/") + LDST_STC2 = Event(f"{LDST_ST.name}/cmask=2/") + LDST_LDC3 = Event(f"{LDST_LD.name}/cmask=3/") + LDST_STC3 = Event(f"{LDST_ST.name}/cmask=3/") + ins = Event("instructions") + LDST_CYC = Event("CPU_CLK_UNHALTED.THREAD", + "CPU_CLK_UNHALTED.CORE_P", + "CPU_CLK_UNHALTED.THREAD_P") + LDST_PRE = None + try: + LDST_PRE = Event("LOAD_HIT_PREFETCH.SWPF", "LOAD_HIT_PRE.SW_PF") + except: + pass + LDST_AT = None + try: + LDST_AT = Event("MEM_INST_RETIRED.LOCK_LOADS") + except: + pass + cyc = LDST_CYC + + ld_rate = d_ratio(LDST_LD, interval_sec) + st_rate = d_ratio(LDST_ST, interval_sec) + pf_rate = d_ratio(LDST_PRE, interval_sec) if LDST_PRE else None + at_rate = d_ratio(LDST_AT, interval_sec) if LDST_AT else None + + ldst_ret_constraint = MetricConstraint.GROUPED_EVENTS + if LDST_LD.name == "MEM_UOPS_RETIRED.ALL_LOADS": + ldst_ret_constraint = MetricConstraint.NO_GROUP_EVENTS_NMI + + return MetricGroup("ldst", [ + MetricGroup("ldst_total", [ + Metric("ldst_total_loads", "Load/store instructions total loads", + ld_rate, "loads"), + Metric("ldst_total_stores", "Load/store instructions total stores", + st_rate, "stores"), + ]), + MetricGroup("ldst_prcnt", [ + Metric("ldst_prcnt_loads", "Percent of all instructions that are loads", + d_ratio(LDST_LD, ins), "100%"), + Metric("ldst_prcnt_stores", "Percent of all instructions that are stores", + d_ratio(LDST_ST, ins), "100%"), + ]), + MetricGroup("ldst_ret_lds", [ + Metric("ldst_ret_lds_1", "Retired loads in 1 cycle", + d_ratio(max(LDST_LDC1 - LDST_LDC2, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_lds_2", "Retired loads in 2 cycles", + d_ratio(max(LDST_LDC2 - LDST_LDC3, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_lds_3", "Retired loads in 3 or more cycles", + d_ratio(LDST_LDC3, cyc), "100%"), + ]), + MetricGroup("ldst_ret_sts", [ + Metric("ldst_ret_sts_1", "Retired stores in 1 cycle", + d_ratio(max(LDST_STC1 - LDST_STC2, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_sts_2", "Retired stores in 2 cycles", + d_ratio(max(LDST_STC2 - LDST_STC3, 0), cyc), "100%", + constraint = ldst_ret_constraint), + Metric("ldst_ret_sts_3", "Retired stores in 3 more cycles", + d_ratio(LDST_STC3, cyc), "100%"), + ]), + Metric("ldst_ld_hit_swpf", "Load hit software prefetches per second", + pf_rate, "swpf/s") if pf_rate else None, + Metric("ldst_atomic_lds", "Atomic loads per second", + at_rate, "loads/s") if at_rate else None, + ], description = "Breakdown of load/store instructions") + + all_metrics = MetricGroup("", [ Idle(), Rapl(), @@ -521,6 +604,7 @@ all_metrics = MetricGroup("", [ Tsx(), IntelBr(), IntelL2(), + IntelLdSt(), IntelPorts(), IntelSwpf(), ]) -- 2.44.0.278.ge034bb2e1d-goog