Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp856949ybk; Wed, 20 May 2020 13:53:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLSJP8+yDtPSELHylFY/zkh8CdW6A4YJC8moRSXO9cDsyo6A2QYn1SiAaur5tFvywGnkQN X-Received: by 2002:a17:906:9490:: with SMTP id t16mr833278ejx.413.1590008030742; Wed, 20 May 2020 13:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590008030; cv=none; d=google.com; s=arc-20160816; b=MgWrsWwePAaND5sz2C1tqLXDzt6O9HlMrsEO7QbocBl4D0Uwb2vCM++HzE1qUXBIyr G4TSHVbl7S1cxKLHXtXVsbBCqdfd/n3wuQTrpLZc2yDfBhw2OYpf2/nV/gphrcgPU0gE 934k0Dq0FQtVpO3UIjlP19ZUenCi1bHuGGkqUXe7bbpus6po5afv7LCKyW1WgJLt0hmQ 7PsHSvbSFp7wBNOwX30oNLMM97HqZcBnueITzQbryBD0UrBYROa4uOgKclS4ogf0ozP6 OthzauaHBJisRIL0B+P3osapdzcc8VZwUScD6SB0J0p1w+RYkXmlGiw3ZQUoRRCI46h8 3yjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=V0FGnfT9DYG8JC6cAGC4OKFve9lrrYAtfll5qCblQ+8=; b=hHdmzYFlDZk082Equo+IDwPhyb/93pjAqAMq1siaHMBHKlqlhT/atFl5rDViu1xJfU uLcqf5k4v4wtZB165V9CihIZlLLywh5gzjIjUrtfsJtdJ3YFM2t7tXdaLEwRHYEzl6ON hCKF1updxUyGL1D/hTsyYREdDlFR3vVOZdDyrSPKY9fIIz3e+j+UmrC2Cn9r2lN4TH1i nELcHu6ufeyIfdaYOvtb7EqAzbLsohThtZ+8xd18Q7SVIMniaTG6MAdyTqv/6Ig7UUDm COcjhyQXO4qaJ+2yFS1E2TqTR9gJUaBCU7NrHN/N4NqPO4NChGc2guiSN/KJLlhfnN8/ 0dCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Qd//t7SJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oy4si2177902ejb.433.2020.05.20.13.53.19; Wed, 20 May 2020 13:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Qd//t7SJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728032AbgETUvG (ORCPT + 99 others); Wed, 20 May 2020 16:51:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:48440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728019AbgETUvG (ORCPT ); Wed, 20 May 2020 16:51:06 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 596C020756; Wed, 20 May 2020 20:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590007865; bh=f5ZjuQZHOyOJalpcVvxXRlHkEct0Vs8p9XAUEBDokrs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Qd//t7SJil89L+3KueWSVoahjbKgKmrETISU0aAsdikuJhHU62WjvjccEg6VenOyD k6A0qZgfLxlQVBlPztWzGRITf4QFm0OGJJGO2ivPoeEtWUWfFPtJwUnhPV6G15bqT9 x5blc5cr9SB5Fsrw6l4/wkdL+1tqtI8De/XMv4Ws= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 4F9E740AFD; Wed, 20 May 2020 17:51:03 -0300 (-03) Date: Wed, 20 May 2020 17:51:03 -0300 From: Arnaldo Carvalho de Melo To: Changbin Du Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/19] perf ftrace: detect workload failure Message-ID: <20200520205103.GP32678@kernel.org> References: <20200510150628.16610-1-changbin.du@gmail.com> <20200510150628.16610-3-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200510150628.16610-3-changbin.du@gmail.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, May 10, 2020 at 11:06:11PM +0800, Changbin Du escreveu: > Currently there's no error message prompted if we failed to start workload. > And we still get some trace which is confusing. Let's tell users what > happened. Applied, but please in the future add Before and After output of the commands for these to be clear even to my 4yo kid: commit 2a5193e460eaf8792a87f678e3c5f78c88db2123 Author: Changbin Du Date: Sun May 10 23:06:11 2020 +0800 perf ftrace: Detect workload failure Currently there's no error message prompted if we failed to start workload. And we still get some trace which is confusing. Let's tell users what happened. Committer testing: Before: # perf ftrace nonsense |& head 5) | switch_mm_irqs_off() { 5) 0.400 us | load_new_mm_cr3(); 5) 3.261 us | } ------------------------------------------ 5) -0 => <...>-3494 ------------------------------------------ 5) | finish_task_switch() { 5) ==========> | 5) | smp_irq_work_interrupt() { # type nonsense -bash: type: nonsense: not found # After: # perf ftrace nonsense |& head workload failed: No such file or directory # type nonsense -bash: type: nonsense: not found # Signed-off-by: Changbin Du Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steven Rostedt (VMware) Link: http://lore.kernel.org/lkml/20200510150628.16610-3-changbin.du@gmail.com Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index b7d3fb5fa8b1..2bfc1b0db536 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -45,6 +45,7 @@ struct filter_entry { char name[]; }; +static volatile int workload_exec_errno; static bool done; static void sig_handler(int sig __maybe_unused) @@ -63,7 +64,7 @@ static void ftrace__workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *info __maybe_unused, void *ucontext __maybe_unused) { - /* workload_exec_errno = info->si_value.sival_int; */ + workload_exec_errno = info->si_value.sival_int; done = true; } @@ -383,6 +384,14 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) write_tracing_file("tracing_on", "0"); + if (workload_exec_errno) { + const char *emsg = str_error_r(workload_exec_errno, buf, sizeof(buf)); + /* flush stdout first so below error msg appears at the end. */ + fflush(stdout); + pr_err("workload failed: %s\n", emsg); + goto out_close_fd; + } + /* read remaining buffer contents */ while (true) { int n = read(trace_fd, buf, sizeof(buf)); @@ -397,7 +406,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) out_reset: reset_tracing_files(ftrace); out: - return done ? 0 : -1; + return (done && !workload_exec_errno) ? 0 : -1; } static int perf_ftrace_config(const char *var, const char *value, void *cb)