From patchwork Fri Mar 1 18:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp88509dyc; Fri, 1 Mar 2024 10:59:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxkyp17yVVEwClQf2O7XBqmlYkofnOzSG5Pi7mrOUEK7pZKVVUiKTC0bKVlynAnfpD1AxwiZ6Ni7KV5l1y1ulzv8yutA== X-Google-Smtp-Source: AGHT+IFfHDe3JfCD3PNso7t+7o4dv8xu8dmApeb00O2pwr0a65XAQGMozswuUpe1MNDw2ynfUMAk X-Received: by 2002:a05:6402:17db:b0:566:41f4:a0ea with SMTP id s27-20020a05640217db00b0056641f4a0eamr1862895edy.37.1709319585133; Fri, 01 Mar 2024 10:59:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319585; cv=pass; d=google.com; s=arc-20160816; b=pwnD9VfAIBwjT6EHLOw2YsLKwnQP/4LAmdjIq2ZNK+EP75eosInaCP97Gz6/YnB1IC +XHoby8ia/33TFBKAGk3yMl6JdL3amJ2zpvBOEL+ivLbYqqrs9ts/ETDpPFNRkX25aYC W7hp2wSnVoH4JSmy0W4NO3lIgKdLCbO6SZfK9ZEb7o7d0Wjn9wp0CnELUijiQAhMdhFE aoHIHyhMAdZSNDxqEfehci9WrNsf0l3NmwsVKOCShyRG/tOesnPNFpuprLkuZhHya1Rv XEEo1aXeHDi7PMG3XY0zZL5A4yJFPKUPNwPuzbHBE52I/hWhOG3IzyHtptulvVTTcDlQ /HqA== 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; fh=qMF8dXFQu0Oteqj0I0WVb/Ki0ft+Gvo22h97g1bnoFU=; b=snoiBOB8SU2Z3DaTnLjJCLeXTECY874zYEL7l1zmoGPLyg2pyGEelMNRVTrODDv0ws Q7AJm7OMGwBiJjykZAoTFnbxt89xzaguiLBR3hmpjVGADI16VRHUPGaNDSkfzCMr/E2r MIou9ABGTQFpNUrT/6IZ6YKRdY0K/Oz2YmAKL78P7S28rzh+zmffXktJabEcJeKRomG/ 6U/dEDM10ruFHoETKsJNn0ktkk7x4s8Ws8XucjuUMi02jyb/QfE94oOUzYo3lXyGhXSE MAr0I3E2glwp0dwLDWF365Z4yggNrmokjoNHmDXfNiTC4PWhPTaW88eGjxZyzuGN9eHr HNFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="L4nbwjO/"; 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-88971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a22-20020a05640213d600b00563de7615c5si1635460edx.624.2024.03.01.10.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:59:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="L4nbwjO/"; 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-88971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88971-ouuuleilei=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 BB2B31F26D23 for ; Fri, 1 Mar 2024 18:59:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD4A53A268; Fri, 1 Mar 2024 18:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L4nbwjO/" 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 82E303D54C for ; Fri, 1 Mar 2024 18:56:40 +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=1709319402; cv=none; b=LXfNiOhRVdobecCa1UHSGdMvC6dIfAeY1Eujt+N+O3RMoZzUwJHQ8D/eBwxSr+ZCHELeOnfUwBZFpegtp+Ui89oOieLKukWJQFyBDZXwr7nsBBPvkL5hHytJlvU359iqLqHkJ3lio45ggjtsTwtn13d/zGR50CVCIV4suFZ2VDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709319402; c=relaxed/simple; bh=ReQNa++yN3cks/OeqEJawBQb3bmDZtEAQZ6F6yRpdYg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Vak3ruZdSLpwXX02AFhpXyHDCkZy9i5anmi5Otc9BA5TCNVCKd/6yY9l18odW5QZorGARxQ0E+TEOv+ZMMz+I6G/V6A9Quv/1Wnil5grjNQDYBpUDO6okTbgaNzKu1y0ZtGJ82SH+fz6rS7F1NbaAGvOK41lv7a1HL5tOphz9Ww= 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=L4nbwjO/; 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-5ee22efe5eeso42109697b3.3 for ; Fri, 01 Mar 2024 10:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709319400; x=1709924200; 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; b=L4nbwjO/VhKmqGrtuMZOWgx/BX9nDeeT5vnXBovLI/TryzoT5hPLRoYL22lKsArbyn nmgI5GZWOqK2eAxs1Dxtssz7Af5fg8xBhbhNe7KG5wCgQqiRDfBqI1VzyobhjdAkbSSj 11rjv0YBc5ROdX/+SX5LscEGAD/Oxus2KlV2+Nrk4GSEcgOEhNRYAyYtPPBgvgtMluVl Y/BlRCJbTVDGlxadWyfI+ENzuBaGnqZFBxZQgCGOrTZXP2Wb/dYhKKQVmWINfwBML7zj DJD1i0w3i2nxg5RqZTV+/ZkUcjXBfNqLAt8e/1/xgtzp8YABZyvtsRNn4Dyqr3/ifOiY LgZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709319400; x=1709924200; 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=iy3P4uSPJWyjA65jWAIGgY8FhfJd7Bx8GKL8ekkcR6Q=; b=r9XY7Mm/Ecefuv0F7rLhM+R6sRr5Z5Vnd6BxsMNLBFA3d94O5GYS50JgPgL8IkIsN3 p43ttrRx6cg983K7wogeRbShU/7T2Wp1AjI0KposzOCZdyWRTeBUYQ8Urb1G+O6VqFiU y7Z4oJk+Zgy+NCtPhcrxKiMJox/ufI8mEMyoPwS9piG3h/GG9SoolrbJO2Knj4d08BvN sHu+uR0wLPM8809aFQhW/U7gPrk56e7M0kA8+sApVfXXjNZy9PWGibrfp8NO+vx7yuUC pG/kUwvO95C2eeQhgqvMdlNc8atEYa7qHybrf8syYLcEZfqjb32ULpT9uFIMWrrQ1ezs +fMA== X-Forwarded-Encrypted: i=1; AJvYcCWeqMQd3wthCGhRZe2VbYJtS83fowPHPaFqOLEi9iP9yFuuPCakptAJc52dDON9iEJQRdsCbKa/uNm/tcCUqeyj2JipOzWeSFHFfRmD X-Gm-Message-State: AOJu0YxGd34pbIc8mYSBSHrlh0AVD14BEo+OsnuMhda3eAcBx7P7j8su kGsM//4om/y7ESPLK60ohY2BtUI2o3U8q9wI+dFMi9s7mn18XO8D5Z33JI+jnv+m/WpF3ql0xat xIJ/xMQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:3387:b0:608:d499:3439 with SMTP id fl7-20020a05690c338700b00608d4993439mr467407ywb.7.1709319399748; Fri, 01 Mar 2024 10:56:39 -0800 (PST) Date: Fri, 1 Mar 2024 10:55:50 -0800 In-Reply-To: <20240301185559.2661241-1-irogers@google.com> Message-Id: <20240301185559.2661241-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240301185559.2661241-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 11/20] perf jevents: Add ILP metrics for Intel From: Ian Rogers To: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351493326098448 X-GMAIL-MSGID: 1792351493326098448 Use the counter mask (cmask) to see how many cycles an instruction takes to retire. Present as a set of ILP metrics. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index 061914834cff..6f6d1cdf6649 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -272,6 +272,35 @@ def IntelBr(): description="breakdown of retired branch instructions") +def IntelIlp() -> MetricGroup: + tsc = Event("msr/tsc/") + c0 = Event("msr/mperf/") + low = tsc - c0 + inst_ret = Event("INST_RETIRED.ANY_P") + inst_ret_c = [Event(f"{inst_ret.name}/cmask={x}/") for x in range(1, 6)] + ilp = [d_ratio(max(inst_ret_c[x] - inst_ret_c[x + 1], 0), core_cycles) for x in range(0, 4)] + ilp.append(d_ratio(inst_ret_c[4], core_cycles)) + ilp0 = 1 + for x in ilp: + ilp0 -= x + return MetricGroup("ilp", [ + Metric("ilp_idle", "Lower power cycles as a percentage of all cycles", + d_ratio(low, tsc), "100%"), + Metric("ilp_inst_ret_0", "Instructions retired in 0 cycles as a percentage of all cycles", + ilp0, "100%"), + Metric("ilp_inst_ret_1", "Instructions retired in 1 cycles as a percentage of all cycles", + ilp[0], "100%"), + Metric("ilp_inst_ret_2", "Instructions retired in 2 cycles as a percentage of all cycles", + ilp[1], "100%"), + Metric("ilp_inst_ret_3", "Instructions retired in 3 cycles as a percentage of all cycles", + ilp[2], "100%"), + Metric("ilp_inst_ret_4", "Instructions retired in 4 cycles as a percentage of all cycles", + ilp[3], "100%"), + Metric("ilp_inst_ret_5", "Instructions retired in 5 or more cycles as a percentage of all cycles", + ilp[4], "100%"), + ]) + + def IntelL2() -> Optional[MetricGroup]: try: DC_HIT = Event("L2_RQSTS.DEMAND_DATA_RD_HIT") @@ -604,6 +633,7 @@ all_metrics = MetricGroup("", [ Smi(), Tsx(), IntelBr(), + IntelIlp(), IntelL2(), IntelLdSt(), IntelPorts(),