From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C448EC001B0 for ; Wed, 19 Jul 2023 15:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbjGSPPb (ORCPT ); Wed, 19 Jul 2023 11:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbjGSPP3 (ORCPT ); Wed, 19 Jul 2023 11:15:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85BC1B7; Wed, 19 Jul 2023 08:15:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 17C1E6172E; Wed, 19 Jul 2023 15:15:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 447B0C433C8; Wed, 19 Jul 2023 15:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689779727; bh=qJ+ZrPEpdBA96XSDs0SJx0ONexgC885l+neDnc4f3ko=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=teN+eU0GR7xtJcebaFAAObKkHW/bzF2oP1wRwhkmMyvJOw/EbyXfyEHwiZ1LzoEIt otVk7eUqCEe0GvVKaW4viGxLbuInZDyqrDf2ZoZyDuACl0k6Tau2CRxgY6coYdxPXk D+wJikzZWxxnPgZdYD+5gmS2V8J4lFn6G5pCZc0r5RLCLBf2pPPkiv5+30C1bnLLug fSI+lbtHqRRcNva+uIj/kJeyQB7jQVP3S4cG6qgMJR7YahKLEJjeKy8SBlR8BcmX2U R1a2egRnqybWxCZ2C1OLXIYf9IdeTkymGGdIaLGoAZuMZ/OjoMa/KgVEOlJG61mqIl r3Ldi2AyBNOJg== Date: Thu, 20 Jul 2023 00:15:22 +0900 From: Masami Hiramatsu (Google) To: Donglin Peng Cc: Alexei Starovoitov , linux-trace-kernel@vger.kernel.org, LKML , Steven Rostedt , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov Subject: Re: [PATCH v2 2/9] bpf/btf: tracing: Move finding func-proto API and getting func-param API to BTF Message-Id: <20230720001522.4aaadaf77d037ccdc7e4b83e@kernel.org> In-Reply-To: References: <168960739768.34107.15145201749042174448.stgit@devnote2> <168960741686.34107.6330273416064011062.stgit@devnote2> <20230718194431.5653b1e89841e6abd9742ede@kernel.org> <20230718225606.926222723cdd8c2c37294e41@kernel.org> <20230719080337.0955a6e77d799daad4c44350@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 19 Jul 2023 10:09:48 +0800 Donglin Peng wrote: > On Wed, Jul 19, 2023 at 7:03 AM Masami Hiramatsu wrote: > > > > On Tue, 18 Jul 2023 10:11:01 -0700 > > Alexei Starovoitov wrote: > > > > > On Tue, Jul 18, 2023 at 6:56 AM 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 tracepoint) > > > > > > > { > > > > > > > + struct btf *btf = 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 via > > > > > 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 corresponding > > > > 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 parse > > a module name in given name?) > > btf_get_module_btf can be used to get a module's btf, but we have to use > find_module to get the module by its name firstly. Thanks for the info! OK, this will be useful. > > > > > Thank you, > > -- > > Masami Hiramatsu (Google) -- Masami Hiramatsu (Google)