From patchwork Thu Jun 6 09:48:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 165969 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp8551481ili; Thu, 6 Jun 2019 02:49:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXpZaDiDj9hDhYPXAhdnksJEJi8qbhMSfx6tiILls5tsvLNudtI3f9QWk0X++wYoXqdz0U X-Received: by 2002:a63:3dcf:: with SMTP id k198mr2610407pga.60.1559814554046; Thu, 06 Jun 2019 02:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559814554; cv=none; d=google.com; s=arc-20160816; b=jk7Fj0s2iDEwi42eFqXkV7kcsNdDA76kBjTaiFjpy/JsElb4ddJS6QKUsDuZ42+nw1 Q5s1M8s1qTHsc90sqmRTPdH1S2BRs3vryuiLJD1Zlf/O7rLOudSp4Jb4G4+eNvw05c+q w6JEgY2jOr8FcvgqKU8SZGzOAUleYYxQhkpf3PtKFfeAvCKgRTcLqHym+0RAsYorp67a WMG+bQfVk/9BydKlmQM6bamRBKdGvZwxdfc/eXMTyv72VQzKaJQxMmnh2MLp/mowjS4w Zvz0tozrVvB3wDfMP/JW6Sc0/5MEeLdxSUsIqsKloC79N7OE6c/tDg7HdZ+jYgW5yOdA cYUQ== 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=Z69gicwAXZGpi8VRS0iC9YC/b3qgAqndAAc2IT4RqWJJvwfRBu2dwZvtWZeST/Ya/b HD2PM3K85z3hgC2c6+HIAN0LhWFdVcBHSLpq3sRSoWuSxBxj2IF34q/eYwzH1x3tQx14 xtR7Cbeb4pk4HqfCXWfQJNM6XRQMjK83n7aW/VRVoFap2yatBQceQjZGjXEGwNp/Dstx zlssuLntVQ8LcqMPQtVlQoHRcNuORLtfw8UikIwCMgY/OL7nlVJrJ80PMoaHxEWEqPcV KzImP8RI6bVhXdWyikVIOItPqGOgC5Drw/HNHogzKDY/ItyvKmURO2mnInXI3babxggd npoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zsmhUT89; 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 f9si1665811pgs.115.2019.06.06.02.49.13; Thu, 06 Jun 2019 02:49:14 -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=zsmhUT89; 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 S1728259AbfFFJtN (ORCPT + 30 others); Thu, 6 Jun 2019 05:49:13 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:36728 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728042AbfFFJtM (ORCPT ); Thu, 6 Jun 2019 05:49:12 -0400 Received: by mail-yw1-f67.google.com with SMTP id t126so622255ywf.3 for ; Thu, 06 Jun 2019 02:49:12 -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=zsmhUT89ZCU+vNeRBa0UgwcQ66/LK2vtVlacT4gsa9cFjC90MQ8ROW63aFSV62iPsp Zhty+47a4l8hIKT608jS4i4FRWolQ5jbQhFfv9k/mb0f64f2CIV7eBsPlgiXdJOsv5zv 08PNfooIZ/y0/wggtCO+S4g13FA1Jgim2U9DHC7DsgnH93W4iW2kP2HPvZQNTHOIyAR3 BXFeaXkSBqi4zatoIlydBllcFCzPF33fE8ZEXzMyR35cxvv+83MpCdF7+H5rytfsWp8U A4nsx2Q3AucQw18xPGRYXHNuwx+vGPkJR8k7sacgA5qWAg4h8APJ4SuIjzGint0Bluho jGfA== 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=P93SRZt+mTDcyArZ0FeBiWoMCEV/NpxrJgKdOFZ5eBToYQvD5wI6nfh0AWalW8JUUS m40aCZSY83MXeNYjWXtpJcRxC2IHnncT++ycQtv4vlnCem8jT7iu5XuAZ5mMr8eG5sOH hXIZf1YqyZtOyzfXnKd6cid4nvsG3DK/sYvgG7ixaWJvsmlJnaC/X4GPwe6U5aEBdDB1 94LqW2hUiHTYn/m8shrbsk/D7ifLwF7bLNuaFyXn3yx7PrNIqLNYKxGGmrAD8FQVW6bH crqE8ROsWOsfS4hznhWDPCQFzy/h/uYM/A9ec8epFMzpN6+AagPiBiGUelpq30SEnro0 3YIg== X-Gm-Message-State: APjAAAWAGBLPk0zEkDB4v9tvU+qpEky9VH+unbcZdk1WunyDVMuAZEil le6ns86G1g8AGwn1KRErK+VhaQ== X-Received: by 2002:a81:3c90:: with SMTP id j138mr24229019ywa.1.1559814551800; Thu, 06 Jun 2019 02:49:11 -0700 (PDT) Received: from localhost.localdomain (li1322-146.members.linode.com. [45.79.223.146]) by smtp.gmail.com with ESMTPSA id 85sm357652ywm.64.2019.06.06.02.49.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 02:49:11 -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 v2 1/4] perf trace: Exit when build eBPF program failure Date: Thu, 6 Jun 2019 17:48:42 +0800 Message-Id: <20190606094845.4800-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190606094845.4800-1-leo.yan@linaro.org> References: <20190606094845.4800-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")) {