Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp403468pxb; Thu, 17 Feb 2022 06:39:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcJRnQ3VqTosy2LMqbP53jaHOs8aQ9nRmhVOP7Zfb1odDYZjvSVOq+iY2Pi6465pXfMn3q X-Received: by 2002:a17:90a:17ce:b0:1b8:a7ed:f91d with SMTP id q72-20020a17090a17ce00b001b8a7edf91dmr3349148pja.64.1645108776063; Thu, 17 Feb 2022 06:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645108776; cv=none; d=google.com; s=arc-20160816; b=giP1GCzfZGfFVZWH1DGgLdsV1KQO2n02Y3MJC6PIetdklmvoUDd/vu31alURdrLmmr Q6ozxV2arBcOoKQUmwJyBAE8sseLvLnS/X7k9FFr2aOv2VpNqrHPN6206Ai1TbYKDqhd Vu4ugkyqI/KjOWgBbA2gG/ovsBEiTKu11HSudN3SaW6Xwwmu51Icoy5b8qcIsWcEaaYJ mV4PdeG9JwBhSvWRK1Mgd6t2Zw2keoTI/uVb0aaEWyYhxm+bCVXuWj/qOY19D7DlGMk1 rIY+b5hSvvTRP2yu0Z2NtsYkIMMU0q9C+bsIsRd6IlKDEEgGUMuQe83a+Z/pK07LZtkN MNEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+DIL0XWxnUAb+aSBB2qvM1MxTnAf3eythJ8eeHGycdc=; b=CGYFu1UoOTwGz462nPH7Q1IGGrZoq+N2Egt6I+akkr9otDa1kPWd1Jvr9CBRNC36Na vnIVPMDLAZXLbxwfKEUN8Y6osnllWiauhN0ubMshs3p2ZD1hYjb1Mcnuy6xTnyKMFKGv gx+4P0Gy0o5uj43HudAbRUQmtfXZ4hEYAopv+iiT700B+TE1xLfbWHHCXYc3zCA3ohRN a3MWdcxrrt61swvH4cB0bKirKsSE6VzeTVQ2MKSVAa14VnxB/An6qDa/eXenn4YsNM4y 3lLTda9B/2+3RFldO5OADed/UZFI2oSRjPm5GqSzcCsd5mvoihzLyOq0GB+ueRVe5auj 2tlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KlsvN2xC; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q78si8334822pgq.722.2022.02.17.06.39.19; Thu, 17 Feb 2022 06:39:36 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=KlsvN2xC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241557AbiBQOEX (ORCPT + 99 others); Thu, 17 Feb 2022 09:04:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbiBQOEU (ORCPT ); Thu, 17 Feb 2022 09:04:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1DC911C20; Thu, 17 Feb 2022 06:04:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 38ED361D44; Thu, 17 Feb 2022 14:04:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4FF8C340E9; Thu, 17 Feb 2022 14:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645106644; bh=5TQEKUug/zE0vEucMuLhHGprgquDacd/+Ob9lkA8xSg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KlsvN2xCKWDCfdXd5XQdF+jtciTljbVQ9GeaZXiY4YdPHVRzoBltADUSwbgMRU2s6 O8tDc51XcwC7DcAzpAdGAT4NsdlFGyN/YVZNvameIaiiNCHXej8wemwB7kt1JwO5wR NTZTD0IP7xwvXxcrR/qr5LtXwjGFxWJaNZ96b3j9smAnmjSKqAWTmngR1Rd9p2GQMy +m9x5wvUasZ3Hd1CKBo3nWjs+t2u1gCVnda4rUXP/kqHZ+3Zt3f8szchiMnnzcXChe dkIhAr2A8yBq3NJzyEGHZurvdmZ5wKImgpRiwfx+nkoGlWXjTJsDawIBMjbEbLsKZe jfQv3BwzAqDrw== Date: Thu, 17 Feb 2022 23:03:57 +0900 From: Masami Hiramatsu To: Andrii Nakryiko Cc: Jiri Olsa , Masami Hiramatsu , Alexei Starovoitov , Steven Rostedt , Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Network Development , bpf , lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Oleg Nesterov Subject: Re: [PATCH 0/8] bpf: Add fprobe link Message-Id: <20220217230357.67d09baa261346a985b029b6@kernel.org> In-Reply-To: References: <20220204094619.2784e00c0b7359356458ca57@kernel.org> <20220204110704.7c6eaf43ff9c8f5fe9bf3179@kernel.org> <20220203211954.67c20cd3@gandalf.local.home> <20220204125942.a4bda408f536c2e3248955e1@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 Wed, 16 Feb 2022 10:27:19 -0800 Andrii Nakryiko wrote: > On Tue, Feb 15, 2022 at 5:21 AM Jiri Olsa wrote: > > > > On Fri, Feb 04, 2022 at 12:59:42PM +0900, Masami Hiramatsu wrote: > > > Hi Alexei, > > > > > > On Thu, 3 Feb 2022 18:42:22 -0800 > > > Alexei Starovoitov wrote: > > > > > > > On Thu, Feb 3, 2022 at 6:19 PM Steven Rostedt wrote: > > > > > > > > > > On Thu, 3 Feb 2022 18:12:11 -0800 > > > > > Alexei Starovoitov wrote: > > > > > > > > > > > > No, fprobe is NOT kprobe on ftrace, kprobe on ftrace is already implemented > > > > > > > transparently. > > > > > > > > > > > > Not true. > > > > > > fprobe is nothing but _explicit_ kprobe on ftrace. > > > > > > There was an implicit optimization for kprobe when ftrace > > > > > > could be used. > > > > > > All this new interface is doing is making it explicit. > > > > > > So a new name is not warranted here. > > > > > > > > > > > > > from that viewpoint, fprobe and kprobe interface are similar but different. > > > > > > > > > > > > What is the difference? > > > > > > I don't see it. > > > > > > > > > > IIUC, a kprobe on a function (or ftrace, aka fprobe) gives some extra > > > > > abilities that a normal kprobe does not. Namely, "what is the function > > > > > parameters?" > > > > > > > > > > You can only reliably get the parameters at function entry. Hence, by > > > > > having a probe that is unique to functions as supposed to the middle of a > > > > > function, makes sense to me. > > > > > > > > > > That is, the API can change. "Give me parameter X". That along with some > > > > > BTF reading, could figure out how to get parameter X, and record that. > > > > > > > > This is more or less a description of kprobe on ftrace :) > > > > The bpf+kprobe users were relying on that for a long time. > > > > See PT_REGS_PARM1() macros in bpf_tracing.h > > > > They're meaningful only with kprobe on ftrace. > > > > So, no, fprobe is not inventing anything new here. > > > > > > Hmm, you may be misleading why PT_REGS_PARAM1() macro works. You can use > > > it even if CONFIG_FUNCITON_TRACER=n if your kernel is built with > > > CONFIG_KPROBES=y. It is valid unless you put a probe out of function > > > entry. > > > > > > > No one is using kprobe in the middle of the function. > > > > It's too difficult to make anything useful out of it, > > > > so no one bothers. > > > > When people say "kprobe" 99 out of 100 they mean > > > > kprobe on ftrace/fentry. > > > > > > I see. But the kprobe is kprobe. It is not designed to support multiple > > > probe points. If I'm forced to say, I can rename the struct fprobe to > > > struct multi_kprobe, but that doesn't change the essence. You may need > > > to use both of kprobes and so-called multi_kprobe properly. (Someone > > > need to do that.) > > > > hi, > > tying to kick things further ;-) I was thinking about bpf side of this > > and we could use following interface: > > > > enum bpf_attach_type { > > ... > > BPF_TRACE_KPROBE_MULTI > > }; > > > > enum bpf_link_type { > > ... > > BPF_LINK_TYPE_KPROBE_MULTI > > }; > > > > union bpf_attr { > > > > struct { > > ... > > struct { > > __aligned_u64 syms; > > __aligned_u64 addrs; > > __aligned_u64 cookies; > > __u32 cnt; > > __u32 flags; > > } kprobe_multi; > > } link_create; > > } > > > > because from bpf user POV it's new link for attaching multiple kprobes > > and I agree new 'fprobe' type name in here brings more confusion, using > > kprobe_multi is straightforward > > > > thoguhts? > > I think this makes sense. We do need new type of link to store ip -> > cookie mapping anyways. This looks good to me too. > > Is there any chance to support this fast multi-attach for uprobe? If > yes, we might want to reuse the same link for both (so should we name > it more generically? There is no interface to do that but also there is no limitation to expand uprobes. For the kprobes, there are some limitations for the function entry because it needs to share the space with ftrace. So I introduced fprobe for easier to use. > on the other hand BPF program type for uprobe is > BPF_PROG_TYPE_KPROBE anyway, so keeping it as "kprobe" also would be > consistent with what we have today). Hmm, I'm not sure why BPF made such design choice... (Uprobe needs the target program.) > But yeah, the main question is whether there is something preventing > us from supporting multi-attach uprobe as well? It would be really > great for USDT use case. Ah, for the USDT, it will be useful. But since now we will have "user-event" which is faster than uprobes, we may be better to consider to use it. I'm not so sure how uprobes probes the target process, but maybe it has to manage some memory pages and task related things. If we can split those task-related part from struct uprobe software-breakpoint part, it maybe easy to support multiple probe (one task-related part + multiple software-breakpoint parts.) Thank you, -- Masami Hiramatsu