From patchwork Thu Mar 8 10:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 130984 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6329919lja; Thu, 8 Mar 2018 02:59:54 -0800 (PST) X-Google-Smtp-Source: AG47ELtfBwMiW1ZucR6Egknnysq+YuyExH64RyCZW04vrKAKhWH0BwJGqKn0lm6eDivV3Y6k1isz X-Received: by 10.99.116.28 with SMTP id p28mr20955614pgc.306.1520506793863; Thu, 08 Mar 2018 02:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520506793; cv=none; d=google.com; s=arc-20160816; b=zEPEWz1OJdIFCxMPEOfveGCiV9rWCfVQL9NqMVzvogVXMFtfMvFi9ZwK74VskN7yAq kY4RZm2HEhQHC/sYj3mtFxHcIDpq/yJNZt5QCQjd/GesMjPlLUrP205dpCXj2mswuup8 ym9IiJehnrC3Im+GVqKY1OiJDjcclmIPwai8s+x4eVxOdxu84xJ5jKTNCo3Ns9fFm5tS NhQLFQcF3tzj3rfenvMGBRWqPGU14hPa6HeUh0ojeG6kIxClpZP00s+02olxnMwb88v0 VO2GqpNVm8UFqvmLwFbmu5OdfsmJJm8XN91eRyee9j+gY1NUo52stnoOF8Meh49BQyxq jrXA== 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 j33-v6si14734711pld.442.2018.03.08.02.59.53; Thu, 08 Mar 2018 02:59:53 -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 S964794AbeCHK7t (ORCPT + 28 others); Thu, 8 Mar 2018 05:59:49 -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 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(-) -- 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; /*