Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp170240rbe; Wed, 28 Feb 2024 16:23:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9N1usjs2Cf7+DT5f9fhiX2f9zUpXVLxM/AciCGnStCid8wMXPcFxMPla5VJyqNOHpMNEyXkNyLOxrO17wV78aHAsN6vZAqmUZv38qDQ== X-Google-Smtp-Source: AGHT+IHy8s6NppF2f4XZPm8jBzKAHRjR0TQZJ/A7mIMlnhPWAuM8L5YMHZ9bf+OA1mGh1yMpjQW0 X-Received: by 2002:a05:6870:968d:b0:21e:212b:d141 with SMTP id o13-20020a056870968d00b0021e212bd141mr508263oaq.19.1709166195059; Wed, 28 Feb 2024 16:23:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166195; cv=pass; d=google.com; s=arc-20160816; b=RUgJ6VoErq+QdLAUTLIUFkiTUkKbJhENOwn+tHJdybjEB9cY9SRvJ+XVDHf1Y/7HR5 5oNKoabit7NhkGMf4ym48zrHXhgppnX52ZV6+xNQeQO8HVex5Vm6ZkEh0SpDWmr6Ss8y kTqdHlZDip80yJoLweuz7E7F6zJC3UR/G0jqkFsT1rUPiBf8+6fCZwPHWjubAGwfjLS2 HRnXKRDP9MQ9cFtFSwXSGsF3kfzTPv9ntfiXA3zVGpUQNjL1/q25Wx6I0ukkJVQx4naH KkGd4qLGlfRFG0bmmmXn+dHjKVrvYCRnImywPpJ7iIUZjU++YTMjXrV5fbg3uBZHxACV F8eQ== 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; fh=h3JJ+yuo4jbvp1F+/QIzK7hM5I8D2NXT/Q+V5EhQVGk=; b=X9yZjORVyYE2vHE6yp6LLdJ3f1fenJN4V1rn6sMrgd8GmJJooiAU1sfTVQqK0HdbWr i0fmKuTxkyE1N2E3YxGnkXdgxkOi8BUTh8C7FcWJcXk2fkc16oIcCmImOmu5Deq8UNnA N+2M66Z0J77TRb1BRv6rMnFN6+RwdZRX8K+UKabBIchD7d/PWsNlqT+RDxJ/u+Gw54Pe 5Lgdn3vYoJCGmPbgHE+5rzdN+87EkGfI2R+Z7O/fR+bdmPbnhCIVaMA2D1izA0YFQO6C pyAWGqJCgU00rtWRO6dyG7s8AZrMWPWEuldxWPhicFWsXhAwSXppANkXOUJJnBj69EKm 6PfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qrth8MBR; 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-85908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x34-20020a056a000be200b006e3f7e38f78si124433pfu.59.2024.02.28.16.23.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:23:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qrth8MBR; 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-85908-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85908-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B721F285FE3 for ; Thu, 29 Feb 2024 00:23:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63CE35D743; Thu, 29 Feb 2024 00:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qrth8MBR" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 EC8B35CDF1 for ; Thu, 29 Feb 2024 00:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165941; cv=none; b=QyPc9+8DhmdQfKi6WGGUheCBzz+BvVeSs9p+7wY9P+LGYvVwzaLjUSkuiqxxPOOCeteAqzLV/afcLvGi+c1fvZyBgOo8wclmdL+6wWmJ3C2Tq3P8S5XnG6tmeu0dhzqkt6QWlDoDRhsNTNrkyiT0GrO8Bvmq9LAfC05QwbnV2hA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709165941; c=relaxed/simple; bh=n24bfMvbsLQrhJDf7paSd47VFWDE5Eb6tLHa7+2e2r0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=cn0QmnwPbj9T4Eg2lHT6Reb6p2/JUN/Tbn2vBm2yF0tkloKoQTEUfkNjX+GomOeY/+kJHQlfH0vh0d6QXy1coNg81W/4kRCRrNQ6yz8NyThMfnphqx17FnZ/on/BJ6ECEqNvO/9P6/yrcCb0C9RcOtN4y+WJKgqqaVpc1tr9J2c= 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=qrth8MBR; arc=none smtp.client-ip=209.85.128.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-yw1-f202.google.com with SMTP id 00721157ae682-6092c637278so5462317b3.0 for ; Wed, 28 Feb 2024 16:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709165939; x=1709770739; 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; b=qrth8MBREDCJTrleDBrvcaqUHpkrb00Y19EVfjNfUN9B8oZw1XTRDF0lXpEPIlrxgP 5ENyMP3H/WNzf1eAsoLe3aoIb1RBSZbg/PiVPaewoI8buU2LtG1k4HLbjgr4mGfGDvlD 0/2KND3NLY3iV38VfUIUcnAx3m9dBPsi2XarNSlLycUmRDWI6nbN4ivRD/8gIYSPsCly bb9fGbNMPCREHF2oIVpF3RITj/rX5+cN0m5DciPNRcPbSimBMdwNLSCarEpzbReqn/dF SpphuyVhD+5sUOodIZUqM2Lh0qNbnEt5hRJ+UXSCcaqbzbGiFXIk7FfEf3y2KIaZw67I RIqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709165939; x=1709770739; 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=ssvmfSzbf4Bf2vyw+vKAKxfn6gLVPgVaJ3+6XRQ1Cxo=; b=HZRlIIsu83BiNW+xkyEGyhvkYFVZnGa1CUZjJAI2IPo0uL+rIle0w6vWKQJhvfEAa9 Klhj/RkAbRkNQ7lMBJqc02aT/0Xbz+m6eJX/dqR+M1NZwmNe04XS3YrUNnFY+2BrNEiz sqfzG5OFpeB2ZTR2o4R6WB86AsrCB5GJOOBeV8eKZIJmVAoKS1zllESdOnRowEUJiFzF Yq8iRH9B2+y1VrTOtnmtdXBd16IJjArz/vingFKPdm/3ZrpG+m4e6kEa/2eNCM+39jBv IEv5033JreLTuYQcbp3ztB5pzrDY84qWmBKX+Ar+VeIzxNFVcqvr9oQaQeVbgEdbSDR2 vuRA== X-Forwarded-Encrypted: i=1; AJvYcCUbSIX+Xe8hOvnL4l121cUSCe1l3yIi9dp6Z3PwnKKVY7RgTEgqqx+2febMkycVwOS1r36A21VG8H+38OURASEcMRw/rxaAY8cwbiou X-Gm-Message-State: AOJu0Yz+TnlECOQpjfRie2J2Qno/Oxbbdx5MPIyWmzmuU8+FWQipVz4M oIQDBYRBtQ0UuuLbP2Lq6NKe619USeY1b1kZrW9e8yONiGtAoRLpODMMkCgAKolERuF55JN38xR ijrsU1w== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:230a:b0:dcc:6bf0:2eb6 with SMTP id do10-20020a056902230a00b00dcc6bf02eb6mr41891ybb.6.1709165939066; Wed, 28 Feb 2024 16:18:59 -0800 (PST) Date: Wed, 28 Feb 2024 16:18:00 -0800 In-Reply-To: <20240229001806.4158429-1-irogers@google.com> Message-Id: <20240229001806.4158429-16-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 15/20] perf jevents: Add mem_bw metric 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" Break down memory bandwidth using uncore counters. For many models this matches the memory_bandwidth_* metrics, but these metrics aren't made available on all models. Add support for free running counters. Query the event json when determining which what events/counters are available. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/intel_metrics.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events/intel_metrics.py index e373f87d499d..8d02be83b491 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -800,6 +800,67 @@ def IntelLdSt() -> Optional[MetricGroup]: ], description = "Breakdown of load/store instructions") +def UncoreMemBw() -> Optional[MetricGroup]: + mem_events = [] + try: + mem_events = json.load(open(f"{os.path.dirname(os.path.realpath(__file__))}" + f"/arch/x86/{args.model}/uncore-memory.json")) + except: + pass + + ddr_rds = 0 + ddr_wrs = 0 + ddr_total = 0 + for x in mem_events: + if "EventName" in x: + name = x["EventName"] + if re.search("^UNC_MC[0-9]+_RDCAS_COUNT_FREERUN", name): + ddr_rds += Event(name) + elif re.search("^UNC_MC[0-9]+_WRCAS_COUNT_FREERUN", name): + ddr_wrs += Event(name) + #elif re.search("^UNC_MC[0-9]+_TOTAL_REQCOUNT_FREERUN", name): + # ddr_total += Event(name) + + if ddr_rds == 0: + try: + ddr_rds = Event("UNC_M_CAS_COUNT.RD") + ddr_wrs = Event("UNC_M_CAS_COUNT.WR") + except: + return None + + ddr_total = ddr_rds + ddr_wrs + + pmm_rds = 0 + pmm_wrs = 0 + try: + pmm_rds = Event("UNC_M_PMM_RPQ_INSERTS") + pmm_wrs = Event("UNC_M_PMM_WPQ_INSERTS") + except: + pass + + pmm_total = pmm_rds + pmm_wrs + + scale = 64 / 1_000_000 + return MetricGroup("mem_bw", [ + MetricGroup("mem_bw_ddr", [ + Metric("mem_bw_ddr_read", "DDR memory read bandwidth", + d_ratio(ddr_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_write", "DDR memory write bandwidth", + d_ratio(ddr_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_ddr_total", "DDR memory write bandwidth", + d_ratio(ddr_total, interval_sec), f"{scale}MB/s"), + ], description = "DDR Memory Bandwidth"), + MetricGroup("mem_bw_pmm", [ + Metric("mem_bw_pmm_read", "PMM memory read bandwidth", + d_ratio(pmm_rds, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_write", "PMM memory write bandwidth", + d_ratio(pmm_wrs, interval_sec), f"{scale}MB/s"), + Metric("mem_bw_pmm_total", "PMM memory write bandwidth", + d_ratio(pmm_total, interval_sec), f"{scale}MB/s"), + ], description = "PMM Memory Bandwidth") if pmm_rds != 0 else None, + ], description = "Memory Bandwidth") + + all_metrics = MetricGroup("", [ Cycles(), Idle(), @@ -815,6 +876,7 @@ all_metrics = MetricGroup("", [ IntelMlp(), IntelPorts(), IntelSwpf(), + UncoreMemBw(), ]) if args.metricgroups: -- 2.44.0.278.ge034bb2e1d-goog