From patchwork Thu Feb 29 00:15: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: 208091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp89062dyb; Wed, 28 Feb 2024 16:19:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVixv4TMBEmBWW4JNlUqkFC0x6cRVQkzMtJa+MiXpI9yZw7JFo5gfVD32mLuG7UnxpBv6OWUWr/ZAvGr5pDXRWSMXqpA== X-Google-Smtp-Source: AGHT+IFh1pTDmVWiKt4ux1Mrq+oxnAQxPly3K1yFv2lcyFx9czlxqNH8ahdLIX1r/Ha10ugr/pyW X-Received: by 2002:a17:903:2350:b0:1dc:66da:d21a with SMTP id c16-20020a170903235000b001dc66dad21amr553853plh.28.1709165957243; Wed, 28 Feb 2024 16:19:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709165957; cv=pass; d=google.com; s=arc-20160816; b=Dz6RiBrP2gP1Fq6smz0kf9n+oJgw87DUYnW6PKbN+LZ2vbr0sY5zgTpVMErUlDWLig EYuSEuzRWRJEhUEimu4T9TUbLoc2wOCT166EttsKVDhktwY8TjYR8srkStrkU856Q4Rx YahYFJpXULeSB2DDeug0V/DvXH08XcS67UiQC8FzsHdzr+2wMEZRwbOFxye5Bh8VIkmT uldsZc0JYvLa/jX36jDxL+iG1hObd9u8GdpI+zoEjzDdZ5SO+3HA4jFZHzdvgQ7JkJcL 4qv8NN63LrVH6o/ujebRRcmn7c2H6VVx59bdb32wAi71bf6BcpjpoXNMQuPNHpIeEDlE f+HA== 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; fh=9JFLhk5TWj+zf26RIZuAduwNsozD3c0R/TYAVyv9FKk=; b=Y4VhHQTxhF6sAMx3LEricN5+4Lg/M2xmHXb9cuIIvqMunlUPqJ1G6DdUSV4obvgxb8 5p7KSjlRCXHeinU1Z9Cka/f65pWOH6TD5W4sbSdquXuwOO1nCBdq1TPMyKFCqWKD7V+I Y4GNSPxkHVxi11hTPx9hT6Trp460Q4RrY6Aj/Llu6WkpSw31L6pcMQ1gxTFOetfBZ5aP 9alnd5kI64oJC+SUv9+AfzZAJEFIBLc1LkUDTVOPHHSxP3+xlK0a1sM9wVpFbgtOX1yU fgq6/w6w1UdhHpcqzyU6kXad081FiCqzUxQiCa5aLmETQMV4SgDdpyaojREBnezL7s9D mfSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgHzwcdz; 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-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85889-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p14-20020a170902ebce00b001dcabe7a18fsi117253plg.126.2024.02.28.16.19.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:19:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SgHzwcdz; 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-85889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85889-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 89944288D52 for ; Thu, 29 Feb 2024 00:18:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B0DE5A0F2; Thu, 29 Feb 2024 00:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SgHzwcdz" 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 C068B5731F for ; Thu, 29 Feb 2024 00:16:11 +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=1709165773; cv=none; b=APEaKQB07PPvDEFnWvcxh+owu8QZIDIKDqBm0ea4Apjwv4EBZ5zbos0+TslTlGPN5QeoOGL7GGxSItKpg0xtLuPvNPIpgtQlW0v5MyMR0IZWxeTdPIbUayCm9QC1dqifGZKPZ9pvb+PkiiG3AYbcTYIYoBThTxowBaGQN/VPAD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165773; c=relaxed/simple; bh=UwkjYK+U+f8LwVeVeyTQSJU60/nxqzY/uXtXOkioAuY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=k3h9OYmYGTaORV9cxg9PINf3tSRPzzozgS5WN9f1JmFFhoa1cHWx5pxwqs/NxJ2F/STO2NACpsE/A9RWqK586J4h3UP2Wza0KMFdYi8QYe7U5u0Ez8yTYLUbMvEBqg9nVWupfP5WGtHvOj+tRAc2Q4f2sC2/YUfd+5j4M2Rcqxc= 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=SgHzwcdz; 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-608e88ca078so6106957b3.1 for ; Wed, 28 Feb 2024 16:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165771; x=1709770571; 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; b=SgHzwcdzxtbE3LV6tT49xoXoF0G1I3qHqCSHLstVUpKDA+rPt4ij6Co35vmgEqJ3Es pWuAv0zcTZza77OUKteWVcOhmzba/T2EquJ5uwWJZYVt+oZWmPBGWYQW8YnNAqMfS55M a5+xtLy1f5yT5wBXbPFcqbL7/N5o4KfyOpfQ7fcpvDoG207nZvptqPD8ByhfMcGtcdX5 nizVyuRg8Bo+lhNRTo8s1H7AeWjDEomblTGatvnhM8yJoQqh2hgBtZJTgLXeflXkN3ch GsUX2JoBM/7CupIf/ua8sTt4tenamFTHQwHKPlEhxYPsqhaNGyFUofIeBF/JJGFdqWnf wcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165771; x=1709770571; 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=rDmb+1G4FeL2VOjrPNtrbYg/sNUzgE2lO0wYF9ntEME=; b=bZ3DVD46aHhaWiFIdH0DSYd4M86Ifjx+w68JgdqMuMXi53cuDUXOcz5c15P1iLlNkT jZUPgbqYnjszINkou3x/GBABlMuLvssKwZdaAN7RHoW3l67rMQ/cFvHxYU2sXrXM23Fk Nyx5KLB6B4nhoNq2zCIx3zXZ2HME1hsths9p4R6eIFOsyRBec3rWAE8tgv9hYIcvbdhg LJ2XrO8YjvzIaUjtgUxfUC7fyrkvFLX+eMWZWvk866Zez0RAAcUDPbJYPgA3eNd7Utoc t1g5FRHXrsQicJboAK0nBdNHXkKR3aBQb69vk0ElnwH1M1WnJ0pDCDpnxKHe2TpAJheN Pkjg== X-Forwarded-Encrypted: i=1; AJvYcCVnyx/r4s97lyYpxJFnJLcAoPqTk30dJm7OyarxsWUmRy/jlCBmh0sfKIHQpV6deAnbJPMR//QG0I0dlRtKgV5xv9qM1L5I/vXtmifI X-Gm-Message-State: AOJu0YwzN2NwFzDkYa2L7V+4sgtTMsmGB6ikK4HJr2mhACeLZf4ntA3D 5mEm8A7kvHLhOR4IBYWEtKx5VF5ru2bIKFC2o2lomjhmgPK5kufzl493pKaGsZW9TJ6h3K2U5yA f6GllPA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1c9:b0:dc6:cafd:dce5 with SMTP id u9-20020a05690201c900b00dc6cafddce5mr209364ybh.12.1709165770873; Wed, 28 Feb 2024 16:16:10 -0800 (PST) Date: Wed, 28 Feb 2024 16:15:36 -0800 In-Reply-To: <20240229001537.4158049-1-irogers@google.com> Message-Id: <20240229001537.4158049-13-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240229001537.4158049-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 12/13] perf jevents: Add context switch 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: 1792190402965782129 X-GMAIL-MSGID: 1792190402965782129 Metrics break down context switches for different kinds of instruction. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/amd_metrics.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/amd_metrics.py index 91f323c1a149..377ce413d051 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -125,6 +125,37 @@ def AmdBr(): description="breakdown of retired branch instructions") +def AmdCtxSw() -> MetricGroup: + cs = Event("context\-switches") + metrics = [ + Metric("cs_rate", "Context switches per second", d_ratio(cs, interval_sec), "ctxsw/s") + ] + + ev = Event("instructions") + metrics.append(Metric("cs_instr", "Instructions per context switch", + d_ratio(ev, cs), "instr/cs")) + + ev = Event("cycles") + metrics.append(Metric("cs_cycles", "Cycles per context switch", + d_ratio(ev, cs), "cycles/cs")) + + ev = Event("ls_dispatch.ld_dispatch") + metrics.append(Metric("cs_loads", "Loads per context switch", + d_ratio(ev, cs), "loads/cs")) + + ev = Event("ls_dispatch.store_dispatch") + metrics.append(Metric("cs_stores", "Stores per context switch", + d_ratio(ev, cs), "stores/cs")) + + ev = Event("ex_ret_brn_tkn") + metrics.append(Metric("cs_br_taken", "Branches taken per context switch", + d_ratio(ev, cs), "br_taken/cs")) + + return MetricGroup("cs", metrics, + description = ("Number of context switches per second, instructions " + "retired & core cycles between context switches")) + + def AmdIlp() -> MetricGroup: tsc = Event("msr/tsc/") c0 = Event("msr/mperf/") @@ -589,6 +620,7 @@ def UncoreL3(): all_metrics = MetricGroup("", [ AmdBr(), + AmdCtxSw(), AmdIlp(), AmdDtlb(), AmdItlb(),