Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5459054rwn; Mon, 12 Sep 2022 09:18:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rSq5HWPcZkOZP9wgco7s0NLAOc0OGGkSiaJvm4g+igPVA7jnP1ixUJMWrImeyquhF6HSb X-Received: by 2002:a17:906:ee86:b0:741:89bc:27a1 with SMTP id wt6-20020a170906ee8600b0074189bc27a1mr19562317ejb.725.1662999519044; Mon, 12 Sep 2022 09:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662999519; cv=none; d=google.com; s=arc-20160816; b=H3W4NaW4Q7pH0je40NmdN9FrBmZ5kfm9BPpMCfBBkZ7gPamiCPjxwS1JygwRAvc/ub dP8WJ1NppXjpAg0JSrzqLWJVggk3JkvULTc8giOO3Yoa3kv2KLJXYgNNniLlf9mpxo1I pcYmqx0Tkiv529gOGj/i5jz5K9LH3WPXfEKtHy4TclLWM9GDyNHvBmINT2cIdr22VaLG ++/OWzek0LYpSREaSf/5ekg5gaW3h9F98gVO0ntbkf6RyvFVuMMcv0ml3f86JmurRV+N nh0zZXvvALQxckxZx5PQcaLWBxqO5thgU2ptr7z0R5VXxUK6hhiBd7T1Zq9HTk+WDMBr oZ8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=SeQIMmEtCzvd05oP/q3VxIbRu9s6ighkykhnARZz8T0=; b=NP8QKqB+c1kCJu8fn5k6CjUN37YL9QDQqMBnCMZpvYi2FkI7XXJs0B6V8Dm3OqZ3/P owvWek7vZV122dFoZNUafZkigMs6S596v9zwTlFybwVWKBcOB4gUlCwYpnuUiJRKhQWd gI+3ykP1Fp1/k5sQ/ibXq8xd4e+Jo1OAokvnLbklgRdBCGXSsB07L5BgcaheE+9hplMz m78Gc9y9q5Js8TBKoqLUceAdp8fFCCiwfqhmPq0M4+Abl1Bo0xoq+gPDykpcZq0KzW+W +Skj6afU4Fo1YsPrNo3WTYsEw9YJxb0gHdkXNTZBqVJpqPsqgqSjTA2qelFjglbu5TgW jggQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q34-20020a05640224a200b0044e8fc8221bsi7291821eda.257.2022.09.12.09.18.12; Mon, 12 Sep 2022 09:18:39 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbiILPiI (ORCPT + 99 others); Mon, 12 Sep 2022 11:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbiILPiF (ORCPT ); Mon, 12 Sep 2022 11:38:05 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61F7325595; Mon, 12 Sep 2022 08:38:03 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=chentao.kernel@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VPXqnu2_1662997076; Received: from 30.15.230.77(mailfrom:chentao.kernel@linux.alibaba.com fp:SMTPD_---0VPXqnu2_1662997076) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 23:37:57 +0800 Message-ID: Date: Mon, 12 Sep 2022 23:37:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] libbpf: Support raw btf placed in the default path To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: <1661349907-57222-1-git-send-email-chentao.kernel@linux.alibaba.com> From: Tao Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 在 2022/9/10 上午3:00, Andrii Nakryiko 写道: > On Sun, Aug 28, 2022 at 10:36 PM Tao Chen > wrote: >> >> Hi Nakryiko, thank you for your reply. Yes, i happed to put the raw >> BTF made by myself in /boot on kernel4.19, unluckly it reported error. >> So is it possible to allow the raw BTF in /boot directly, athough we >> can set the specified btf location again to solve the problem with the >> bpf_object_open_opts interface. >> >> As you say, maybe we can remove the locations[i].raw_btf check, just >> use the btf__parse, It looks more concise. > > Please don't top post, reply inline (that's kernel mail lists rules). > > But yes, I think we can just use btf__parse and let libbpf figure out. > Please send a patch. > Thank you, i will send the patch in v2. >> >> 在 2022/8/26 上午4:26, Andrii Nakryiko 写道: >> >> On Wed, Aug 24, 2022 at 7:05 AM chentao.ct >> wrote: >> >> Now only elf btf can be placed in the default path, raw btf should >> also can be there. >> >> It's not clear what you are trying to achieve. Do you want libbpf to >> attempt to load /boot/vmlinux-%1$s as raw BTF as well (so you can sort >> of sneak in pregenerated BTF), or what exactly? >> btf__load_vmlinux_btf() code already supports loading raw BTF, it just >> needs to be explicitly specified in locations table. >> >> So with your change locations[i].raw_btf check doesn't make sense and >> we need to clean this up. >> >> But first, let's discuss the use case, instead of your specific solution. >> >> >> Signed-off-by: chentao.ct >> --- >> tools/lib/bpf/btf.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c >> index bb1e06e..b22b5b3 100644 >> --- a/tools/lib/bpf/btf.c >> +++ b/tools/lib/bpf/btf.c >> @@ -4661,7 +4661,7 @@ struct btf *btf__load_vmlinux_btf(void) >> } locations[] = { >> /* try canonical vmlinux BTF through sysfs first */ >> { "/sys/kernel/btf/vmlinux", true /* raw BTF */ }, >> - /* fall back to trying to find vmlinux ELF on disk otherwise */ >> + /* fall back to trying to find vmlinux RAW/ELF on disk otherwise */ >> { "/boot/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/vmlinux-%1$s" }, >> { "/lib/modules/%1$s/build/vmlinux" }, >> @@ -4686,7 +4686,7 @@ struct btf *btf__load_vmlinux_btf(void) >> if (locations[i].raw_btf) >> btf = btf__parse_raw(path); >> else >> - btf = btf__parse_elf(path, NULL); >> + btf = btf__parse(path, NULL); >> err = libbpf_get_error(btf); >> pr_debug("loading kernel BTF '%s': %d\n", path, err); >> if (err) >> -- >> 2.2.1 >>