Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp358362pxb; Fri, 16 Apr 2021 07:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv29xBZi9skL8JPM1Bshet7C4qA4bAk9ZXwjgR1M7QkTcooyMY6s1P3eiGbCBRqckVB7uz X-Received: by 2002:aa7:d046:: with SMTP id n6mr9048406edo.357.1618583129127; Fri, 16 Apr 2021 07:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618583129; cv=none; d=google.com; s=arc-20160816; b=hN5SIf9QUsSxD+GNlI/DT0O71dj1w43Qercr292CM11NJmUclmx+YQ/4Anp7cftN5/ Iqd4Z4YLdfrCn3+unWELSFdDgzdN0sGiVMPL5bhmGUpfRo6XiRAsPg1s96UvGFKFMdBp oIvdy7QvFEZ6j4kaHfTHQhgfEunDHc0/sGtL+NISOeKkFcoImdoao/yDCK3FGcLWuYIe 0Olcfdz8UeZJolNtRUxkAXT0FXS0PLr4rfd5ezOmg60/fkI+o8T3xrm9JQL6CgAivIbQ pzd7+lA5ds5ryjQIQu6T+Q7a7XcYzSNGZc1B9wzje6iaqrer4wCmHmxT2/A4mCdyQa4s /1mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=OnKCEtZ3YywK/bxqzOd4JFMoKXYZZmKuBt191boR43U=; b=OGI2z3lc+MdtxS68M47RBGOwbrRrlv63r2VS/Rin297kw97Rtx3wzR3SLCMIYCLTcj 9g2/flcoxua6xC9ezXVPmGEwRgT5QoMYYbDNGHYOKC/krOrJLPLcapd2ZrWl6hNKabZC yUd1Hzo+hsaApEocP+ku+wcSHEk0F84N3JwgPJRML687zcpmMsHsLi0k7pZYmibNXmga r1Eb6ftRRzKTFWWR1zeqLMXj+mDtOqOvpZRYH4Vg/85mdoNeL4rOQyar1AtvG5TFOmjE 9IYjcLCgkTIoQwE9purqs8fxynmIj1nY9DjmtrE3yIuN5jAuQHkpV1uApHbHfZT2bd0f 1fyw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si37158ede.545.2021.04.16.07.25.05; Fri, 16 Apr 2021 07:25:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236387AbhDPOH3 (ORCPT + 99 others); Fri, 16 Apr 2021 10:07:29 -0400 Received: from mga11.intel.com ([192.55.52.93]:23079 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236241AbhDPOHN (ORCPT ); Fri, 16 Apr 2021 10:07:13 -0400 IronPort-SDR: sLc0UpxZYn/l7ysIihIdb5tqYmRw/VhTvoknqpXXRwr6Su6NyY0fLFctoCVApn0mJtymPfME7z o93++03soojg== X-IronPort-AV: E=McAfee;i="6200,9189,9956"; a="191854308" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="191854308" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 07:06:49 -0700 IronPort-SDR: Qbjfa9WSZs1QzPErIGUPI66g8LAGzAtjHz5LK5ptfLgVRk7rnd3Nygdi3rkF+/dN75hfqUUsOZ tvG4TUFnHvXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="612766748" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga006.fm.intel.com with ESMTP; 16 Apr 2021 07:06:46 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v4 11/25] perf parse-events: Compare with hybrid pmu name Date: Fri, 16 Apr 2021 22:05:03 +0800 Message-Id: <20210416140517.18206-12-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416140517.18206-1-yao.jin@linux.intel.com> References: <20210416140517.18206-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On hybrid platform, user may want to enable event only on one pmu. Following syntax will be supported: cpu_core// cpu_atom// For hardware event, hardware cache event and raw event, two events are created by default. We pass the specified pmu name in parse_state and it would be checked before event creation. So next only the event with the specified pmu would be created. Signed-off-by: Jin Yao --- v4: - New in v4. tools/perf/util/parse-events-hybrid.c | 21 ++++++++++++++++++++- tools/perf/util/parse-events-hybrid.h | 3 ++- tools/perf/util/parse-events.c | 5 +++-- tools/perf/util/parse-events.h | 4 +++- tools/perf/util/parse-events.y | 9 ++++++--- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/parse-events-hybrid.c b/tools/perf/util/parse-events-hybrid.c index e27b747080e1..10160ab126f9 100644 --- a/tools/perf/util/parse-events-hybrid.c +++ b/tools/perf/util/parse-events-hybrid.c @@ -59,6 +59,15 @@ static int create_event_hybrid(__u32 config_type, int *idx, return 0; } +static int pmu_cmp(struct parse_events_state *parse_state, + struct perf_pmu *pmu) +{ + if (!parse_state->hybrid_pmu_name) + return 0; + + return strcmp(parse_state->hybrid_pmu_name, pmu->name); +} + static int add_hw_hybrid(struct parse_events_state *parse_state, struct list_head *list, struct perf_event_attr *attr, char *name, struct list_head *config_terms) @@ -67,6 +76,9 @@ static int add_hw_hybrid(struct parse_events_state *parse_state, int ret; perf_pmu__for_each_hybrid_pmu(pmu) { + if (pmu_cmp(parse_state, pmu)) + continue; + ret = create_event_hybrid(PERF_TYPE_HARDWARE, &parse_state->idx, list, attr, name, config_terms, pmu); @@ -103,6 +115,9 @@ static int add_raw_hybrid(struct parse_events_state *parse_state, int ret; perf_pmu__for_each_hybrid_pmu(pmu) { + if (pmu_cmp(parse_state, pmu)) + continue; + ret = create_raw_event_hybrid(&parse_state->idx, list, attr, name, config_terms, pmu); if (ret) @@ -138,7 +153,8 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, int parse_events__add_cache_hybrid(struct list_head *list, int *idx, struct perf_event_attr *attr, char *name, struct list_head *config_terms, - bool *hybrid) + bool *hybrid, + struct parse_events_state *parse_state) { struct perf_pmu *pmu; int ret; @@ -149,6 +165,9 @@ int parse_events__add_cache_hybrid(struct list_head *list, int *idx, *hybrid = true; perf_pmu__for_each_hybrid_pmu(pmu) { + if (pmu_cmp(parse_state, pmu)) + continue; + ret = create_event_hybrid(PERF_TYPE_HW_CACHE, idx, list, attr, name, config_terms, pmu); if (ret) diff --git a/tools/perf/util/parse-events-hybrid.h b/tools/perf/util/parse-events-hybrid.h index 9ad33cd0cef4..f33bd67aa851 100644 --- a/tools/perf/util/parse-events-hybrid.h +++ b/tools/perf/util/parse-events-hybrid.h @@ -17,6 +17,7 @@ int parse_events__add_numeric_hybrid(struct parse_events_state *parse_state, int parse_events__add_cache_hybrid(struct list_head *list, int *idx, struct perf_event_attr *attr, char *name, struct list_head *config_terms, - bool *hybrid); + bool *hybrid, + struct parse_events_state *parse_state); #endif /* __PERF_PARSE_EVENTS_HYBRID_H */ diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9b2588df22a4..f69475a158bb 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -453,7 +453,8 @@ static int config_attr(struct perf_event_attr *attr, int parse_events_add_cache(struct list_head *list, int *idx, char *type, char *op_result1, char *op_result2, struct parse_events_error *err, - struct list_head *head_config) + struct list_head *head_config, + struct parse_events_state *parse_state) { struct perf_event_attr attr; LIST_HEAD(config_terms); @@ -524,7 +525,7 @@ int parse_events_add_cache(struct list_head *list, int *idx, ret = parse_events__add_cache_hybrid(list, idx, &attr, config_name ? : name, &config_terms, - &hybrid); + &hybrid, parse_state); if (hybrid) return ret; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index c4f2f96304ce..bf6e41aa9b6a 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -138,6 +138,7 @@ struct parse_events_state { struct list_head *terms; int stoken; struct perf_pmu *fake_pmu; + char *hybrid_pmu_name; }; void parse_events__handle_error(struct parse_events_error *err, int idx, @@ -188,7 +189,8 @@ int parse_events_add_tool(struct parse_events_state *parse_state, int parse_events_add_cache(struct list_head *list, int *idx, char *type, char *op_result1, char *op_result2, struct parse_events_error *error, - struct list_head *head_config); + struct list_head *head_config, + struct parse_events_state *parse_state); int parse_events_add_breakpoint(struct list_head *list, int *idx, u64 addr, char *type, u64 len); int parse_events_add_pmu(struct parse_events_state *parse_state, diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index d57ac86ce7ca..aba12a4d488e 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -454,7 +454,8 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_e list = alloc_list(); ABORT_ON(!list); - err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6); + err = parse_events_add_cache(list, &parse_state->idx, $1, $3, $5, error, $6, + parse_state); parse_events_terms__delete($6); free($1); free($3); @@ -475,7 +476,8 @@ PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config list = alloc_list(); ABORT_ON(!list); - err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4); + err = parse_events_add_cache(list, &parse_state->idx, $1, $3, NULL, error, $4, + parse_state); parse_events_terms__delete($4); free($1); free($3); @@ -495,7 +497,8 @@ PE_NAME_CACHE_TYPE opt_event_config list = alloc_list(); ABORT_ON(!list); - err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2); + err = parse_events_add_cache(list, &parse_state->idx, $1, NULL, NULL, error, $2, + parse_state); parse_events_terms__delete($2); free($1); if (err) { -- 2.17.1