Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1073829pxy; Thu, 22 Apr 2021 22:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEbpsndMnzLGTdv91A34Mlzn11+aal5/1aAGy1i47fgsVNagvg2YfUlmgizftJF9/d4gct X-Received: by 2002:a05:6402:31f0:: with SMTP id dy16mr2316411edb.161.1619156342815; Thu, 22 Apr 2021 22:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619156342; cv=none; d=google.com; s=arc-20160816; b=Ns8stIkI5vnmMuu/qwhfxlemDnufmsXzEOCsLonThH1ANV4aSwbp+kgJM9AHw2bPPg xKkB/5q7P2oG8O22RO58Q+iReyT32Qlgn3Sm8bCxbxhNQH43nrJQ4Dn8cxm61r6MsQ3s 93BJGFrfn4zc77wotANPXu8mrtyWxU3iE5nRDgc66D9ry/dybUPBhwmj+rl8yKZlJVYv z8UDILWMjneEAaH3Kni79sze7akVfBRYYg1ajVgAWFGb4WWYt/AAuqo43w+c1tEM1tW0 5Am+CSSYT4IKpPlPuXC74RE6bTqj3zUXkESBXcsUl78VBeOL5VP0hJ5tWaa2xTcc+hjB kmrQ== 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=38TNmBS2KY9svV6BSR0pIiQDm1/zlZax3cO8cuVCraA=; b=JpINZXf17LyY9o2aQKcBSCS3TEWSEo0xQKf/+25d4Gwhzp3ARowtARy9uwv1RdZivy bwxU6kVSxlzSW9Qell0jpGEmrDb3Dg+JS+zpKhrWVhjyM+fo6nqeuipp422oIH2hUW88 D8zR7TKrNrHS6JgPAZh/nU44FnFA3zyR2rW8tzQ4/PnFNzcSINlIYPr+kfx2LlxF1ILZ 8YjgwMR5c4P9xna4xzs3UH5RdSAAYLthETb3BqGPnMU2Z9Z1voloF7TGXutWCXgU3DXn 1rdXxnH8GBNaYxC76WdleXyc5nCE4XONkIXXXWzPVSgHko9LaTxo1shJwFTqBwrHoHz3 aQXQ== 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 dj11si4187436edb.230.2021.04.22.22.38.39; Thu, 22 Apr 2021 22:39:02 -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 S240703AbhDWFiH (ORCPT + 99 others); Fri, 23 Apr 2021 01:38:07 -0400 Received: from mga18.intel.com ([134.134.136.126]:9325 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240682AbhDWFhm (ORCPT ); Fri, 23 Apr 2021 01:37:42 -0400 IronPort-SDR: MG0abR0pPH+aTPL3j8Z/ydBXyz6JwEkURxWIb6irTW5BP4Ith6V0usbJwsvGOqC8/ncx6UqvMH M2S2VBm8+E3w== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="183501819" X-IronPort-AV: E=Sophos;i="5.82,244,1613462400"; d="scan'208";a="183501819" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 22:37:06 -0700 IronPort-SDR: j7B25bMCvhBP33DYtTgyCPSB+g1dEJk8iJ4fmKxRbULc8aM4AdiDxWPpyk94wduPgfJlZTXcpd ac5/A28V8Rrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,244,1613462400"; d="scan'208";a="386293630" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by orsmga006.jf.intel.com with ESMTP; 22 Apr 2021 22:37:04 -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 v5 11/26] perf parse-events: Compare with hybrid pmu name Date: Fri, 23 Apr 2021 13:35:26 +0800 Message-Id: <20210423053541.12521-12-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423053541.12521-1-yao.jin@linux.intel.com> References: <20210423053541.12521-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 --- v5: - No change. 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 cc3b8d77c1c1..26f96a30964f 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