From patchwork Thu Jun 6 07:56:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 165953 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp8440491ili; Thu, 6 Jun 2019 00:56:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnPCjM8p0RjE2YLrkFw+YblFNKCr6c8sbVXN0tffvQ1NLK7aipdRdiPaPGm9r1mkIy5384 X-Received: by 2002:a17:90a:29c5:: with SMTP id h63mr15677297pjd.83.1559807809028; Thu, 06 Jun 2019 00:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559807809; cv=none; d=google.com; s=arc-20160816; b=za+p/spmFAwauChWA2dVG7Mw9vI4CApZHhJn9iJqYauAaAJ/G+KV0p86VRlpAW5g5Z b73nCnjH4e+Fnbkvs9ivKJCc/L+Il0j4PZIqXl5nOf2cIDyfeJQpJJ6RI4KQC4R0FLEh HS+EYig3t/DKAXE2q5TQnzRIKu8WfRxWlbqGAN0y87Di2bTtnWpBf3GpejtHbB8VjGkn r5x7+AFEIuYXxmkvZ73KcYhUVyuloyY2NV2HLxLJO3ekKYbVINuZb0K0VGju/bhZiQ5M eFmKVQZr3F1beyU8yKT8NX1whlT0AyItuYqP362VUXwiajAfyo5ySeexdvFLdg1jMn1e i4mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TbM9vdATYDfk/+/NGyr5Ij8vLHhNayhJciB4ayq0pHE=; b=l3Ph0fMe7C92j0ey3VVpboPOMn7aMSm5wny1RIT0Wud/znLFd7tSUdP2LMVI5u+kvq pkQGRkuDmA51z2cewGPkfFG0g3me77e7sbOyZaY0wSWvjXh+vSXkIpqLD1X+5kDXLbf6 YLfhZx+XwZOfwiVHYJ60wtMqv/LidRb4pHjjDUgDqlDB0CYpPY2bZAIrh/0vIjpIiAro b4yrRdyteIyCHXkGQBdchoIQRGqst7Wc5hsROnqfAerLRPf98EmUANLLZIZRpQsNNA9G tYKc10TFTR/utD5wX7P7sBK/RJYKSHzf3o/7djCjno/9cvlQXEAMU5TmqAV2HMVcqsf6 FEMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MM6OcPwA; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 195si1387556pgb.327.2019.06.06.00.56.48; Thu, 06 Jun 2019 00:56:49 -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=@linaro.org header.s=google header.b=MM6OcPwA; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbfFFH4s (ORCPT + 30 others); Thu, 6 Jun 2019 03:56:48 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:39670 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfFFH4q (ORCPT ); Thu, 6 Jun 2019 03:56:46 -0400 Received: by mail-yb1-f195.google.com with SMTP id c5so600318ybk.6 for ; Thu, 06 Jun 2019 00:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TbM9vdATYDfk/+/NGyr5Ij8vLHhNayhJciB4ayq0pHE=; b=MM6OcPwAJE1POnI9pGXHiBCNozL4ZBtxEn7ju0XByHG94g+QwzU/iiSy44DRpp3Unm FYPVos2EGcDv26xHAbZRORvla6calNQz4bJPO419a6f/RVB0FqB0wnH1K0bpliXR0snw 7ot9cbH/X6rWk2AYvw88dVCramLl96KtBpZ1KfzV2MpsNBY4AyKGEvjdqNYoBwh/sjkW gUEd8CXA/N5zkn4EkSVFtCQDgodRSQ8TkO+0BilrhFBNsCQ9aIwwObLfuDN5/Oj/vvQl TW6ZP85+pOrzanq+88wrhLAf+HYTSw9GTGEEHwRyRLCTKy19juEFCNEovH81pwPXf6dP ohkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TbM9vdATYDfk/+/NGyr5Ij8vLHhNayhJciB4ayq0pHE=; b=U+BJ6df1akpHpsyYlKZMMEe+/LggLHU2HLulqrCNIwsxnd5ZY2twADtTGyFReRlohl U1Ln+t6C5ClmPOQTh1UFOHno/fxVKDNlnYa52FEru2XdtVyA/PVS3b4zJZE86aCeRTY0 c2DDu4q7s3ujOXVLBFL3DvHiuQ4+FeAcoQ0mP/4gFjdBmFdTLuvvnHdEqvrt4YmSomVF NUI1B2PMn314VUO38ObRlSxkBX/6BoufUe1N00JhBxhieWyHicRlUwRE6Bj2PETSONlU MOiEp8CLHW5I4gm9cEFyLp/GtuMA7+lsPilgNMIFQDcXCJrFZABvdVK6a30JAL2b1aAT 3I4g== X-Gm-Message-State: APjAAAU/Pv/t2y5mCxqFkWlFwkVTDPoq8me+FDjRW3S6jFMuQknper6s mc0He6qxTTrPSE4DemukQGCYOQ== X-Received: by 2002:a25:410f:: with SMTP id o15mr20004920yba.328.1559807806138; Thu, 06 Jun 2019 00:56:46 -0700 (PDT) Received: from localhost.localdomain (li1322-146.members.linode.com. [45.79.223.146]) by smtp.gmail.com with ESMTPSA id 14sm316343yws.16.2019.06.06.00.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 00:56:45 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Adrian Hunter , Mathieu Poirier , Mike Leach , Suzuki K Poulose , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/4] perf trace: Exit when build eBPF program failure Date: Thu, 6 Jun 2019 15:56:14 +0800 Message-Id: <20190606075617.14327-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190606075617.14327-1-leo.yan@linaro.org> References: <20190606075617.14327-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Leo Yan --- tools/perf/builtin-trace.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 54b2d0fd0d02..4b5d004aab74 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -3664,6 +3664,14 @@ static int trace__config(const char *var, const char *value, void *arg) "event selector. use 'perf list' to list available events", parse_events_option); err = parse_events_option(&o, value, 0); + + /* + * When parse option successfully parse_events_option() will + * return 0, otherwise means the paring failure. And it + * returns 1 for eBPF program building failure; so adjust the + * err value to -1 for the failure. + */ + err = err ? -1 : 0; } else if (!strcmp(var, "trace.show_timestamp")) { trace->show_tstamp = perf_config_bool(var, value); } else if (!strcmp(var, "trace.show_duration")) {