Received: by 10.223.185.116 with SMTP id b49csp6167115wrg; Thu, 8 Mar 2018 03:01:14 -0800 (PST) X-Google-Smtp-Source: AG47ELtH6mEt54IEU7nVkoUGhv7bA4GJg+BNgrvRQtkD9U9rFIuX/UeNxB7gLl21FzwhBW2xDEvh X-Received: by 10.99.109.79 with SMTP id i76mr20115424pgc.402.1520506874683; Thu, 08 Mar 2018 03:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520506874; cv=none; d=google.com; s=arc-20160816; b=wi8mdCA5Mx8pgI9aqIJRegDgTDqEFBZ7AO+6EyA4VPJyFae8fb4/p7kAfe4ltGJhpW OPexyQqMEaTumAOyBejfx3YzXPanpRvlIbUMAkvvUuRCoO6YMeueK1txxrVKO+XrfRkx K0eAHzJOKmuf+dBhoDM/i0SrK8jLNXBBiyhozXuiwKBhK6Aut+ntTr+o1ET6AUw0xrUD GyPLCubGu1RKqc9kjBcY/M0GZBVcirX5eyxU0wUHKLUh3cAct/4yvpcFxBe5O1rK4iEB /7bwM2MejfEKhcPazHjBRpTpvtXJujQHMfrtUViCH6RCkrKu+3OZUkZepnXmIJvld4WC LZbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=XXikjZYZMAqVmkh0bP4Gljd01RlDQ8St2I+TUTETLBQ=; b=qm0FHW9x22MeILJHhPsv4SjkKrbfxMHWdu7c+jwhMjK8Xi5RBpbIAxlC5edQ3HzPAH 3lOBXZNekkrIQXlbxGUfQ9KqTXlnpdlZMRF0d1pj7hTOYaZJc/i/OMvQ9q3tPswmcejq L+YpfZLbL2pPMQe7tIlj1ZbPy+XAeNRDOv6WK/tY3GLOHKWrlVuRgRFz6VJGcJOSP+KJ mu8Tms7XRU8eJn1UROGRjgGb4imT7XriYMPilOrE9RVw3VZ/thXsi6slTLzaUrpohHRD lkL3mALWG+BBs1h+scsq5iWUNLd3jaLBNnPAz/pWzt7XN68Wygk2YZDSJ7THEfPtLVHH Z/bA== 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 c62si15513829pfg.240.2018.03.08.03.00.59; Thu, 08 Mar 2018 03:01:14 -0800 (PST) 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 S935636AbeCHK7s (ORCPT + 99 others); Thu, 8 Mar 2018 05:59:48 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6177 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755732AbeCHK7o (ORCPT ); Thu, 8 Mar 2018 05:59:44 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A47CC776E1B5A; Thu, 8 Mar 2018 18:59:30 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Mar 2018 18:59:25 +0800 From: John Garry To: , , , , , , , , , CC: , , , , "John Garry" Subject: [PATCH v3 03/11] perf vendor events: drop support for unused topic directories Date: Thu, 8 Mar 2018 18:58:28 +0800 Message-ID: <1520506716-197429-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520506716-197429-1-git-send-email-john.garry@huawei.com> References: <1520506716-197429-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- NOTE: There was a bug in this code with how add_topic() sets topic_level. Also a delimiter could be added in printing the "topic" in get_topic(). 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 edff989..1d02faf 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; /* -- 1.9.1