Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp963478ybm; Wed, 27 May 2020 12:18:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQBU6KNAUyZG1YgtOQTUr5AUXKBUm4KKfyVf01F8j8f2mI3OmW5ictdKlLFBFE839CNNr+ X-Received: by 2002:aa7:cb53:: with SMTP id w19mr7354553edt.328.1590607116585; Wed, 27 May 2020 12:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590607116; cv=none; d=google.com; s=arc-20160816; b=tgSD8IO6QPEdSIoROih7YblfQkCfW0OOjHrnAemDliQQPEeigntnvL4Dq4/9ehaApb Xh/tvCA/3+P3zywpAW7yI4af0xMyWbN+rWWmi85zT1u87QwGLoBojbS8nzIvq0++U1Su IvUrKZmJmHpvlB7tXpQaND0wmWtiTlunbHqjmC1fZo4CED5M/E3sV419RXeEYMgrIM5N w/QtExEsyMoBHVbo497XCXXNwcEiHluWfUHCQkCef6Q8EqnwI6mU4EEGsI+6bBLko0FP I6NTs3gpD18ehvqqNMP/qMhB/k/OzSvj7zf6LqBkZQpUfg6EEuBEo8hmTolpELGfJCcH wCwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:to:from:subject:cc:date :in-reply-to:content-transfer-encoding:dkim-signature:dkim-signature; bh=6pxEigjWfelMjOWs/Jq1DeSXeYEVsneKZclbXHsrvFQ=; b=08j1AqRsC/YbHTVbLqYYSIM7apvFLu4NvdGs23uEZmXuFtCDTdZuLS9d3rGwDSLDm6 lAOwOsBI+sn1Rm+PohxnQrd4FoLDSRXShYeLh6et6c5ux721/U6x6vxDVOoBCf7mgpnn lBgLF7S1YZdXc1CUlyBcv/OR2pQ6UPBWJNNWSn+t91o8W1c3TT4HWvZ35YDEHVJ3YOhJ SIHeFffYKK2TF/d+ojECKVbZVBUBUJq5tJz1Ek8gMelXj5Pxeoo3ourcrp6eqpTMEPN+ HaPcaVnJcL6M3nC+B6t8g3IVqwPyvyMAiDLuHDi5AuhO8EgIv9Y/3/fEEfSujl78u2lp DzyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="Dx1/Dmht"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=0IfLJJFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si2245866ejr.218.2020.05.27.12.18.13; Wed, 27 May 2020 12:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="Dx1/Dmht"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=0IfLJJFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731238AbgE0RMe (ORCPT + 98 others); Wed, 27 May 2020 13:12:34 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:55191 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729894AbgE0RMd (ORCPT ); Wed, 27 May 2020 13:12:33 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 022B8A97; Wed, 27 May 2020 13:12:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 27 May 2020 13:12:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= content-transfer-encoding:content-type:in-reply-to:date:cc :subject:from:to:message-id; s=fm3; bh=6pxEigjWfelMjOWs/Jq1DeSXe YEVsneKZclbXHsrvFQ=; b=Dx1/DmhtipYpfHdvAyM/R5S0l0Urw1kxEabTy7ndJ KTekDH5RnTfTmgtWbw1GPf0w0zy//8W2XsYDGENYLAJYsG0M8MFKQSDtejpoMNaj hAnXIlNbMdyUmtqWBcPkLMwrLpd0M7Nc9TADOGV8r3gsiI1QSzzcbcOKvskxWyKF nWVGqyFKvv8np6XOsHfTuSvEfCcTazr4q8NN3JRTDddw3g5bkUEkEjt7XqafB7mF s6kv6nZ29QgL09L95cmnqmIRb0l/H+XOyd3tVem/EXMHCkWlMabbx17u+lEyIi6K 3pthk+jGFVzijmv9tcwao0yLwP9yMl0ot6BCt4x7h51LQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6pxEig jWfelMjOWs/Jq1DeSXeYEVsneKZclbXHsrvFQ=; b=0IfLJJFz1oyDNl66pJNJfD fK4c+ZqgBV1JRd7wxvWo0TU2bYMX+yWOONUwtiB+FAnfw5CoMWYA3HuOJmeEcBPU q/R1AyizBPiuyjRbbfpR4f7oAz/w44K8x1bfsWuD6eRh21k1csZ/bGwbNjAylRqG S+zKp5kTf584fTAjy65FIqG4zQT2eZj8e1EzY0n//TpCX4X5shiCofJRsWRjhz+v d8/6CyoSQmHjzKPaqDddMQGkUE8+Pfxftj15FQ6LpZOcIGiJYWbn/7iaf/xmQiV7 cU4CzpS/asntOs7f7QqfBxMPHb3C9yAf8NwoTMtLn7S9qV5cTx0tWsr3I2WKHtPw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddvgedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpefgtggjfffuhffvkfesthhqredttddtjeen ucfhrhhomhepfdffrghnihgvlhcuighufdcuoegugihusegugihuuhhurdighiiiqeenuc ggtffrrghtthgvrhhnpeelleelfeekudehudeitdefkeeutdfhieeiudeggfdutdetleek vedtteevieffteenucfkphepjeefrdelfedrvdegjedrudefgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Received: from localhost (c-73-93-247-134.hsd1.ca.comcast.net [73.93.247.134]) by mail.messagingengine.com (Postfix) with ESMTPA id 7C89A3280063; Wed, 27 May 2020 13:12:29 -0400 (EDT) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 In-Reply-To: Date: Wed, 27 May 2020 10:03:56 -0700 Cc: "Alexei Starovoitov" , "Daniel Borkmann" , "Martin Lau" , "Song Liu" , "Yonghong Song" , "Andrii Nakryiko" , "john fastabend" , "KP Singh" , "David S. Miller" , "Jakub Kicinski" , "Jesper Dangaard Brouer" , "bpf" , "Networking" , "open list" , "clang-built-linux" Subject: Re: [PATCH bpf-next] libbpf: Export bpf_object__load_vmlinux_btf From: "Daniel Xu" To: "Andrii Nakryiko" Message-Id: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrii, On Tue May 26, 2020 at 3:09 PM PST, Andrii Nakryiko wrote: > On Tue, May 26, 2020 at 7:09 PM Daniel Xu wrote: > > > > Right now the libbpf model encourages loading the entire object at once= . > > In this model, libbpf handles loading BTF from vmlinux for us. However, > > it can be useful to selectively load certain maps and programs inside a= n > > object without loading everything else. > > There is no way to selectively load or not load a map. All maps are > created, unless they are reusing map FD or pinned instances. See > below, I'd like to understand the use case better. > > > > > In the latter model, there was perviously no way to load BTF on-demand. > > This commit exports the bpf_object__load_vmlinux_btf such that we are > > able to load BTF on demand. > > > > Let's start with the real problem, not a solution. Do you have > specific use case where you need bpf_object__load_vmlinux_btf()? It > might not do anything if none of BPF programs in the object requires > BTF, because it's very much tightly coupled with loading bpf_object as > a whole model. I'd like to understand what you are after with this, > before exposing internal implementation details as an API. If I try loading a program through the following sequence: bpf_object__open_file() bpf_object__find_program_by_name() bpf_program__load() And the program require BTF (tp_btf), I get an unavoidable (to the best of my knowledge) segfault in the following code path: bpf_program__load() libbpf_find_attach_btf_id() <-- [0] __find_vmlinx_btf_id() find_btf_by_prefix_kind() btf__find_by_name_kind() <-- boom (btf->nr_types) because [0] passes prog->obj->btf_vmlinux which is still null. So the solution I'm proposing is exporting bpf_object__load_vmlinux_btf() and calling that on struct bpf_object before performing prog loads. [...] Thanks, Daniel