Received: by 10.223.185.116 with SMTP id b49csp817926wrg; Fri, 23 Feb 2018 07:16:34 -0800 (PST) X-Google-Smtp-Source: AH8x225A+/GmLuCP65jZxMX4qv8oxUwESoFi+NpNVEmS/BkYTG0wy9/kw+WhU8VGx2MlGFpSESak X-Received: by 10.98.56.150 with SMTP id f144mr2120124pfa.150.1519398994617; Fri, 23 Feb 2018 07:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519398994; cv=none; d=google.com; s=arc-20160816; b=QVVuqxh37a5iW82EKloGgALI5Oo2z0qlbJaGEJo54WGOZpvvxJ7RN+bVYZZP++Z21i 9vuUtidnciUVeilYSwNBhtZAoagEAQA7p3Pv2dkOL7kXMwMxNVnQf2qvrsaq8DMKY+XN nRc24QQcmU2Tt8SX8QEYMZr2G3ZvYBNKWPcVTorFBu9PnIREjMXZmwzsxbfZSFgLLhXA c1uDi2yoxUFgFCB1jbdNNNNY1ugCE9ppH3YYI1FaW3qN0ey2vT+EtEHhdfxHEr+KBNW6 wOSvBun4QHN8hHttDEN/My+IZRjmirFnx/9XmfuUTOcjHVm4pJHUyu0MqKegiY1wdFrA b4TA== 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=G2nU+dKi/TApBx3Q8w2Q5fXzW7lasbyCM6H9nNFWvz0=; b=e6PonZlCg5Et6gpHH3RoE1tm+/iUVgqSM4i/mqj4NW0ZcF8S/5hOJeV1oSEhP6HqL1 AsJWvJNHxV/ZVWyoM4yeg3eTO6vUpLRMmb1uveQrPFSC3c4lhbLSJU+JzlJhc3hFEQq7 Lq8AkZ8EAXVjA/xFsWJqWcEPvtCBCmhtCSCHMRbbTUFpJOdnz0tobfsSWH1zcl/glkPd 5tZ/3VAPg446r7KZihvUPrcaClt//fdrZexpbB6Kmb7NQJgChrHiXv4PBqPzP4zKZB2a xVNaeQ1NWO347Bh1+B6dCjY5L69aEJBuJNzGRM9aTptmVfWdUSyfFhMt1gxZXQMwvoIk Q2Ww== 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 i1-v6si1906995pld.42.2018.02.23.07.16.19; Fri, 23 Feb 2018 07:16:34 -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 S1752007AbeBWPOb (ORCPT + 99 others); Fri, 23 Feb 2018 10:14:31 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:39963 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751904AbeBWPO1 (ORCPT ); Fri, 23 Feb 2018 10:14:27 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E993A91A9A3D5; Fri, 23 Feb 2018 23:14:19 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 23 Feb 2018 23:14:12 +0800 From: John Garry To: , , , , , , , , , CC: , , , , "John Garry" Subject: [PATCH v2 03/11] perf vendor events: drop support for unused topic directories Date: Sat, 24 Feb 2018 00:05:24 +0800 Message-ID: <1519401932-205051-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519401932-205051-1-git-send-email-john.garry@huawei.com> References: <1519401932-205051-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 --- 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