Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2350059rwn; Fri, 9 Sep 2022 12:15:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR46L4923RF+tP8hTfsAEuhS/OUeCHRFzHGJOn46ibycdix531PD3LevAPBlLEQd2tshTr/n X-Received: by 2002:a05:6402:1910:b0:450:fb10:fddf with SMTP id e16-20020a056402191000b00450fb10fddfmr4557818edz.321.1662750899991; Fri, 09 Sep 2022 12:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662750899; cv=none; d=google.com; s=arc-20160816; b=B+LdnOrMc9BTvmB6K/dcizHhHFmPAAdue8xiT6+3X6XP9UROYi3HwfiV47PoqwAgwU nQyvWIFcz4EotFeNH82HK1EXdYwJmf9wn7TmtFl/oduPs/QnHjBC0LDUTzi0TX5A1u9/ +JPAUt9v6irD4jiSSU6GDoUSziGTKIg9KnlX3qKNAxqD50BlAsx5qE50MsQY8JsvY6S0 ZW0dNiVtgqsIr1RH/Ue39lqq53ef4Zd49buPZMqpcY48pfGTb5c0fDCV9nQQO30Qze/T LJcUOStI+csgoMgmFY9Zq1jL5LTzpQSXYxZjiJ/s/SkTZlmBrn4ebLC7Qtn8J97BP/Tl zjlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ox4CFUuD18drqtN8IsU1qD1pZvik437HsGVopsWFXik=; b=MhCQ2l3+FBhxOF1shPJpKB14YiJ37Dooz+FuyBpS6L89x/8APE2Kb7xNb8I7U0zjEz SlGlDDvyjDSs8DpRSEApW0UZFkOCfNeIl1J7v/2JDDVFO7FmCR/qNF3405cW0cbPcfEx e4m8+sIA1BjMuXoRlOEEqotbP3kkBPDxyiohvOr6o9Af8p7fLAjCrdx55YPDRh391pHe NvNYAl6hIaCfVd1Q88CEcPApzWHNXEqem+LNL2swu3yuPgl5UrAxz8KnrUk/6SSr2KR9 Hx2PAUqU7A8apLIAyU6sWSf2VOmsx5XcSwK7wGhtBxqGAnUr/UrnsqYii5rpjXC0J8U7 zKrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S7iuggkP; 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 z4-20020a05640235c400b0044ef9c83492si1256425edc.472.2022.09.09.12.14.34; Fri, 09 Sep 2022 12:14:59 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S7iuggkP; 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 S229892AbiIITAl (ORCPT + 99 others); Fri, 9 Sep 2022 15:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbiIITAi (ORCPT ); Fri, 9 Sep 2022 15:00:38 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7F774DCA; Fri, 9 Sep 2022 12:00:36 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b35so3964367edf.0; Fri, 09 Sep 2022 12:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=ox4CFUuD18drqtN8IsU1qD1pZvik437HsGVopsWFXik=; b=S7iuggkPdOAS4DBUAxkiKJ7/HcezhrUSy1EjrKd7adE9zpPnMfIrqRlpH0hc1Lp9NM KswAkP4qKJV/6p++GW4B7Mn1mVNrNgItawbOr6eQu9lZbwTwIg0qapiHORegaLkz0nOJ zvjwwAUdqE5JxXAPwkJoqNlKmfkHHbPK5THjqCPFVOI7IBY7M1zQCgKpJOko94hjrEhJ oAuYbDuDEoTdmlP2m0o4JtqtYmjDyR4Hs4ILrD/tiAHXI8xS8revZpNBWMIuJCbm2rhj NSQc5AH0KJzH9EE8ltKDCR8WGnibNsd4QAM5Tzuh9cNRmyxvLmwE7fa4Ic94REIcPref NN3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=ox4CFUuD18drqtN8IsU1qD1pZvik437HsGVopsWFXik=; b=VPaTWTh39IdNoCLOH37jxKqVRyl3j/hKbgOv6GMXwssvOHH2HhK365M3esgywIyzvd drH/Iv1Gh4kfHdtAlPjSEjbNibiDRWCYsK66oqaB0EY5bzL8Tc0T8J9MoJ3UqlIFFac8 OkzzY0hwUu+j75UmijZaP9X4NMO1Q5VrwY4mVpr/0l60OgT4/UUl4BnCeiCPOlk+xxyD UvzDH+epp1QQUSrDK+O2OtRld8Szq0NniiL9tq4VyoEXOThLmjrKYlluH4OgOI+vdBM1 ptkXQ8EjQ4jckYUQjrmo+MYwC5YsYGGPK4D0XxacysfjDvzKBYtX9dDKDhBCkQx4YR4a J/nA== X-Gm-Message-State: ACgBeo3dwCNl7mI8DMxOIPLlP+R+KxzlhcUCn/NmrKAAH4150GLgvHw+ 4S4EIsHKrn21BlSK3AozUM4CSnXOv7QJChk7b0I= X-Received: by 2002:a05:6402:24a4:b0:440:8c0c:8d2b with SMTP id q36-20020a05640224a400b004408c0c8d2bmr12375623eda.311.1662750035366; Fri, 09 Sep 2022 12:00:35 -0700 (PDT) MIME-Version: 1.0 References: <1661349907-57222-1-git-send-email-chentao.kernel@linux.alibaba.com> In-Reply-To: From: Andrii Nakryiko Date: Fri, 9 Sep 2022 12:00:24 -0700 Message-ID: Subject: Re: [PATCH] libbpf: Support raw btf placed in the default path To: Tao Chen 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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,T_SCC_BODY_TEXT_LINE 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 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. > > =E5=9C=A8 2022/8/26 =E4=B8=8A=E5=8D=884:26, Andrii Nakryiko =E5=86=99=E9= =81=93: > > 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[] =3D { > /* try canonical vmlinux BTF through sysfs first */ > { "/sys/kernel/btf/vmlinux", true /* raw BTF */ }, > - /* fall back to trying to find vmlinux ELF on disk otherw= ise */ > + /* fall back to trying to find vmlinux RAW/ELF on disk ot= herwise */ > { "/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 =3D btf__parse_raw(path); > else > - btf =3D btf__parse_elf(path, NULL); > + btf =3D btf__parse(path, NULL); > err =3D libbpf_get_error(btf); > pr_debug("loading kernel BTF '%s': %d\n", path, err); > if (err) > -- > 2.2.1 >