Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 208D01377 for ; Sat, 7 Oct 2023 02:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sh7Z5eAO" Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45190BE for ; Fri, 6 Oct 2023 19:13:46 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81841ef79bso3720745276.1 for ; Fri, 06 Oct 2023 19:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696644825; x=1697249625; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=JEVjZ6N3og+gW+xMTkpMzQJ6pQd4TOr0IjDXaW6Z93M=; b=Sh7Z5eAOKDlJFvMF4do3ce2itXjTZsOeGNFBKEnY0eQPyChXiauARjZ6JFGYkgNthA wVYwiNHVh/rievmGACu4lHjj4o9+b0/N5a97/pT5lFGJFmzA5v7Rj2wuKOFcal2BI9qI ZmFq3Nzxltnhm58fNGdiMzMdgl0JHt3/M/7vt4vEDxMin9/qNPAmIZWzC7TutGFaRIk1 tX8MHvMgdhTUFzJlnt0YOetRiVO1yUOkkeN1NAWJCxTSM5iq6yWKotEP8biwyaOwy38X lsSRhto77rhVOIF1F3DwX/Ds+UYYkr1BANyxj7fu0KgCbt2eTlRYaJgldPHcTCT5VSRf fEYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696644825; x=1697249625; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JEVjZ6N3og+gW+xMTkpMzQJ6pQd4TOr0IjDXaW6Z93M=; b=u8c2YtUowknpGrEf4c1kKqRWUkg46619N5K+WSz48ZWoljCHiNaxB3qW1AUzXdN2U/ zydg12gYvNQAC5G3rsKD1sjpDC1niJPfB2vxYkUnX1jb8aajmgygCKznC/xGHAYgyWRl DvmTVyaeZSGl1XSfGJ80C2m8ko63xyrkMF7sD9ao9PyDR5AVC7J41iLCTm44n5Mwr8Y7 ltkVVWVa4Z0fxt69UcMfFawRjELI/utZI615pRvOKs2qgMQk8y1HLj1piSt+1iw+P85j Nf3zl1z0/NiGlnYpuCfkSThrI14VLmVbmhBfDOJqvf/klKNST5baOksbNMinZlQFZWr2 0tPw== X-Gm-Message-State: AOJu0YwgGXvCcsmadfrIMpwDDBsVevsWb8rto2tPH+hkT3QYykLUFWQE RDEg7m1W8UQpq5sUOthbxexbupyO7QWP X-Google-Smtp-Source: AGHT+IF2EWY4ixpkApTIlh/URgj2hH2/ff+8VAS2lTt0A8xa82u8MZbVhfUp9TQhyImXiXti7n+Pv8SxiS2H X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:7031:b36b:6c77:bfd0]) (user=irogers job=sendgmr) by 2002:a25:2513:0:b0:d0f:a0a6:8e87 with SMTP id l19-20020a252513000000b00d0fa0a68e87mr142757ybl.2.1696644825394; Fri, 06 Oct 2023 19:13:45 -0700 (PDT) Date: Fri, 6 Oct 2023 19:13:19 -0700 Message-Id: <20231007021326.4156714-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v1 0/7] PMU performance improvements From: Ian Rogers To: Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Thomas Richter , Ravi Bangoria , Kajol Jain , Jing Zhang , Kan Liang , Yang Jihong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Performance improvements to pmu scanning by holding onto the event/metric tables for a cpuid (avoid regular expression comparisons) and by lazily computing the default perf_event_attr for a PMU. Before % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 251.990 usec (+- 4.009 usec) Average PMU scanning took: 3222.460 usec (+- 211.234 usec) % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 260.120 usec (+- 7.905 usec) Average PMU scanning took: 3228.995 usec (+- 211.196 usec) % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 252.310 usec (+- 3.980 usec) Average PMU scanning took: 3220.675 usec (+- 210.844 usec) After: % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 28.530 usec (+- 0.602 usec) Average PMU scanning took: 275.725 usec (+- 18.253 usec) % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 28.720 usec (+- 0.446 usec) Average PMU scanning took: 271.015 usec (+- 18.762 usec) % Running 'internals/pmu-scan' benchmark: Computing performance of sysfs PMU event scan for 100 times Average core PMU scanning took: 31.040 usec (+- 0.612 usec) Average PMU scanning took: 267.340 usec (+- 17.209 usec) Measuring the pmu-scan benchmark on a Tigerlake laptop: core PMU scanning is reduced to 11.5% of the previous execution time, all PMU scanning is reduced to 8.4% of the previous execution time. There is a 4.3% reduction in openat system calls. Ian Rogers (7): perf pmu: Rename perf_pmu__get_default_config to perf_pmu__arch_init perf intel-pt: Move PMU initialization from default config code perf arm-spe: Move PMU initialization from default config code perf pmu: Const-ify file APIs perf pmu: Const-ify perf_pmu__config_terms perf pmu-events: Remember the events and metrics table perf pmu: Lazily compute default config tools/perf/arch/arm/util/cs-etm.c | 13 ++------ tools/perf/arch/arm/util/pmu.c | 10 +++--- tools/perf/arch/arm64/util/arm-spe.c | 48 +++++++++++++--------------- tools/perf/arch/s390/util/pmu.c | 3 +- tools/perf/arch/x86/util/intel-pt.c | 27 +++++++--------- tools/perf/arch/x86/util/pmu.c | 6 ++-- tools/perf/pmu-events/jevents.py | 48 ++++++++++++++++------------ tools/perf/util/arm-spe.h | 4 ++- tools/perf/util/cs-etm.h | 2 +- tools/perf/util/intel-pt.h | 3 +- tools/perf/util/parse-events.c | 12 +++---- tools/perf/util/pmu.c | 39 +++++++++++----------- tools/perf/util/pmu.h | 18 ++++++----- tools/perf/util/python.c | 2 +- 14 files changed, 117 insertions(+), 118 deletions(-) -- 2.42.0.609.gbb76f46606-goog