From patchwork Fri Feb 23 16:05:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 129374 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp748202edc; Fri, 23 Feb 2018 07:15:12 -0800 (PST) X-Google-Smtp-Source: AH8x225PzD1H2cA0hjx+3SuYqwKhR2rxm/7Z5rDR44F7eaYhHtQaKbfnP1+jsn4OI7kwDe+ZoLKr X-Received: by 2002:a17:902:b904:: with SMTP id bf4-v6mr1995782plb.195.1519398911922; Fri, 23 Feb 2018 07:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519398911; cv=none; d=google.com; s=arc-20160816; b=bcBXRQCqjNTCnVTTI60EBiXricR4eho3pS+0RHWbjCfNYomVUwa9D+iMA4JYuHBeXp kyd7tW+SgLzWzfCtlKE8JhTxktz6awDGuE0rb88O0bp/8WkhrLNYSrCqI3okEales1p9 US02+RwLOduIXTQp7Jcb6l0EzZxrXZk6Znfr36aWhBNxriu9v2obTv2hPRw3oiUuGA15 qmfcB9kHsKhAGW9w/5BVyHDK9oiROlzK6cT5cclsy6S5RwqrEalvLZ3HnLjEwR1PYmTw 1rECeZ/Fzs8G2HeIujeKY3CdzFwcTSXduQfUK0KeT6ZWkFrMHCbGIjWKIZ7A8tOAcTIs r6EQ== 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 a190si1627611pge.436.2018.02.23.07.15.11; Fri, 23 Feb 2018 07:15:11 -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 S1752011AbeBWPOb (ORCPT + 28 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 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(-) -- 1.9.1 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; /*