Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1286260iob; Fri, 29 Apr 2022 01:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWUXUSRf1QrgWSabb+wHGu5Xs+sEM+R/0KAd8RnP5GTKxLUxqJ9NyyvTpfDHCT4p4QWJdJ X-Received: by 2002:a05:6a00:228d:b0:50a:934f:e302 with SMTP id f13-20020a056a00228d00b0050a934fe302mr39033504pfe.20.1651222131113; Fri, 29 Apr 2022 01:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651222131; cv=none; d=google.com; s=arc-20160816; b=H5eot9j71MiVKevbRsqs1HMHrWqhdXKXcH7wqpD5hgq+J4fuflrcxufwWsg/yDgG1E CB8dF9QgqNQe+5upStWVhTzC3tpoM6y+z3kpcvHbvKOf3PalRBBvEksgr9yybif97lVh 8jQNa9+qsB4ZRrxpH/LleVgb/lhWDGAu+rOs9/uJj5q0Yhj89qkK+ZndXYOv9n1hKPJ0 3EIWonfnA3Jjp9hlCK7IQ1gGkaXa9x4HoSKrJkP8RvGApGeWC1N2VbXVnSeVXJgMrOaG J3AeZo0xT8UdlJ303qFQIwRVkpgU1MxnRg2aQP+lzd2X1G84i06fMLHEH1n6YW1gn/RR kTfA== 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=ZozNJbImTlZi92lh7h5eZ93VBLVeVKEC1D84yravxlU=; b=MP0qIJZC+zCVluN+WtJNxM9Ufu0SdkO7LEw0bo3bIYbsx4AI9NkwK/xhHWNXHBUVKM KkKOb8PgXgjtzFmfDFMtT2sg7tcYzQe5PfjcF9gg3Gl0ppkedakLSB56tkZbvclKWrea //PPwsG3flKbq4+k5GPYJE7DtA8ftphvkxbE2s6npD6EDTYiPv6LcT5X6tl4OcBdq05b s+Zu1VXfVz0+sQB1vxjswB8s32ykcLgHckzzfcP79Q1x68sPt5vugkTGhYImhAi2JkMe m5fu4X8kt06WFJgu1QA2YgxTysJpYvg7MzXfD4DX0nEYwMJuxcsnCRTFeMjeDO1Q8bOz B8og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e17B5lrT; 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 kk11-20020a17090b4a0b00b001c9e16e3b0dsi7085560pjb.73.2022.04.29.01.48.35; Fri, 29 Apr 2022 01:48:51 -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=e17B5lrT; 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 S238041AbiD2FC1 (ORCPT + 99 others); Fri, 29 Apr 2022 01:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237887AbiD2FC0 (ORCPT ); Fri, 29 Apr 2022 01:02:26 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D042A71C; Thu, 28 Apr 2022 21:59:09 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id r11so3317095ila.1; Thu, 28 Apr 2022 21:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZozNJbImTlZi92lh7h5eZ93VBLVeVKEC1D84yravxlU=; b=e17B5lrT112l/EHfhHCyIOwYW5UNDhwLriJM+d19yK8igKlmjd1lUSKaQ+jjpHzgXX D8QrkIL5LV5J82IqSrSRkwZA8kraBRluG04/EfpaUrr174T6SzcamOOHeTzm7SbfFGh5 LetaX7LXwdhyzfLwqRjnRsE+HoVweBCXE1kxTDZy1IfT7lo7OO8n9MRafkUZ1hQOp1AJ uKj15OfYiajn+LowUTE4zL75Mn5eR1tE/YH4CADX2RItRiBdKMsGoIntImwvkdGo/7MT Rb3oVxI3quHE35GYeWPuhZpYP2LeHZ4SiHXrTrGDPnCTpLw6Ch4dmkNtzZk0OfvvIdrL 1Jvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZozNJbImTlZi92lh7h5eZ93VBLVeVKEC1D84yravxlU=; b=0lOiELk70o8dC0Msh2NqbZwueyo/9qd2w9pkKCJ3Z3njlFG7fa+xczaW1PgqyO8CjP PAr5E8uFU0quGEuvCVje9j2E1LptCKBqPMEDqnVuwUtmcB1A8/7vBYikI8keQjKHUW96 9aNiuCDZ9eeQBl/0ufWK9VKNUJ83hnIHo5Yc9uFzWFqde+eyVw+w7fBDVlxOlU45cnpC WTpsPbznxebkSMVg5LucJA+sxPq3jV0DmM8flJyzJFXcyVYOslh5OtSY7W+FI2aihxvz mH5tS9PeTagA74UujWMekohuCbk0nijxqmCH1dM63/aiy92V8pncTOeRZ44oJC39rh3o iTIw== X-Gm-Message-State: AOAM531KbElBWTg/TM4HzzfkSLmNooKVeBP4VDESdfLlw+LI0ei4BNrm tyjr4VZoRpOxgzGhjsOIohrx77iymQQ+Wm9H2cg= X-Received: by 2002:a92:6406:0:b0:2bb:f1de:e13e with SMTP id y6-20020a926406000000b002bbf1dee13emr14232288ilb.305.1651208349194; Thu, 28 Apr 2022 21:59:09 -0700 (PDT) MIME-Version: 1.0 References: <20220428110839.111042-1-larysa.zaremba@intel.com> In-Reply-To: <20220428110839.111042-1-larysa.zaremba@intel.com> From: Andrii Nakryiko Date: Thu, 28 Apr 2022 21:58:58 -0700 Message-ID: Subject: Re: [PATCH] bpftool: Use sysfs vmlinux when dumping BTF by ID To: Larysa Zaremba Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , open list , Martin KaFai Lau , Song Liu , Yonghong Song , Maciej Fijalkowski , Alexander Lobakin 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 Thu, Apr 28, 2022 at 4:17 AM Larysa Zaremba wrote: > > Currently, dumping almost all BTFs specified by id requires It should and will work only for kernel modules. It won't and shouldn't work for BTFs coming from BPF programs. We shouldn't blindly guess and substitute vmlinux BTF as base BTF, let's fetch bpf_btf_info, check that BTF is from kernel and is not vmlinux, and only in such case substitute vmlinux BTF as base BTF. > using the -B option to pass the base BTF. For most cases > the vmlinux BTF sysfs path should work. > > This patch simplifies dumping by ID usage by attempting to > use vmlinux BTF from sysfs, if the first try of loading BTF by ID > fails with certain conditions. > > Signed-off-by: Larysa Zaremba > Reviewed-by: Alexander Lobakin > --- > tools/bpf/bpftool/btf.c | 35 ++++++++++++++++++++++++++--------- > 1 file changed, 26 insertions(+), 9 deletions(-) > [...]