From patchwork Thu Apr 16 16:20:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 221119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11618C2BB55 for ; Thu, 16 Apr 2020 16:21:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0A3320857 for ; Thu, 16 Apr 2020 16:21:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HN8WubAf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440769AbgDPQVr (ORCPT ); Thu, 16 Apr 2020 12:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2388432AbgDPQVI (ORCPT ); Thu, 16 Apr 2020 12:21:08 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E6DC0610D6 for ; Thu, 16 Apr 2020 09:21:08 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id m25so3559889pgl.8 for ; Thu, 16 Apr 2020 09:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=i6zi1rxo51fT0gF/9bIKSou9eRtAcSwwYlA8EKV06Zo=; b=HN8WubAfA91Oq5unhGG2MkopzGLkdfvg9STdwJsiSIl7hxl76b/eAFL7jhXWb2Ox3m SaEaUPM39ntxqpGiuXqlA9gEIeJArcs1oELta1pGoAcCQ8Y7j8qiITnix2h4f6JoQEYo QGJQ8W+5urtqToRkZR16mEWxOdz8X99KKwur5GuVOBWessbgEv21JC8tFrrOd+XMsTgZ 3gGLM7hP3pDlEuoL69b+4rbPzHzQTdT7C2AiKjHEWbjy6fqk6wwDguVwtJvgVeZiRMRD Qskf5j6/g0x46Y9hPI3Zx1XgQfznExjp8bc0l/9GDXZ+HHifmCBePWCImVSFvpI0yfuh lE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=i6zi1rxo51fT0gF/9bIKSou9eRtAcSwwYlA8EKV06Zo=; b=twFwoJwmteQQCal4R0imt5OFlPPrpjyUAD1roquLvMn/tbK3f8FgD5SKYK+6terxu7 nko5toyXesTmrnI65GDvlSI0SBVlX0s2aedQADGff31i+szdarQPKF14NRItEaMjfFar WhEz0yWihUiQh9UZu3/Ga1xjHg37t9ke4AFkqEfKFbYfcR2m+ISabL0rcM+gWh6edOrM KyYLXaHinfURw9aTloHBUtIFhT60bZfU0cK19QiWoOf1ASA1WHUtfBFMdpQoQpg1r2Lj T9G9X0X8bLKLR33sycugr26Esjowzx5dbkR/WQeaEU/w51KVnii3cgVeE3+BcvYoSm5R GDTw== X-Gm-Message-State: AGi0PuZEQ+Nxn9ghqf8RGHQBKFuGWNw6tzuL19bcDh4uby3bYOBM+FIa aR+OPqyMHuXWRrLHZMImS15Lkjj/rI5W X-Google-Smtp-Source: APiQypJCtiTrQy1RWVW3S33PVpA4SuG+D/ydw+ePNnNNFVlEgIZ3Zws8LDl2fX9FI8lD+yI2Kl+taVRN26F2 X-Received: by 2002:a63:6444:: with SMTP id y65mr27372866pgb.343.1587054067816; Thu, 16 Apr 2020 09:21:07 -0700 (PDT) Date: Thu, 16 Apr 2020 09:20:56 -0700 In-Reply-To: <20200416162058.201954-1-irogers@google.com> Message-Id: <20200416162058.201954-3-irogers@google.com> Mime-Version: 1.0 References: <20200416162058.201954-1-irogers@google.com> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog Subject: [PATCH v10 2/4] tools feature: add support for detecting libpfm4 From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Yonghong Song , Andrii Nakryiko , Greg Kroah-Hartman , Thomas Gleixner , Igor Lubashev , Alexey Budankov , Florian Fainelli , Adrian Hunter , Andi Kleen , Jiwei Sun , yuzhoujian , Kan Liang , Jin Yao , Leo Yan , John Garry , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Stephane Eranian libpfm4 provides an alternate command line encoding of perf events. Signed-off-by: Stephane Eranian Reviewed-by: Ian Rogers --- tools/build/Makefile.feature | 3 ++- tools/build/feature/Makefile | 6 +++++- tools/build/feature/test-libpfm4.c | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tools/build/feature/test-libpfm4.c diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 3e0c019ef297..3abd4316cd4f 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -98,7 +98,8 @@ FEATURE_TESTS_EXTRA := \ llvm \ llvm-version \ clang \ - libbpf + libbpf \ + libpfm4 FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 621f528f7822..a6eded94a36b 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -68,7 +68,8 @@ FILES= \ test-llvm-version.bin \ test-libaio.bin \ test-libzstd.bin \ - test-file-handle.bin + test-file-handle.bin \ + test-libpfm4.bin FILES := $(addprefix $(OUTPUT),$(FILES)) @@ -325,6 +326,9 @@ $(OUTPUT)test-libzstd.bin: $(OUTPUT)test-file-handle.bin: $(BUILD) +$(OUTPUT)test-libpfm4.bin: + $(BUILD) -lpfm + ############################### clean: diff --git a/tools/build/feature/test-libpfm4.c b/tools/build/feature/test-libpfm4.c new file mode 100644 index 000000000000..af49b259459e --- /dev/null +++ b/tools/build/feature/test-libpfm4.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +int main(void) +{ + pfm_initialize(); + return 0; +} From patchwork Thu Apr 16 16:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 221120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E327FC352BE for ; Thu, 16 Apr 2020 16:21:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9A2820771 for ; Thu, 16 Apr 2020 16:21:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AVbDpsLb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393776AbgDPQVR (ORCPT ); Thu, 16 Apr 2020 12:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2389337AbgDPQVL (ORCPT ); Thu, 16 Apr 2020 12:21:11 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6E5C061BD3 for ; Thu, 16 Apr 2020 09:21:10 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id x25so3438739pfq.18 for ; Thu, 16 Apr 2020 09:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=a6tQ7DnVmCoPtEQQNpyDptK3byF4qMP4x4cRpQx2XV4=; b=AVbDpsLbKtAaOU3yTQ6Jkn38wfxP3SvLchMNOvt7HyyL0QwFZNGqVKoVyLKjt64kGs xvsh/ec3XhwSbr/TYnKAw/3EEAX+t7qo6T8+MJ8Ll3dAzCOYHzCYANNSGso/eDiRS9Ss TwXciuCd155RVkf14SrqLqp5b1JMcN15Pjj01mS+v2KVoLYkaqIbhd7LZiK4zyVVwE0i Q2v23jJUpr1rVLNbAZh2otJz6lnKISqB1yeokKz4ZCu/G34JqABEXnsw0oGT3EyP+KXi 8B9f8n91EoUnn4jpPfhrK7RYaSMSWO0kyNJe15rOBs6fJJK0X8fifF6bz85UfbQpDz/m ij0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=a6tQ7DnVmCoPtEQQNpyDptK3byF4qMP4x4cRpQx2XV4=; b=R1ji6PuZztIDPO5BykQbd5E2xGTF3TxvtQTi/6lri0g/WIyi6v3U4jddCbSa9aM7Zo 9iddr2VwyZOKDTK6CywUIKTpRO1hrsm4yNP+nLnskk5hKgY6l6RC/TBMrjqT0qXT1yyN qToI6QNii09de0tCwRrBIk06BR+LYqMuUh3JS5f4VcrfrglbUHbiPYBQs0eRUCHLpXmm kfQfXG4W37ATE5GAO+ob4XH/lxhUPoN3yCDnQTCPOc06p7bfAz5KktUv0MPxXyinW2MT RSW3XZQEegtPLOKPMHhpN+3+3Q9Fkxr7u22UIA6xH122kVr7PcSXDsV39hR+lvsTwItd tI1g== X-Gm-Message-State: AGi0Pubh1pXUG3I4HnRF5JPRHipUPfaTpFBlaoxjakTP7wYcZ5v2EhAo VsCT0ynbQEOHBy6o2Mh4C8NJW37ibLSU X-Google-Smtp-Source: APiQypI/5T+C0TPvvOpusz5KPtkgU0R8dP8dM8GPvH2VRKVG1DKmMcsjfxZ4wvFE7gi8YomJ59uyV4oQeOg8 X-Received: by 2002:a17:90b:23c8:: with SMTP id md8mr5869465pjb.172.1587054070393; Thu, 16 Apr 2020 09:21:10 -0700 (PDT) Date: Thu, 16 Apr 2020 09:20:57 -0700 In-Reply-To: <20200416162058.201954-1-irogers@google.com> Message-Id: <20200416162058.201954-4-irogers@google.com> Mime-Version: 1.0 References: <20200416162058.201954-1-irogers@google.com> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog Subject: [PATCH v10 3/4] perf pmu: add perf_pmu__find_by_type helper From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Yonghong Song , Andrii Nakryiko , Greg Kroah-Hartman , Thomas Gleixner , Igor Lubashev , Alexey Budankov , Florian Fainelli , Adrian Hunter , Andi Kleen , Jiwei Sun , yuzhoujian , Kan Liang , Jin Yao , Leo Yan , John Garry , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Stephane Eranian This is used by libpfm4 during event parsing to locate the pmu for an event. Signed-off-by: Stephane Eranian Reviewed-by: Ian Rogers --- tools/perf/util/pmu.c | 11 +++++++++++ tools/perf/util/pmu.h | 1 + 2 files changed, 12 insertions(+) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index ef6a63f3d386..5e918ca740c6 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -869,6 +869,17 @@ static struct perf_pmu *pmu_find(const char *name) return NULL; } +struct perf_pmu *perf_pmu__find_by_type(unsigned int type) +{ + struct perf_pmu *pmu; + + list_for_each_entry(pmu, &pmus, list) + if (pmu->type == type) + return pmu; + + return NULL; +} + struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu) { /* diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 5fb3f16828df..de3b868d912c 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -65,6 +65,7 @@ struct perf_pmu_alias { }; struct perf_pmu *perf_pmu__find(const char *name); +struct perf_pmu *perf_pmu__find_by_type(unsigned int type); int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, struct list_head *head_terms, struct parse_events_error *error);