Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3920518rwj; Tue, 20 Dec 2022 03:53:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6tkvIYZrob927cQnj8E5UvoikxdtURL7/f9qCMBMDU14FcuKjw6v4RTroPzEmFuZM9AQuX X-Received: by 2002:a05:6402:299b:b0:468:fd17:aeb9 with SMTP id eq27-20020a056402299b00b00468fd17aeb9mr36317799edb.0.1671537223935; Tue, 20 Dec 2022 03:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671537223; cv=none; d=google.com; s=arc-20160816; b=MfqcHLdFJEskrGofMzwF8VkOitnpJYjQjWCOoVB6UkyDp9fSJcZzI6vrW2U3tbFGhc VJE2InpCYlUj3p0PKZ3Y/OmkEEjHmadL7aUPZgRMHFuBPNW5lD/PNRwCHtdXKs7TIogc G9O5/bqqBCZIotRcfWLxRNWI+Sitw6oHbbK+PuEPcSAhn2Ko6tz+59RMVvI78khDR23q uvWnzT/5t6ELak/rocSKW0HocNbzKhi62pU1E/AePNPaoRAe0+c1rKpdDc4VmTrf4lA/ MyHbdrDptUm90/0Jcctw+SHac/MG7A/0HWueujTYGhdpUGn8DvSgi2sh/dSYFTIKIAjw DIJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/5PyI2r45cXC4VPa82F8kchhQCGmhp0Mxv2K4MPTItM=; b=APrm1EjprpZjg/ZqMiuZx+rc9q5dqu53CAf07oTiWqGmSPKw1YwEPDzhJF7cj/Qy7L QjAnuW0+bnSSRbC+qEWgVrCzFH9Qbos3ucXX8Q0sJOOsBnX5LGqtvHJAO853hWY3VUnE X3SkrFP6NU1+WhGEDVZ418ezcDqfDMzS3u7bGP/59f4kpcs182DZ/s96TPYD8epE9YCE UzcSvn5jWjzBcFw/nc87ANJ1j4ZIgkH+ecOuzKkF6debUvI66/qwqA3GUVZkqTdzvUMc fRhRgTpjaAD1oUWcdUNCsCSbqiuA5hux8tJx6+RybTTr43Sa3gAkSQD5kDbH6S5wgbuA ipxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L7GMgutR; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020a05640204c600b0046d25b746a6si9562996edw.632.2022.12.20.03.53.27; Tue, 20 Dec 2022 03:53:43 -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=@linaro.org header.s=google header.b=L7GMgutR; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiLTLej (ORCPT + 70 others); Tue, 20 Dec 2022 06:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbiLTLei (ORCPT ); Tue, 20 Dec 2022 06:34:38 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4A08B04 for ; Tue, 20 Dec 2022 03:34:36 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so16191985pjj.2 for ; Tue, 20 Dec 2022 03:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/5PyI2r45cXC4VPa82F8kchhQCGmhp0Mxv2K4MPTItM=; b=L7GMgutRkj3qZcXp5mrTJlXEpwbu1F0SAXifZWMH02YWGo4hvzmU2XUWBMUyIKPJFb 5dml+ojCzx4kiyathxHYShcXYhTOa3u0S/BqwYKviEQrPml5/Fgy48H1wOyQ0U2GUq61 EsGrwuo4pQeBzGKkO4iKgeuzby26OGVIkolGy3Wl+Qdt1/BeZHkos9eNKDSG5lI/ajBG ETKAidRnsolKk5Q2DxQz+AMbznaYDhMdXCIEs133YNyQWmSur5hzrrRFAI0atg89Hrz5 e59Bez8vgRnqVtGyF3USTpTbi06QgyvjAH4qmpuGPuyRwyUh/8+b95n0qk0JK4IMmFuD yoOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/5PyI2r45cXC4VPa82F8kchhQCGmhp0Mxv2K4MPTItM=; b=1SJgTQIzxbM7wC0NG/m9QZZZ8S/YsSQNIwqN4GVMF3KV/34ACjNOPRj9nRWELT7TFB iTsLamuPI+xHPyP+rlhQ/J9mKDjAYwwO8o2lgIUY9CLQAYRou4txeLT5BmfN53Dts6Lb Uuz4GT+e8XucdG8J9LSKvsBsL8b/ItElirVYEjK3h+k41g5p90HUfud3zGkrOD0Or4UA WkpaMft7b8KoEX98dbOBidQgIoAQXj3tG3vMgKtojZxfUGUVLWke2MRVOZqLvzRkofvA t5Wf5Bt2QkYcw/Ha4PRU9Tn2dEM52EJ8CrNUeJp6UuzeXtipEwv8+PFiAUHM2W301WMn DbLQ== X-Gm-Message-State: AFqh2kowTsYPlpynX9VrNbFfOl6Xb1GVdr3roqZY4YrhgJqM788dtgg5 C2vYV/WmPKZIFl9EMD5fKVtdgA== X-Received: by 2002:a17:902:ea91:b0:189:c6fb:f933 with SMTP id x17-20020a170902ea9100b00189c6fbf933mr12287704plb.28.1671536076042; Tue, 20 Dec 2022 03:34:36 -0800 (PST) Received: from leoy-yangtze.lan ([152.70.116.104]) by smtp.gmail.com with ESMTPSA id f7-20020a170902ce8700b00186b758c9fasm9178299plg.33.2022.12.20.03.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 03:34:35 -0800 (PST) Date: Tue, 20 Dec 2022 19:34:21 +0800 From: Leo Yan To: Changbin Du Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , 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 Subject: Re: [PATCH v3 1/2] libbpf: show error info about missing ".BTF" section Message-ID: References: <20221217223509.88254-1-changbin.du@gmail.com> <20221217223509.88254-2-changbin.du@gmail.com> <20221220013114.zkkxkqh7orahxbzh@mail.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221220013114.zkkxkqh7orahxbzh@mail.google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 09:31:14AM +0800, Changbin Du wrote: [...] > > > Now will print below info: > > > libbpf: failed to find '.BTF' ELF section in /home/changbin/work/linux/vmlinux > > > > Recently I encountered the same issue, it could be caused by: > > either missing to install tool pahole or missing to enable kernel > > configuration CONFIG_DEBUG_INFO_BTF. > > > > Could we give explict info for reasoning failure? Like: > > > > "libbpf: failed to find '.BTF' ELF section in /home/changbin/work/linux/vmlinux, > > please install pahole and enable CONFIG_DEBUG_INFO_BTF=y for kernel building". > > > This is vmlinux special information and similar tips are removed from > patch V2. libbpf is common for all ELFs. Okay, I see. Sorry for noise. > > > Error: failed to load BTF from /home/changbin/work/linux/vmlinux: No such file or directory > > > > This log is confusing when we can find vmlinux file but without BTF > > section. Consider to use a separate patch to detect vmlinux not > > found case and print out "No such file or directory"? > > > I think it's already there. If the file doesn't exist, open will fail. [...] > > > @@ -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. Thanks, Leo