Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp743490rdb; Fri, 6 Oct 2023 19:14:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqjQrGbFGE/HLrLq464z4IgUcPhe3o64WfzuyWwESs7P6utpy8FRIAiOO/ApVs1lIGQN34 X-Received: by 2002:a05:6a20:3d01:b0:14c:446c:b188 with SMTP id y1-20020a056a203d0100b0014c446cb188mr11406614pzi.37.1696644842032; Fri, 06 Oct 2023 19:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696644842; cv=none; d=google.com; s=arc-20160816; b=YAb+pbYQAWqdE4keMwgiTJ+crjiNOqHmj0L8IBILgF3TY9v0vasjIVXnPml31ltlmJ JoXEewktk1ZVYH2AcPRjlAIlUsg8SbQRXp1fvJIj+C/6ey/+0qzROpRfrS384aCL5iug rkEPBn6ma2x864JFItP9du2M7ZSMW5nrt7d9Dm1zASyux5tqqQqq6yYV7ucCZeLWc+pO 4F8lflWVTOjmOuo4v2YSlhQi9dc61L4NlZB25bvSQx9prdM2Bci53lGT6U+qP3mqUCOo 6tTpBN7tNNzY+DL7IDHTRpGeDwOs5QPB3YsMI82DeEhSujWZQqCsv9Dsbu+eJDwwwDKI XU3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=JEVjZ6N3og+gW+xMTkpMzQJ6pQd4TOr0IjDXaW6Z93M=; fh=/5tleBjPDujrXIYss611tAyhfELId0etfY4oKm6i49Q=; b=mpQniew0BfGo3OfGPFwWtRjCEEs0ww8cxHvtJjPnzHpH/0eELQKkgNVHbwtQnSKAR+ i+EggkJTI0pTolgt0NE+oww+tfAmw6g3YpdcILc6zRS9Wv52ykucEuoofQsm2q4fHQNV jsG/A9hNYNdIn5kIZu6AfZTU/V/AOcLGW7a9DD8vQ3hH4U0CvPhkrCWZyA3NlxtzFlig aLWlO9XxxQksQvnaQaLryhRFLHoznKUK7gvkaTjbj69Q4xhi2OWeJFx/9Y9zZeuf2GAE n3yyLU1Qjmk5dlX2x+b0z8LXxnNExfeymQBMqIueWYRqQcBqNLbhM+6YCC6Ravfv47rY nceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Sh7Z5eAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d16-20020a056a0024d000b0068e3f55075esi2774984pfv.134.2023.10.06.19.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 19:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Sh7Z5eAO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 513DD82430A1; Fri, 6 Oct 2023 19:13:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234052AbjJGCNs (ORCPT + 99 others); Fri, 6 Oct 2023 22:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbjJGCNr (ORCPT ); Fri, 6 Oct 2023 22:13:47 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D75BF for ; Fri, 6 Oct 2023 19:13:46 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d816fa2404aso3729725276.0 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=baOQ8Pn7+Yc0ngWdZwDVoo7UYd4DvsFIERZOgvdk+aAZKHAN0SmDmHYvcrZeFNLAJ7 0bevVzkrGMvizciycFD02gFhn5SX/Ne7WOOm9suFYdRwAZ5Mi+CoQkyRmjFHcS9kaqT6 XPf74R7A+l78cMnBEMDDPCN25ZP03UyzUwLBT9oeGQw8W8rXnbCIvr6GtF2Q6ZFQLfIC BJyE2319dN4oQL0pdsI4b6hXI2doQC49PHltkwooVcg9npQcoJlIoaWYmwKon61ZEpmv vAQ75gUEVHfyNKEtccfbNwE0mSEOYw81SG0LXqQhDzIpLZ/L6jkrIQwfkYV11bH2Kknl oTnA== X-Gm-Message-State: AOJu0Yzl+yReVT4mnP3Jrq5nl0CqD8h+UdK0a2mghnqSvobQcQ27iiZq xDKUcbgaQE6HgNdVi8jBGjj3pM5biVM6 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> 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=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 19:13:58 -0700 (PDT) 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