From patchwork Fri Mar 1 18:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 209024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp84084dyc; Fri, 1 Mar 2024 10:50:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWx6IjCufBq6x5ZYaya8ftbdo14c0mXdoiDf+TsHF5+jX7bkNrBq7ZA9tsAgdyJdev6CXTXhNX1Hncv7LbmkO1NCbrxbw== X-Google-Smtp-Source: AGHT+IFo5ZWEd1cUF1gA4ZTNFRHXkKJgbW7IlVECyNA3g7iqjF37IilWiIrQMPlPG13qX744od57 X-Received: by 2002:a17:906:4547:b0:a44:7cd8:fd34 with SMTP id s7-20020a170906454700b00a447cd8fd34mr1659288ejq.37.1709319056340; Fri, 01 Mar 2024 10:50:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319056; cv=pass; d=google.com; s=arc-20160816; b=WqlRjt5zAEz0Z+0G/CocPWfJdEE/n0IZ5wQWOXTb//52ZxVk80W96t67k05p2pY2sW Tk7e5vf2y064dBd5E73IhlyDAM2dd2T+goxFrMguBgx6Q3Vt+3jhO9Hcj6CYqQiAb3S7 7yuFL0wS/4Hs63v0YCIZSvdLtjoM6ely/VUyOLeH7Ss2A4MI2hiUw8dzLGj0bNZAmHBR 3WN25uRj6+aGrfgyZYPFJ1L7hj1EVgl/qHDEtTVDxxCXA5PBn5avfBp7av/PMEm631gB /K/pI8lBnQ2HFKfU7EsgGOg81SL/UCdKuKDoVejWAGEaGRvtr/cckL1qJqiSbGu+qSMK E6ug== 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; fh=NfMeFYVZ5RGXtoZtwv9zK9oVr6w0xIC4q4msOKo6esc=; b=ALEdhmg6z3PvPoGA++GOB34iH1FJsGTIJQVBXpQpTcHU0e3vEmcKVdmGgG1D89K1lb +lewLdhn0D2F0xLFqjoVR+CoXFIVIu1deCHrjbEQ2OezJ9BzWtf35jUG6xh5g1fW6zFp lPSbubwL9qsTzOMhlb8ksDJVm1kSHKqJec8JRUiUT2gtyeTZVPhXrzXtnK0DwHpe6Xah u8EJb0hdnXoPBjO/C4fLOwUmO85KICHS6AylXKh4LjjssuFXlWPRM9+QcMu+QHrjA9qE sXUOp49QH8gMWG5tMQ1JPJtjLlTbDvzfT/uPA8I2ejPgJTkXrx3u88jXgrMdl1jXAbAr HapA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hGOARVnE; 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-88948-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88948-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 m11-20020a170906234b00b00a3fc622b1a8si1583914eja.595.2024.03.01.10.50.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88948-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=hGOARVnE; 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-88948-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88948-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 C9BEE1F26CB5 for ; Fri, 1 Mar 2024 18:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 673CD3D982; Fri, 1 Mar 2024 18:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hGOARVnE" 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 E5D2D3D3BB for ; Fri, 1 Mar 2024 18:48:12 +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=1709318894; cv=none; b=JODEdumDYj1/PSPdIDVOpsCuGTbDNL1yDpaToA1BMznlHDZhz3Y8cpWXSz5KjaNjTLqKXDAo6K9S/wkKwIIvJig3KziYnyv/LoXxjvznyNR6tjnXehsSFo4DHsm4cPfuOMigq7olJBk2/9M2rJIec07OE1xvMOTKOor3KakAaEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318894; c=relaxed/simple; bh=rdT/e0Jk04uz/hli1au/7w9zNoOK9Gsygo85Wow1ix4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=oA0ow3TPVaBMDeW1r6Y0UCCV9ehA5QX2haqX/lZ0fcg9vhcSR8BJ4AZ7NSnELybWzai3TrgxaHvN2xFSPeGcM2EqbgdlVHTw8ZiSFMCHvAnWyFusDGOXVLb1yZ8ew/Xj7PgvCIIzLawaqcD7onIiY3+hjc0kNAS2JEynJaVWSm0= 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=hGOARVnE; 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-6093f75fc81so43465157b3.1 for ; Fri, 01 Mar 2024 10:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709318892; x=1709923692; 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; b=hGOARVnEr5xFFtpzaNPWOObxPn2dAndkDKpQzVtrO+tAoB5NZ2q2KHAbuDwAS3cI23 aqar3Vsrzl2gRropVv0tX1HlfF1ykioTUjcLvzcXBx+kNPaNrJack3kyEaZPmMDuPbcP JatgyUP6ooa2qXNltuvHXbXLFla4ZOktfgJkhPkLV8wLecHSqx8MSoZHGYaiKmOdwOlB C2Vx73CmXSxvYLCEoRDmzbW72NeNc135uB0xYlYHbSS00SFSr79Tj0VIrrGFEz5oZdn9 lCHxg0FQtA9+oN4E12lC4NrwMRr61RjTNOoehp1+BJHaIlv2dL0h7p4Zla0qup36cXWo m3iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709318892; x=1709923692; 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=cHahQF2BiK1eIw2Re/KcTjpVIHmS0xMmp3oAqD999cA=; b=AwQUwDGzaqiGJoZ66v7UOic0CAcPHvqoTgqSS7B6mdVelH3vTvxKn3ur6DlV3dXOws Fy9z/gd8c+YI2QQVwencOi1Ngg0fUXTkA23N1ux3HuCLath6JS0dCbXWYX9lTFzqifTz esd7oHF1ZCVP+4k9IaFj9iqP12g74CNTC3AZ/g69v8DkwB/C2L5am47E7vnTpVqeKdu9 WGbwdGTCx06B135i0g9uqQAhPm7Vv9f+zyDZy22v9MsbXdCPZLO0/oQ0+aGdFybznpcV eQzCFVGkhEpy/OMhghOakPHzxaOIkYCBGvZD1kW7GoDccfFnyBAKyxhXKuuHLvAgwYWW SFUA== X-Forwarded-Encrypted: i=1; AJvYcCWleeCm/+FtKwZhM17LD2/rWOJyIO+5pIsTH0HAvpUnuksORMOD/tlV8qTjzY4HXuf+bXKlvyCo91jBkZh5sSwDRGIBFigm4bRn+DMp X-Gm-Message-State: AOJu0Yz7FtHvyqaKox7pVtpmEmPB673blbpp79kE8OAuIyRRAuzXq6zG Fr8yMMq/xtXARgTlTBuC81wY3WWOp5HFIsS2sihP7RDIFx7i1R+6gs5vbmqzCDTukT0IupkIdD0 AWKHAXg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:690c:b15:b0:608:e4fc:aada with SMTP id cj21-20020a05690c0b1500b00608e4fcaadamr631228ywb.8.1709318892155; Fri, 01 Mar 2024 10:48:12 -0800 (PST) Date: Fri, 1 Mar 2024 10:47:36 -0800 In-Reply-To: <20240301184737.2660108-1-irogers@google.com> Message-Id: <20240301184737.2660108-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: <20240301184737.2660108-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 11/12] perf jevents: Add ILP metrics for AMD From: Ian Rogers To: Sandipan Das , Ravi Bangoria , 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792350938777804218 X-GMAIL-MSGID: 1792350938777804218 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/amd_metrics.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 6b182a9bbfe5..91f323c1a149 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,35 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdIlp() -> MetricGroup: + tsc = Event("msr/tsc/") + c0 = Event("msr/mperf/") + low = tsc - c0 + inst_ret = Event("ex_ret_instr") + 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), cycles) for x in range(0, 4)] + ilp.append(d_ratio(inst_ret_c[4], 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 AmdDtlb() -> Optional[MetricGroup]: if zen_model >= 4: return None @@ -560,6 +589,7 @@ def UncoreL3(): all_metrics = MetricGroup("", [ AmdBr(), + AmdIlp(), AmdDtlb(), AmdItlb(), AmdLdSt(),