Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp585939rwd; Mon, 12 Jun 2023 19:20:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PO9r/xdsR7JLoulb8C20o87dCHrIGvVXpglLQkz0T5dWTPv8nu5zwRBLTB5w8putQY0UW X-Received: by 2002:a17:907:72c5:b0:981:ca85:2c9c with SMTP id du5-20020a17090772c500b00981ca852c9cmr4609327ejc.9.1686622846934; Mon, 12 Jun 2023 19:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686622846; cv=none; d=google.com; s=arc-20160816; b=vX8zpR4ZIdNFHi8UeRipY0DptG7MK6PiDL+2+kILI6r9wvF8XptyaTc9ocbmWos+At HawG3keSlyn/N6l7aTBI4U7Spd+XoHSX/uNrCfdHg7c4FeoNsN2xqRkYHxCuUw62h2AF neQJ+LEovH9G6GjCKFQjwpmxHG7i5tcFLGh8WofgXF8fVZ4Zpk3iMvLSoRFz4vdS2HWg y9s4tzOyvVr6wvh8eGtd1pLFA4x/HAwedJEij3G9TQD+ii+ZaCgzJd+sER2vDST8ZzQg Cm3owv1/MnNDWJaMsHg2KmOJwN3/irAyR6GSxYvjK63YU0IiSLNpoUvd5znFzTkuahO+ DGLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:mime-version:date :dkim-signature:message-id; bh=Az7NwX67Bf/1j76+8r8hc++AaCY3OLyQFY+NixwvQvo=; b=WzK6CZxytn/pi7ou7Z2iBaNmo5fjEDwQ9WYd+QNRT+3bpxTP8/Ii/J8cW5tTOU7t7/ t0KUjZgGTgyUaSGZyTirRjRSxLXZBChRfMs40tcAF00vsuxecrIjUuXgFgOoO+E0ykqe 3stRI42w19++8otKh5junkBnfoo3OHqRp1L/TDKtGYoNXlf+iyxXeyj7L1pjpVt9HBq3 /YaSjYeAd1/FpyOgFO02XihD2sK6ogAQe9cSrfdaVNGiE28X91w78K75Z3qNyVzpJGe6 oCJ/m9l8VdY4P8C6VnLWPyGSQQzFK/1JkGXXDfhVwYuqQ/Oh1+BtA99uxjRzSV92Ocqd kSDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hz2mq9yq; 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=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j25-20020aa7c0d9000000b0050bf9999de9si6290430edp.620.2023.06.12.19.20.22; Mon, 12 Jun 2023 19:20:46 -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=@linux.dev header.s=key1 header.b=hz2mq9yq; 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=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237495AbjFMBaw (ORCPT + 99 others); Mon, 12 Jun 2023 21:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjFMBau (ORCPT ); Mon, 12 Jun 2023 21:30:50 -0400 X-Greylist: delayed 456 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 12 Jun 2023 18:30:49 PDT Received: from out-59.mta0.migadu.com (out-59.mta0.migadu.com [IPv6:2001:41d0:1004:224b::3b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB79318E for ; Mon, 12 Jun 2023 18:30:49 -0700 (PDT) Message-ID: <6a2e8f05-ce2f-bbbb-e6ad-f9db524db997@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1686619387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Az7NwX67Bf/1j76+8r8hc++AaCY3OLyQFY+NixwvQvo=; b=hz2mq9yqhmWY9nieZx4gzwS/YE9ZWGp0bHn91oSDu5eSjBRB9SRXnmvgpPAJubxIw+lad3 15MT5ruvlPl+He8bSCbg1jwtPCIZyJwsmKxR+IgJJsr5SHdFcFZW+2c8DBNF6KZDPS50ba t/vgfYxefzC2GSqhuwsaeUuBww6SoFA= Date: Tue, 13 Jun 2023 09:22:41 +0800 MIME-Version: 1.0 Subject: Re: [PATCHv2] ftrace: Show all functions with addresses in available_filter_functions_addrs To: Jiri Olsa , Steven Rostedt Cc: Yonghong Song , Masami Hiramatsu , Mark Rutland , Andrii Nakryiko , lkml , linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Andrii Nakryiko References: <20230611130029.1202298-1-jolsa@kernel.org> <53a11f31-256d-e7bc-eca5-597571076dc5@meta.com> <20230611225407.3e9b8ad2@gandalf.local.home> <20230611225754.01350a50@gandalf.local.home> <20230612110222.50c254f3@gandalf.local.home> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Jackie Liu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 在 2023/6/13 04:25, Jiri Olsa 写道: > On Mon, Jun 12, 2023 at 11:02:22AM -0400, Steven Rostedt wrote: >> On Mon, 12 Jun 2023 07:49:53 -0700 >> Yonghong Song wrote: >> >>> I am actually interested in how available_filter_functions_addrs >>> will be used. For example, bpf_program__attach_kprobe_multi_opts() >>> can already take addresses from kallsyms. How to use >>> available_filter_functions_addrs to facilitate kprobe_multi? > > the problem is that we need to do 2 passes: > > - through available_filter_functions and find out if the function is traceable > - through /proc/kallsyms to get the address for traceable function > > having available_filter_functions symbols together with addresses allow > us to skip the kallsyms step > > and we are ok with the address in available_filter_functions_addr not being the > function entry, because kprobe_multi uses fprobe and that handles both entry and > patch-site address properly > >>> Do we need to change kernel APIs? It would be great at least we >>> got a RFC patch to answer these questions. >> >> I agree, having that information would also be useful to me. >> >> Jiri? Andrii? > > so we have 2 interfaces how to create kprobe_multi link: > > a) passing symbols to kernel > > 1) user gathers symbols and need to ensure that they are > trace-able -> pass through available_filter_functions file > > 2) kernel takes those symbols and translates them to addresses > through kallsyms api > > 3) addresses are passed to fprobe/ftrace through: > > register_fprobe_ips > -> ftrace_set_filter_ips > > b) passing addresses to kernel > > 1) user gathers symbols and needs to ensure that they are > trace-able -> pass through available_filter_functions file > > 2) user takes those symbols and translates them to addresses > through /proc/kallsyms > > 3) addresses are passed to the kernel and kernel calls: > > register_fprobe_ips > -> ftrace_set_filter_ips > > > The new available_filter_functions_addrs file helps us with option b), > because we can make 'b 1' and 'b 2' in one step - while filtering traceable > functions, we get the address directly. > > I tested the new available_filter_functions_addrs changes with some hacked > selftest changes, you can check it in here [1]. > > I assume Jackie Liu will send new version of her patchset [2] based on this > new available_filter_functions_addrs file. Yes, once the new interface is released, I will release a v2 version patch based on it. -- Jackie Liu > > I think we should have these changes coming together and add some perf > measurements from before and after to make the benefit apparent. > > jirka > > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git/commit/?h=bpf/avail_addrs&id=fecaeeaf40bae034715ab2e9a46ca1dc16371e8e > [2] https://lore.kernel.org/bpf/20230526155026.1419390-1-liu.yun@linux.dev/#r