Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp545536rwj; Thu, 22 Dec 2022 11:03:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsbqQi1HHKaHXEnVG0N1/gOKwX9l0gQGFclHEddIlowr6rsDaVQo5RGBHYs8UnuTsPmT5cO X-Received: by 2002:a05:6402:1055:b0:467:c3cb:49aa with SMTP id e21-20020a056402105500b00467c3cb49aamr5678083edu.4.1671735801423; Thu, 22 Dec 2022 11:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671735801; cv=none; d=google.com; s=arc-20160816; b=RI7sjZQQGysaUPkRcSOOa/Bm5S1oNxauw0qXlKVqvUKFQ7oWFMOKiKkEGgXcHAHlRp Flza2MxRES6RFNm0R6BClRmqlWEpJ9XfwcwDIvjtQZX7/JhWj3x0NVQ3MAwnQQzJwjPM sX9weJBTo7HYBI3DRlscTBovCr6D7c9bPRlt8nRDEho8W8YQEzHY81UvaZF82y8PDYSn q7fko56N4anj9r8ukUz0mSWw8COvtlgDYFjq6tGa5sULebvc4c3/VZel7BdXjY4IgWZd B29q4cR4bMO/JPI9ERf94UU2PGyVcWUjPvrxVDAisGoDMCkyyUUXZImNLdymSAS3BftB cdIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+wjlf9HtdBwtd5BfrKK3NoAIyLd+UFeDv/NhLgMN1as=; b=a9HnEVcYXcGqv5ulAgSrpn8J3hceEgNtnhAz18zGWsyX4zJ/wtPxOkQpC0Td7ex4xi 5TmCjYgKs7RVDwpRL4EMf/sVTCvhV+6pP2H1YQi/88vxEYq6stPaDS+49WAY6HxtKwSk RX3b/oorddAGDIpTEbYKhCSplYXg5vtc/24OrvQFcp8GCTKtdWxrm2a1ixlgyGJPYry7 1Ugvyycd3c8R4CpcOqsLt5aX8+HKvSjrHDlxbxPe3gCMJeHCL9g/RlTkh4jKUKDukbHw tazmrKELUy2SMJcxVoDXiC4arPAiYjEI8MHyK7sKReP7oBW6LMhAAAfaqX5IPDIpXby2 TDvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A4i6MI57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a056402281100b0046bce131279si1534149ede.13.2022.12.22.11.03.05; Thu, 22 Dec 2022 11:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A4i6MI57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235454AbiLVSwS (ORCPT + 68 others); Thu, 22 Dec 2022 13:52:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbiLVSv7 (ORCPT ); Thu, 22 Dec 2022 13:51:59 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E4A029363; Thu, 22 Dec 2022 10:51:41 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id x22so6955092ejs.11; Thu, 22 Dec 2022 10:51:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+wjlf9HtdBwtd5BfrKK3NoAIyLd+UFeDv/NhLgMN1as=; b=A4i6MI57PBStveX53sUUEvZ+x7r1V47+5xIVi+hPAAfEWErZ06/pJUlK4Hst9pX/b8 XlJsuixCjjzgxhcnCMGoxM5AEfOvrtXGsbYxsdOnJg3yL04oHA3B4hzJ63iRKf4XCCcy +4ezcGTXJvXs/CsX9i+BqbEmLHYworqDNE7nCKjxq7RHtsGCXdeSufvd8EQwmkpIZRmc 7CMhvEKfe26E8krl41lM7uYmiegPQzavuvjHeheWfjx2y3/74PG8dDEFo/mfClmMm+fM iVkHNcOuHpAWzrA1430NggdBSgVRlkVZw79JIUMGN3drPnGPOodEjpMsNufwvlmYqKY5 c3+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+wjlf9HtdBwtd5BfrKK3NoAIyLd+UFeDv/NhLgMN1as=; b=sMVEBBEi07v4TAMXgZRWCpzbOI5iR8X+oUAl+WHypYpUcSFjqDS5A5IqBsdZ9y74Du WKzDTMJzXNPR/O5T68klx8PhXey02s7/8F7MlhU6TmNj3AL/QuDHtzkrYTBpe7Segwb5 ugeDvg9j1UFoarbgcNCr/VPnp3F8RblqYu5kmW1EkW+qF3NITFaJOhv0rpyycE+lbeL9 HPl3n7FQzChXN+bMrMArhCxbYPsIRHi7Z6swibmE+SbPYWkn4P9bYOQ2n6R0l2sSvcbs 9515Nu6InFegoga2k21UuO47WWaU2oglf+a7WyKq4Yp/X6tcmMTy1I9qDig7JQU1akMO ITTA== X-Gm-Message-State: AFqh2koWSQNYZmnWX2+fJcnCR3XtcpdUaO9p06RlzoEtP6ItoMUZtbdt 3madA/gprR9mbfzXbeImnhDURSPwoakw9PXXE4/hCS2p X-Received: by 2002:a17:906:f209:b0:7fd:f0b1:c8ec with SMTP id gt9-20020a170906f20900b007fdf0b1c8ecmr453038ejb.114.1671735100056; Thu, 22 Dec 2022 10:51:40 -0800 (PST) MIME-Version: 1.0 References: <20221217223509.88254-1-changbin.du@gmail.com> <20221217223509.88254-2-changbin.du@gmail.com> <20221220013114.zkkxkqh7orahxbzh@mail.google.com> In-Reply-To: From: Andrii Nakryiko Date: Thu, 22 Dec 2022 10:51:28 -0800 Message-ID: Subject: Re: [PATCH v3 1/2] libbpf: show error info about missing ".BTF" section To: Leo Yan Cc: Quentin Monnet , Changbin Du , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Shuah Khan , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Alexander Shishkin , Namhyung Kim , Mykola Lysenko , linux-perf-users@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2022 at 7:55 PM Leo Yan wrote: > > On Tue, Dec 20, 2022 at 04:13:13PM -0800, Andrii Nakryiko wrote: > > [...] > > > > > > > @@ -990,6 +990,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf, > > > > > > err = 0; > > > > > > > > > > > > if (!btf_data) { > > > > > > + pr_warn("failed to find '%s' ELF section in %s\n", BTF_ELF_SEC, path); > > > > > > err = -ENOENT; > > > > > > btf_parse_elf() returns -ENOENT when ELF file doesn't contain BTF > > > section, therefore, bpftool dumps error string "No such file or > > > directory". It's confused that actually vmlinux is existed. > > > > > > I am wondering if we can use error -LIBBPF_ERRNO__FORMAT (or any > > > better choice?) to replace -ENOENT at here, this can avoid bpftool to > > > outputs "No such file or directory" in this case. > > > > The only really meaningful error code would be -ESRCH, which > > strerror() will translate to "No such process", which is also > > completely confusing. > > Or maybe -ENODATA (No data available) is a better choice? -ENODATA sounds good to me, yep. > > Thanks, > Leo > > > In general, I always found these strerror() messages extremely > > unhelpful and confusing. I wonder if we should make an effort to > > actually emit symbolic names of errors instead (literally, "-ENOENT" > > in this case). This is all tooling for engineers, I find -ENOENT or > > -ESRCH much more meaningful as an error message, compared to "No such > > file" seemingly human-readable interpretation. > > > > Quenting, what do you think about the above proposal for bpftool? We > > can have some libbpf helper internally and do it in libbpf error > > messages as well and just reuse the logic in bpftool, perhaps? > > > > Anyways, I've applied this patch set to bpf-next. Thanks.