From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756116AbdKCLoe (ORCPT ); Fri, 3 Nov 2017 07:44:34 -0400 Received: from foss.arm.com ([217.140.101.70]:41184 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752854AbdKCLod (ORCPT ); Fri, 3 Nov 2017 07:44:33 -0400 From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: takahiro.akashi@linaro.org, rostedt@goodmis.org, Julien Thierry , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] perf: Fix ftrace builtin when kernel doesn't have function_graph Date: Fri, 3 Nov 2017 11:44:18 +0000 Message-Id: <1509709458-44541-4-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509709458-44541-1-git-send-email-julien.thierry@arm.com> References: <1509709458-44541-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When linux is built without support for function graph tracer, the ftrace builtin of perf will fail when trying to reset max_graph_depth because the file does not exist. This prevents the use of function tracer from perf. Only try to write the file max_graph_depth file when it exists. Signed-off-by: Julien Thierry Cc: Will Deacon Cc: Mark Rutland Cc: Peter Zijlstra Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org --- tools/perf/builtin-ftrace.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 25a42ac..1abc066 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "debug.h" #include @@ -116,6 +117,13 @@ static int append_tracing_file(const char *name, const char *val) static int reset_tracing_cpu(void); static void reset_tracing_filters(void); +static inline bool tracing_file_accessible(const char *name) +{ + struct stat s; + + return stat(get_tracing_file(name), &s) == 0; +} + static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) { if (write_tracing_file("tracing_on", "0") < 0) @@ -130,8 +138,12 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) if (reset_tracing_cpu() < 0) return -1; - if (write_tracing_file("max_graph_depth", "0") < 0) + if (!tracing_file_accessible("max_graph_depth")) { + if (!strcmp(ftrace->tracer, "function_graph")) + return -1; + } else if (write_tracing_file("max_graph_depth", "0") < 0) { return -1; + } reset_tracing_filters(); return 0; -- 1.9.1