From patchwork Tue Jun 11 18:58:19 2019 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: 166472 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2721510ilk; Tue, 11 Jun 2019 12:01:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYLE3eGYFom6k3+QbGTjfnUBJhFXMkmh8PoJfNBrt1IkVOmxg1HM0zKfGhWdZpL+AcseAt X-Received: by 2002:a63:8042:: with SMTP id j63mr5288619pgd.239.1560279713306; Tue, 11 Jun 2019 12:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560279713; cv=none; d=google.com; s=arc-20160816; b=Iz14EQvYAFT9I5PgegCxFxJGihjKyZeVixI9Nxcisn8k9WYtg7CneiGSfgX/38k6f6 2KfvMPxP+GEik9KLDRzPlWFILzc+oNxIw505sLFpdpZ3mGbkvHCGCFGvbYQuLHnP3zu5 Gxxw7XBBRZD+/nKa+vMZ9jV/YZskjid7jWJYki7bylOJ7QTTATGcZF3pal1bZAdQdjPe aYZj/TSlZsbh0EaoTgFLmW8nDk20w1XOLAjlC0p8Jlb1s5MKlmeEnOGj6vOZ3z918wlY 86JgIAjuyu/Uxsf3k8rYNm36e1EHjZD6oRer51NM3CkMfloFp4zcnch/08QhHfxgFhhn 8d4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xE3nEr4zffUsqs3HvxhD6Hz+rS6yOV1GmHCIhoDAuHg=; b=yD9FyFm2L6w2pG5kPRZS02tTALtEDgBcYtto3mAKAbJamM2uHwfY8xE2kqCTo0A5h/ iJfNjyx6fdQ4Uyy0IjovxW1HfzsP+7528j9K/gLR/xjUzuxAuKUWDt9ddYuzUC8Actfo iFWN9s2ieXF8CgL3wvDiUfwi7Y3qCtryVtIJ5z64d5Q+AXyM4VB+rMYVBJQhEFac49g3 ROXvDYOq9034Jpr79wREv4ZWCwFyUI7Jb2aPfQUU4zmb1pROAU0nfUttKDr4k79Z3zn6 5DD4R6mRriE00sYJARq+3rjkKS2RFF5ks5O3VgPJufIygrhcsepr6c4S9qgkNv+KbKhg m8GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GWvxEU+c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si1183388pgq.564.2019.06.11.12.01.52; Tue, 11 Jun 2019 12:01:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GWvxEU+c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392304AbfFKTBw (ORCPT + 30 others); Tue, 11 Jun 2019 15:01:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:38056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388445AbfFKTBv (ORCPT ); Tue, 11 Jun 2019 15:01:51 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.35.11]) (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 B6D3C2184D; Tue, 11 Jun 2019 19:01:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560279710; bh=heC0QYeS5YTC+MsORVxIBCYxOA5dsTe559ukfImRyFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GWvxEU+c+a48E8JEIaDFyUT1E12DPO1UTZZ3RLeENEUkHjxuxE98B8UfY6GwsbaOD PF05DYDo+y0owE6IjDprbv5upn220jTQggsMCQlpmjjKDIDLb75RYlgcRGVjI8b34X aeQLNTFWpb99lqEcEzdi+yohgY5xMXsDexRrhFsY= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , Alexei Starovoitov , Daniel Borkmann , Jiri Olsa , Martin KaFai Lau , Mathieu Poirier , Mike Leach , Song Liu , Suzuki Poulouse , Yonghong Song , Arnaldo Carvalho de Melo Subject: [PATCH 33/85] perf trace: Exit when failing to build eBPF program Date: Tue, 11 Jun 2019 15:58:19 -0300 Message-Id: <20190611185911.11645-34-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611185911.11645-1-acme@kernel.org> References: <20190611185911.11645-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan On my Juno board with ARM64 CPUs, perf trace command reports the eBPF program building failure but the command will not exit and continue to run. If we define an eBPF event in config file, the event will be parsed with below flow: perf_config() `> trace__config() `> parse_events_option() `> parse_events__scanner() `-> parse_events_parse() `> parse_events_load_bpf() `> llvm__compile_bpf() Though the low level functions return back error values when detect eBPF building failure, but parse_events_option() returns 1 for this case and trace__config() passes 1 to perf_config(); perf_config() doesn't treat the returned value 1 as failure and it continues to parse other configurations. Thus the perf command continues to run even without enabling eBPF event successfully. This patch changes error handling in trace__config(), when it detects failure it will return -1 rather than directly pass error value (1); finally, perf_config() will directly bail out and perf will exit for this case. Committer notes: Simplified the patch to just check directly the return of parse_events_option() and it it is non-zero, change err from its initial zero value to -1. Signed-off-by: Leo Yan Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Jiri Olsa Cc: Martin KaFai Lau Cc: Mathieu Poirier Cc: Mike Leach Cc: Namhyung Kim Cc: Song Liu Cc: Suzuki Poulouse Cc: Yonghong Song Fixes: ac96287cae08 ("perf trace: Allow specifying a set of events to add in perfconfig") Link: https://lkml.kernel.org/n/tip-x4i63f5kscykfok0hqim3zma@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f7e4e50bddbd..1a2a605cf068 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3703,7 +3703,12 @@ static int trace__config(const char *var, const char *value, void *arg) struct option o = OPT_CALLBACK('e', "event", &trace->evlist, "event", "event selector. use 'perf list' to list available events", parse_events_option); - err = parse_events_option(&o, value, 0); + /* + * We can't propagate parse_event_option() return, as it is 1 + * for failure while perf_config() expects -1. + */ + if (parse_events_option(&o, value, 0)) + err = -1; } else if (!strcmp(var, "trace.show_timestamp")) { trace->show_tstamp = perf_config_bool(var, value); } else if (!strcmp(var, "trace.show_duration")) {