From patchwork Tue Mar 13 12:04:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 131445 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp643667ljb; Tue, 13 Mar 2018 05:06:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELs0U2FCgu2E0Knup6gxWpT1JqPo5r59MpRPspm2MO0+jyxQQbSwFqOYqoiB4vqWQIWbm17o X-Received: by 10.98.1.88 with SMTP id 85mr382267pfb.226.1520942776941; Tue, 13 Mar 2018 05:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520942776; cv=none; d=google.com; s=arc-20160816; b=eALqCgGDUL3VYlkb5KtXuTKYXOmOiHivjId0ru6bxZ2QztMWIWuUbcZA2FLNTgUatG ktOj6V+5u4KXIyrewEXQ+TvAHL74nKt+TZcHyzqBYQwVIZx6aGdDtvPyELt//vOoviJL i+xJPG43asmht3icPgIFl/9ulrITu4obfknbAvBc0c104BTRC5IwH0OiIXWo5SUYzH+z 00VhBmClBaOivwzdMlYbvnIlqxlVg2yXew0+JDXvC9WPofNAN17AWzHHsCxS+Po5qqOL i2ieWkP/U4RHw+UYW8vLawNu8jQBFkrXZGrxKgbM0X8KQrRFLwrMnHEWbu2mDSsJuE91 EG4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=0ovJVhiOIQLS4qbGHE8Mvzl3SvYvUK+icZyFPhsdf60=; b=H16pux+O1Q00HBA+Iio/HMoNu8/DCJrAP1KES6cmNnlVvpkaSGngjyOJ0CXIEyS/9Y +SJjlA/i8P//FnS2Uhs9zVBdbYzkGnBGynLDiZQMjQArvQUh7zWakDtp8CiEFjROv7Ry j03sXGDmzRPQfgLLcMytlkmGSzXKELLLZB3f+9LxcBR2mahmsv2y6rj0ulYaJbzKUBP1 iitnavDkb4vnv15T94tPx7TARN/cY5ABog1bVw3sFQzk6LKQhUsg/8k9673JUw8MnFM1 HeUzjr8QRGKB1MRy/S9DF2/nKpC/skkH2gbTZ/r39WHClMjAIb3cSgMGJhfbEGmHCPMH TKOQ== 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 y6-v6si49970plr.174.2018.03.13.05.06.13; Tue, 13 Mar 2018 05:06:16 -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 S933291AbeCMMGK (ORCPT + 28 others); Tue, 13 Mar 2018 08:06:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:54834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933266AbeCMMGI (ORCPT ); Tue, 13 Mar 2018 08:06:08 -0400 Received: from jouet.infradead.org (unknown [177.79.83.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1617121796; Tue, 13 Mar 2018 12:06:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1617121796 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, John Garry , Alexander Shishkin , Andi Kleen , Ganapatrao Kulkarni , Namhyung Kim , Peter Zijlstra , Shaokun Zhang , Will Deacon , William Cohen , linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Arnaldo Carvalho de Melo Subject: [PATCH 13/31] perf vendor events: Drop support for unused topic directories Date: Tue, 13 Mar 2018 09:04:50 -0300 Message-Id: <20180313120508.29327-14-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313120508.29327-1-acme@kernel.org> References: <20180313120508.29327-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry 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(-) -- 2.14.3 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; /*