From patchwork Fri Nov 3 11:44:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Thierry X-Patchwork-Id: 10039867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07E4C6032D for ; Fri, 3 Nov 2017 11:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E937E29592 for ; Fri, 3 Nov 2017 11:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC19C295B4; Fri, 3 Nov 2017 11:45:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 689EF29592 for ; Fri, 3 Nov 2017 11:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Dc7aEE9PJx8VkVwaFpN/gAc0NPwUAUoH+dUOFMuYovk=; b=ZnXUC3N1nFGqeeYuCKAjdV33a7 f1B5HKH07RWLetBYJqjhm2+iUt+W2YTGx6YAMwtrsGKjQXi6qq6WtBVpP208ABuj0/MHSvMmOg1fD 5nMlPU8F+F/6ZD0Cp5aNYHyGfONS+OhnjukwIeI18vbL4iARskZdiBYtPr6UfUNMtiGwi3vvDCgNH xQGJ98kzGPZ9M62aXST/jCYof0HbzIVLoKRC0KhCt09nyYeZG13UI+LZq8Vai/tcaQMEQRLMM92OV 8ryiCnDmykt0mG/muF6pJQGsR5Vl46PZsWry7n2GtpithozDhCg0LBL0SpFt5hnUCBVK1+2AWHzhd DGLahPQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eAaQ2-0002N0-J1; Fri, 03 Nov 2017 11:45:50 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eAaP5-0008L0-4j for linux-arm-kernel@lists.infradead.org; Fri, 03 Nov 2017 11:44:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C10B91650; Fri, 3 Nov 2017 04:44:32 -0700 (PDT) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 245F33F25D; Fri, 3 Nov 2017 04:44:31 -0700 (PDT) From: Julien Thierry To: linux-arm-kernel@lists.infradead.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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171103_044451_542071_65178BF8 X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Julien Thierry , Peter Zijlstra , Will Deacon , linux-kernel@vger.kernel.org, rostedt@goodmis.org, takahiro.akashi@linaro.org, Ingo Molnar MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) -- 1.9.1 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;