Received: by 10.213.65.68 with SMTP id h4csp157297imn; Mon, 19 Mar 2018 23:24:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELubcMurU4muNGyJXNL7oi2CPlCXH4Hg34uS6rB4IUlUaOiGJVsUG7loEvaa5mMv30Ch03gz X-Received: by 2002:a17:902:983:: with SMTP id 3-v6mr15601406pln.278.1521527059408; Mon, 19 Mar 2018 23:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521527059; cv=none; d=google.com; s=arc-20160816; b=JCGai0GEW1EuptAozN7F14GIdAYdnI3uL2jUbvB7CEWbvC5qsm1qNlrxniOaogiv8d t+ALBuelMz0N3/GiNj8TKtYHcxPUvPHvH8AiInDkXb2Rx62EVcIeUNKnxIsfgju3ACvW FzGqL/Zebkl6+pawc5zOI6RkmnuZ2kDhBlYActDvC7DnGtdPH7I2Of2uGOi/v7rO0F+E kGHuqXykOQIRCDOs4dZZlPJwL3D0qOtb/yDsuY3szn6BFNVV9t9lnTkM4q1eXfp/hWV+ p4Y9/THWfMQOflxDxxPLKXtK2pPCSDJ0usCqEd+NANepYB2X/k68tTiSF25HjhZLcv3c mFQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=LWWE30nrPSO4qh6AJTj1eFmpladC1DWNoQhlF0tRbZk=; b=yoZcDDCoiE2RmLfoRDOmDyDXLbshWOPlxxIYsSV6gBTjBQQzYoJkjfv4Ky3Mk6DOpM I/LUQZa6Zl7WHmodi5vsB4WDkGcfV8nyrf//KMheJBcCBCFj7y/bPvWDqNfEKr8KgQHE IDVvKxcbAg/0pBfeRPqIGq4S1TGenBG7GYvppudrc5MUWjcZkuqsWVEcoqtJ6eEWUihl Fbl0ff6kA33G1uCkW+tRxx576b2xWszMP4mSFYczwRc21AMBp7h51q2Y01GzWfhmbPcK 718EVmdjz7LRuUbXf9tGSg99X2imyXPJcd22Asba5sy8YfnLB8AQ+kOruQB+tZ8QYLP2 aUVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si1013498plm.539.2018.03.19.23.24.05; Mon, 19 Mar 2018 23:24:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbeCTGXB (ORCPT + 99 others); Tue, 20 Mar 2018 02:23:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33475 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbeCTGXA (ORCPT ); Tue, 20 Mar 2018 02:23:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w2K6MKEx028782; Mon, 19 Mar 2018 23:22:20 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w2K6MJMq028778; Mon, 19 Mar 2018 23:22:19 -0700 Date: Mon, 19 Mar 2018 23:22:19 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for John Garry Message-ID: Cc: alexander.shishkin@linux.intel.com, acme@redhat.com, zhangshaokun@hisilicon.com, tglx@linutronix.de, john.garry@huawei.com, ganapatrao.kulkarni@cavium.com, peterz@infradead.org, will.deacon@arm.com, wcohen@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, namhyung@kernel.org, ak@linux.intel.com, mingo@kernel.org, jolsa@kernel.org Reply-To: jolsa@kernel.org, mingo@kernel.org, ak@linux.intel.com, namhyung@kernel.org, wcohen@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, will.deacon@arm.com, peterz@infradead.org, zhangshaokun@hisilicon.com, ganapatrao.kulkarni@cavium.com, john.garry@huawei.com, tglx@linutronix.de, acme@redhat.com, alexander.shishkin@linux.intel.com In-Reply-To: <1520506716-197429-4-git-send-email-john.garry@huawei.com> References: <1520506716-197429-4-git-send-email-john.garry@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf vendor events: Drop support for unused topic directories Git-Commit-ID: 6f2f2ca3454ec4fa03fcd4507bdd7fe97303065b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6f2f2ca3454ec4fa03fcd4507bdd7fe97303065b Gitweb: https://git.kernel.org/tip/6f2f2ca3454ec4fa03fcd4507bdd7fe97303065b Author: John Garry AuthorDate: Thu, 8 Mar 2018 18:58:28 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 16 Mar 2018 13:54:09 -0300 perf vendor events: Drop support for unused topic directories Currently a topic subdirectory is supported in the pmu-events dir, in the following sample structure: /arch/platform/subtopic/mysubtopic.json Upto 256 levels of topic subdirectories are supported. So this means that JSONs may be located in a topic dir as well as the platform dir. This topic subdirectory causes problems if we want to add support for a vendor dir in the pmu-events structure (in the form arch/platform/vendor), in that we cannot differentiate between a vendor dir and a topic dir. Since the topic dir feature is not used, drop it so it does not block adding vendor subdirectory support. Signed-off-by: John Garry Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ganapatrao Kulkarni Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Shaokun Zhang Cc: Will Deacon Cc: William Cohen Cc: linux-arm-kernel@lists.infradead.org Cc: linuxarm@huawei.com Link: http://lkml.kernel.org/r/1520506716-197429-4-git-send-email-john.garry@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/pmu-events/jevents.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index edff989fbcea..1d02fafdc34d 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -256,25 +256,18 @@ static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val) goto out_free; \ } } while (0) -#define TOPIC_DEPTH 256 -static char *topic_array[TOPIC_DEPTH]; -static int topic_level; +static char *topic; static char *get_topic(void) { - char *tp_old, *tp = NULL; + char *tp; int i; - for (i = 0; i < topic_level + 1; i++) { - int n; - - tp_old = tp; - n = asprintf(&tp, "%s%s", tp ?: "", topic_array[i]); - if (n < 0) { - pr_info("%s: asprintf() error %s\n", prog); - return NULL; - } - free(tp_old); + /* tp is free'd in process_one_file() */ + i = asprintf(&tp, "%s", topic); + if (i < 0) { + pr_info("%s: asprintf() error %s\n", prog); + return NULL; } for (i = 0; i < (int) strlen(tp); i++) { @@ -291,25 +284,15 @@ static char *get_topic(void) return tp; } -static int add_topic(int level, char *bname) +static int add_topic(char *bname) { - char *topic; - - level -= 2; - - if (level >= TOPIC_DEPTH) - return -EINVAL; - + free(topic); topic = strdup(bname); if (!topic) { pr_info("%s: strdup() error %s for file %s\n", prog, strerror(errno), bname); return -ENOMEM; } - - free(topic_array[topic_level]); - topic_array[topic_level] = topic; - topic_level = level; return 0; } @@ -824,7 +807,7 @@ static int process_one_file(const char *fpath, const struct stat *sb, } } - if (level > 1 && add_topic(level, bname)) + if (level > 1 && add_topic(bname)) return -ENOMEM; /*