Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3540005ybz; Mon, 20 Apr 2020 04:58:30 -0700 (PDT) X-Google-Smtp-Source: APiQypLBw0b9ZnMKSDmwzonT1PMz1F3AnogRQaQQv42dX+uLhp2XUVCq+oA6KHb//QQiuxV3Ie1U X-Received: by 2002:a17:906:af99:: with SMTP id mj25mr15350962ejb.151.1587383910418; Mon, 20 Apr 2020 04:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587383910; cv=none; d=google.com; s=arc-20160816; b=uuFkBy7pr6jQrVGki5lAzB/yqKQSQp9cxF0+DAA9ksOaPtKqqOJwf+g8O+69FvK7re j6q4pmsxgQLgHXtisNsirfNPdRhA2Zzs2dWH5p1gjDcMaznmF/EEKcn2XBDfjDDJjnCe UOMYo4dyTQ/K1pr33jHEPNmwEqiVR1x4JPtDJoA3kmm7SWrlM3d/QXHJ/bNz0MyYRh5v HwHbXtb1mIu9kHTw/mlF62AtwZ5nlbAG+znC5KGXvIVK4I5sFgvx59Q7gN/R7K+WMdHu yCt6X1X/ub4BQdDoDBmiuVWTpsORbv7k9Wlhz6lndFU8+xYpQuVuUHZMJ7sTrKYCqQGf 2uHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uytTg9DQWF8WhS6za8o8FzVysxcGMr8Z8ohzy2g6cbA=; b=J4t6ijD9WyuHhSmEv60OuJ+ZOaK9z/mm5mwstC5J5GC7r7QlBk99YNE/AK6gg/OHj4 WK6DqkZlHJCca+JNqZX7XbF8/+EpQuPRKsK8/NwaN8SuyMYFZCvbX5E4GCrZOhBkRY63 RZarVnJbD7J+BNofg4IHlmAgPAB//CN2ymLfVKSxeuS9kBgvuIvz2mW1Zlx5Kh2NNle+ 0b/F/N9oCvDYb4Bggp36zXJ/2XKmoHzOFazqQM6ZgyM7a4XIvDHLlcu5AvSkBrLgORqE PscnbPb6g8PjZ+aODP7Cp10AHqgRMieIwf/oBNhgh5Slf88mgCrtaZtFwyj2P8zjtcKB qtpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xydOqEqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si412098ejr.440.2020.04.20.04.58.07; Mon, 20 Apr 2020 04:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xydOqEqW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727030AbgDTL4R (ORCPT + 99 others); Mon, 20 Apr 2020 07:56:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:40536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgDTL4N (ORCPT ); Mon, 20 Apr 2020 07:56:13 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D69C922209; Mon, 20 Apr 2020 11:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587383772; bh=u7yG1A4dyYz+LQCEOwvwrhPfBkWm6kF3HaBT6Ua4scA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xydOqEqWcwRFdcqEbwsPF4nM8ONcg+4vHpV4H5iW/I6b47w1rOe9OZgnotsi1EFR3 7wMK+AwYSJ7c8EO9jSjb+e1IBsdITCWp2IpR81Rc1QLmibsVfd0mSY0tdREHqKh0be 5RRpYBr5zUY7fuaixZkUFp5ZieV3S3jD8Vw4uqV8= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Adrian Hunter , Andi Kleen , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 37/60] perf evsel: Move and globalize perf_evsel__find_pmu() and perf_evsel__is_aux_event() Date: Mon, 20 Apr 2020 08:52:53 -0300 Message-Id: <20200420115316.18781-38-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200420115316.18781-1-acme@kernel.org> References: <20200420115316.18781-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter Move and globalize 2 functions from the auxtrace specific sources so that they can be reused. Signed-off-by: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Link: http://lore.kernel.org/lkml/20200401101613.6201-13-adrian.hunter@intel.com [ Move to pmu.c, as moving to evsel.h breaks the python binding ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/auxtrace.c | 19 ------------------- tools/perf/util/evsel.h | 3 +++ tools/perf/util/pmu.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 809a09e75c55..33ad33378a90 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -58,25 +58,6 @@ #include "symbol/kallsyms.h" #include -static struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel) -{ - struct perf_pmu *pmu = NULL; - - while ((pmu = perf_pmu__scan(pmu)) != NULL) { - if (pmu->type == evsel->core.attr.type) - break; - } - - return pmu; -} - -static bool perf_evsel__is_aux_event(struct evsel *evsel) -{ - struct perf_pmu *pmu = perf_evsel__find_pmu(evsel); - - return pmu && pmu->auxtrace; -} - /* * Make a group from 'leader' to 'last', requiring that the events were not * already grouped to a different leader. diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index e64ed4202cab..a463bc65b001 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -158,6 +158,9 @@ int perf_evsel__object_config(size_t object_size, int (*init)(struct evsel *evsel), void (*fini)(struct evsel *evsel)); +struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel); +bool perf_evsel__is_aux_event(struct evsel *evsel); + struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx); static inline struct evsel *evsel__new(struct perf_event_attr *attr) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index ef6a63f3d386..bc912a84b5e9 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -18,6 +18,7 @@ #include #include #include "debug.h" +#include "evsel.h" #include "pmu.h" #include "parse-events.h" #include "header.h" @@ -884,6 +885,25 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu) return NULL; } +struct perf_pmu *perf_evsel__find_pmu(struct evsel *evsel) +{ + struct perf_pmu *pmu = NULL; + + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (pmu->type == evsel->core.attr.type) + break; + } + + return pmu; +} + +bool perf_evsel__is_aux_event(struct evsel *evsel) +{ + struct perf_pmu *pmu = perf_evsel__find_pmu(evsel); + + return pmu && pmu->auxtrace; +} + struct perf_pmu *perf_pmu__find(const char *name) { struct perf_pmu *pmu; -- 2.21.1