Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7484337rwp; Tue, 18 Jul 2023 16:32:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlEk1JwJFbC/0IJRNWf7D7bDFvGHUVCvn6C1v2E1+Ux0mW3K1oqRObkw9r2/DJtd0C0XKlsM X-Received: by 2002:a05:6a20:394a:b0:131:eeba:1317 with SMTP id r10-20020a056a20394a00b00131eeba1317mr793528pzg.32.1689723174534; Tue, 18 Jul 2023 16:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689723174; cv=none; d=google.com; s=arc-20160816; b=Zzew21rttga2+baujhOcEw0HRYQfF03B+FzwXwlEU9pv0D/R9UrCfBlCEW/OpUWxbm RZ+LohPJ5bcg3+007LdK1ZIT8widNr3+MQKVbMNfx24BRg8UvLol1zXwINRxmfLOKk2k gxN16BgrTlu6uHR0KrAuVQzPTQm+tE9e2INrIVlbKIFcpLn0zufzjAvgTKSJixY8xCSL yXndG+zs3VgMoqCEBhrrvpr4MrdSxPVQ9I6WBXVpaDt0DnLiwE1lfg3s2Bw/f+EiZEE/ Z+SGtPnkmRBvaud2XK0Em6WHqhZxk5CzEBTt3Yi8/HXOhO+HciPvNHnNM4BBzIecjEAM Iazw== 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=1NQfBVXDdJBauiDRZhAmRRYJqr7LclnAThyEWYFadCc=; fh=hTo2SVktvmge9VJDSHLyff2G3xxLSvtEFz02cZ36bxU=; b=mpsHKUlWZjnJsI2Za4mTKb3jswZP2R4uMBVXSn1wRgTwmA9XPUp1uCBJbfSsjzWIIO OQswv1CSK2C2TTzY52i3O6k/5la2KqRd6M2tkjU0hTMl2XyAy6l25TYqmpxGLYi4Unpy fDrvdHdQhV8TriEuoU74LiKjYBB8SLWKdmW2gdA4TOqv/M+s4MGVZldejfyMEVh2+SjO 1E4rLPmGkE2Ztm+MqKz81pK9aGmJgHaQYR7+BLGiVpGNOP5i82HO6h2IDZggwP/rPsYb zIc1n7AQQ/vw8tSpGAJIVsJHBRZ9xTBw3hjrlKasdhGe7THfvwx7V6JnPgaQlLc4jTOM soWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=b1A78LJB; 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 n6-20020a632706000000b0055ff89f224asi2499564pgn.812.2023.07.18.16.32.35; Tue, 18 Jul 2023 16:32:54 -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=20221208 header.b=b1A78LJB; 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 S229651AbjGRXNN (ORCPT + 99 others); Tue, 18 Jul 2023 19:13:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjGRXNM (ORCPT ); Tue, 18 Jul 2023 19:13:12 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45849ED; Tue, 18 Jul 2023 16:13:09 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2b743161832so96829141fa.1; Tue, 18 Jul 2023 16:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689721987; x=1692313987; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1NQfBVXDdJBauiDRZhAmRRYJqr7LclnAThyEWYFadCc=; b=b1A78LJBt6GeKcjIel5xGf2nrJ1kcal3jaIcMyCrNrFBd2QzaFoaGdEx4XMZDf8En5 dN2BByGDzYfgOY83IL1Uz9WOibbRkj97iSZWD1XUW6xJtNgUNeIAx76gTF5IFKUIaMGz cA6f1HYXlQsqCf2T911C8g3U0dC/W8ym7c8m6UqsNVP2QBJyMtU0k0MkQS3QFnbx1svE tpO3azyX8V297OnfaGCEu+S42Ad4DgZsihGwLSjO24FfQpWWNy0nG/TbEWLLY6OtqOD+ nidrtbDAUuKO9hTYzR3WIvP4jtViOxbrCj3j2Ylruk+6Tqwn6P1D8GsvEoAnq9ZRg7Zu okPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689721987; x=1692313987; 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:message-id:reply-to; bh=1NQfBVXDdJBauiDRZhAmRRYJqr7LclnAThyEWYFadCc=; b=JPBF2zS+2VSavuWS7uITPFqthnrt1GsReO4CXDaH4CGjJU8781lTv3KH0f55SNb+p/ 57Gm+JvnwbZYSaNChA+yVuaQU/F8HH+DddBGyzKQ+uDLpl5PeoXp+rPmG7WU1S2pLzOi TzPTGef9XMmaHvcikpf8sofBbmNHZ3lhkTNd6jOyx6G9BmbCfwBK4fb7MXlgTamR8SjQ DI7xxjrlZoy5j/4uyG5aUhW42PMUATPU/9WKGqWR31NHC/qXbVJ9aGZr3ZtcQr9jKt7Z 0ZanuCJaervtw/bWO8ED0mU5k5kgCDFH3DK0Vt8hHUUe1549uK2GVLhwaXqh5HXVw3CG elQQ== X-Gm-Message-State: ABy/qLbmGBNqyXdQ19Mt6AriTa88YJgg0MexsXGx2geRwSgd4vvStpf3 doS/p5RtTSKa4zxoUSlhkdCLKocBPLAlLDNiZs8= X-Received: by 2002:a2e:7403:0:b0:2b6:fa71:5bae with SMTP id p3-20020a2e7403000000b002b6fa715baemr507830ljc.12.1689721987346; Tue, 18 Jul 2023 16:13:07 -0700 (PDT) MIME-Version: 1.0 References: <168960739768.34107.15145201749042174448.stgit@devnote2> <168960741686.34107.6330273416064011062.stgit@devnote2> <20230718194431.5653b1e89841e6abd9742ede@kernel.org> <20230718225606.926222723cdd8c2c37294e41@kernel.org> <20230719080337.0955a6e77d799daad4c44350@kernel.org> In-Reply-To: <20230719080337.0955a6e77d799daad4c44350@kernel.org> From: Alexei Starovoitov Date: Tue, 18 Jul 2023 16:12:55 -0700 Message-ID: Subject: Re: [PATCH v2 2/9] bpf/btf: tracing: Move finding func-proto API and getting func-param API to BTF To: Masami Hiramatsu Cc: Donglin Peng , linux-trace-kernel@vger.kernel.org, LKML , Steven Rostedt , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov 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_BLOCKED,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 Tue, Jul 18, 2023 at 4:03=E2=80=AFPM Masami Hiramatsu wrote: > > On Tue, 18 Jul 2023 10:11:01 -0700 > Alexei Starovoitov wrote: > > > On Tue, Jul 18, 2023 at 6:56=E2=80=AFAM Masami Hiramatsu wrote: > > > > > > On Tue, 18 Jul 2023 19:44:31 +0900 > > > Masami Hiramatsu (Google) wrote: > > > > > > > > > static const struct btf_param *find_btf_func_param(const char = *funcname, s32 *nr, > > > > > > bool tracepo= int) > > > > > > { > > > > > > + struct btf *btf =3D traceprobe_get_btf(); > > > > > > > > > > I found that traceprobe_get_btf() only returns the vmlinux's btf.= But > > > > > if the function is > > > > > defined in a kernel module, we should get the module's btf. > > > > > > > > > > > > > Good catch! That should be a separated fix (or improvement?) > > > > I think it's better to use btf_get() and btf_put(), and pass btf vi= a > > > > traceprobe_parse_context. > > > > > > Hmm, it seems that there is no exposed API to get the module's btf. > > > Should I use btf_idr and btf_idr_lock directly to find the correspond= ing > > > btf? If there isn't yet, I will add it too. > > > > There is bpf_find_btf_id. > > Probably drop 'static' from it and use it. > > Thanks! BTW, that API seems to search BTF type info by name. If user want= to > specify a module name, do we need a new API? (Or expand the function to p= arse > a module name in given name?) We can allow users specify module name, but how would it help? Do you want to allow static func names ? But module name won't help. There can be many statics with the same name in the module. Currently pahole filters out all ambiguous things in BTF. Alan is working on better representation of statics in BTF. The work is still in progress. For now I don't see a need for an api to specify module, since it's not a modifier that can be relied upon to disambiguate. Hence bpf_find_btf_id that transparently searches across all should be enou= gh. At least it was enough for all of bpf use cases.