Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753009AbbHaIdD (ORCPT ); Mon, 31 Aug 2015 04:33:03 -0400 Received: from terminus.zytor.com ([198.137.202.10]:37893 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752974AbbHaIc5 (ORCPT ); Mon, 31 Aug 2015 04:32:57 -0400 Date: Mon, 31 Aug 2015 01:32:41 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org, a.p.zijlstra@chello.nl, matt@codeblueprint.co.uk, mingo@kernel.org, raphael.beamonte@gmail.com, dsahern@gmail.com, jolsa@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org Reply-To: acme@redhat.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, raphael.beamonte@gmail.com, dsahern@gmail.com, a.p.zijlstra@chello.nl, mingo@kernel.org, matt@codeblueprint.co.uk, hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org In-Reply-To: <1440596813-12844-3-git-send-email-jolsa@kernel.org> References: <1440596813-12844-3-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add tracing_path and remove unneeded functions Git-Commit-ID: 9f44f0cc1c32f1542071447a9493652bbc03facb X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4077 Lines: 134 Commit-ID: 9f44f0cc1c32f1542071447a9493652bbc03facb Gitweb: http://git.kernel.org/tip/9f44f0cc1c32f1542071447a9493652bbc03facb Author: Jiri Olsa AuthorDate: Wed, 26 Aug 2015 15:46:44 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 28 Aug 2015 14:53:51 -0300 perf tools: Add tracing_path and remove unneeded functions There's no need for find_tracing_dir, because perf already searches for debugfs/tracefs mount on start and populate tracing_events_path. Adding tracing_path to carry tracing dir string to be used in get_tracing_file instead of calling find_tracing_dir. Signed-off-by: Jiri Olsa Cc: Raphael Beamonte Cc: David Ahern Cc: Matt Fleming Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1440596813-12844-3-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/util.c | 56 ++++---------------------------------------------- tools/perf/util/util.h | 2 +- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index f7adf12..d33c341 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -34,6 +34,7 @@ bool test_attr__enabled; bool perf_host = true; bool perf_guest = false; +char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing"; char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; void event_attr_init(struct perf_event_attr *attr) @@ -391,6 +392,8 @@ void set_term_quiet_input(struct termios *old) static void set_tracing_events_path(const char *tracing, const char *mountpoint) { + snprintf(tracing_path, sizeof(tracing_path), "%s/%s", + mountpoint, tracing); snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", mountpoint, tracing, "events"); } @@ -440,62 +443,11 @@ void perf_debugfs_set_path(const char *mntpt) set_tracing_events_path("tracing/", mntpt); } -static const char *find_tracefs(void) -{ - const char *path = __perf_tracefs_mount(NULL); - - return path; -} - -static const char *find_debugfs(void) -{ - const char *path = __perf_debugfs_mount(NULL); - - if (!path) - fprintf(stderr, "Your kernel does not support the debugfs filesystem"); - - return path; -} - -/* - * Finds the path to the debugfs/tracing - * Allocates the string and stores it. - */ -const char *find_tracing_dir(void) -{ - const char *tracing_dir = ""; - static char *tracing; - static int tracing_found; - const char *debugfs; - - if (tracing_found) - return tracing; - - debugfs = find_tracefs(); - if (!debugfs) { - tracing_dir = "/tracing"; - debugfs = find_debugfs(); - if (!debugfs) - return NULL; - } - - if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0) - return NULL; - - tracing_found = 1; - return tracing; -} - char *get_tracing_file(const char *name) { - const char *tracing; char *file; - tracing = find_tracing_dir(); - if (!tracing) - return NULL; - - if (asprintf(&file, "%s/%s", tracing, name) < 0) + if (asprintf(&file, "%s/%s", tracing_path, name) < 0) return NULL; return file; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 88a8915..291be1d 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -83,10 +83,10 @@ extern const char *graph_line; extern const char *graph_dotted_line; extern char buildid_dir[]; +extern char tracing_path[]; extern char tracing_events_path[]; extern void perf_debugfs_set_path(const char *mountpoint); const char *perf_debugfs_mount(const char *mountpoint); -const char *find_tracing_dir(void); char *get_tracing_file(const char *name); void put_tracing_file(char *file); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/