Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1130822pxb; Wed, 16 Feb 2022 11:42:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfqRWM1Xn5OC9xNF3F///eolGkUfbE83wJBJN8Qa2dyoCQrGJ09RDx2Tqf0cDWPxF8MmLP X-Received: by 2002:a17:906:7093:b0:6bd:eb91:1730 with SMTP id b19-20020a170906709300b006bdeb911730mr3480733ejk.695.1645040529146; Wed, 16 Feb 2022 11:42:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645040529; cv=none; d=google.com; s=arc-20160816; b=Ti7XMayi7NjJiio4tcxmNEl8fmVCdTMrodhDHKXVIxhqgWwoMahRoD/tt3aYuFIQCp 5B6BYDitH1X2y7bJ+YKx21L1JTPeFrCMSd1RpOqMiZDJ/NNu96uboCvNs8S2JAN42pIM lpTCEUqSXBZj3ORo7gAxY4bP/E7hhSgo80zXlnl/5y6COVpheVjXj21PngcwZCBaaGW4 9NASyw0HvKkGEsvKg1R6uw7dKI4itdZkuvG7koUUXDirz8eolFi0yShFRDOEScZtdPGI WRJl6kQyAXqDEKTM6nTTUjXzqvYPdmtyjB6A5dUmF3gVG5ZtUzh6HE9x6wgUN2CyHcab A74w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cOcn/3/cCrzj4+eIAU0TlZEiW9Bi0T8velPLnnoMOp0=; b=B2ZPZuPA/qmyy/imsp8FJAseHmPGAGFsM9TR+qivB71F3QVXTWkNZNHUdawUkGRTZL FVIo5yD6ZC1SUX+xAVR2y0x2FRv0dH0MsTFCK2qwS4SOni02N3toouqVpvTAB3cXHhQO YHbg3hb42pLUqXIgr0HFBuas9bkCXKTkoLYlppfKmoRdc6M+5Y6zloZiPifkw/XNLzA8 mkbnAJFe45x3gMsI1uJdyuoASScuDF/zNb6Ocas4dlUeJH83IVvwjtCd/Z9o1eHO41g+ yVueJJYrfaOrCI5TZcrTZzLQnEoxeBqwoJrNikSTL4ID3eBjx+QfOvgs7qow2hOdO4iI NRrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jOM726r1; 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 8si462127eje.184.2022.02.16.11.41.46; Wed, 16 Feb 2022 11:42:09 -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=@gmail.com header.s=20210112 header.b=jOM726r1; 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 S237650AbiBPS1q (ORCPT + 99 others); Wed, 16 Feb 2022 13:27:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237632AbiBPS1o (ORCPT ); Wed, 16 Feb 2022 13:27:44 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A974C2E78; Wed, 16 Feb 2022 10:27:32 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id f13so449418ilq.5; Wed, 16 Feb 2022 10:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cOcn/3/cCrzj4+eIAU0TlZEiW9Bi0T8velPLnnoMOp0=; b=jOM726r1yxEA2eI2TR0QzX0YLb9iOufgfJvh4rq/1h4SoZupiLLygPCjLAXSAthCoL IjD02c3rvV0JyCS3PqSRNLvfwNaWi7Jep1fksNnvVm7XuVjlRpRCd8qmxyw0Zpk5Nf21 UOk5hYAysOfiVCyEhBmeLsUC6CsqitTYndFgTQfAOzw27qLWTRicHkxI9PjHvJrB6swF LWaOI21XTxT6Fmz9Ij3mcqxUZYcnn0+59fA8L6aZ6M8kbEj69gMF5lgf7msjTgsKtGmT u1p+fGNCkY82lE+V0fQViponTbd2A2Hm0+u95UWN6F30EoY6etJcH6+sf8Cne8jkiZWq Pavg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cOcn/3/cCrzj4+eIAU0TlZEiW9Bi0T8velPLnnoMOp0=; b=yDJehPgOOD1ImKncK6sz5xxBqI1DmBq8Bk0HPsVBKhwmUwEffiEzbiikQIPhZMVPnT Av9ZdSB2UkUxUw3kzVIcKhywP11Z5XhKalVO5c+bIimZjD8ixpXdRckWwSJkMKXRiDgZ 8JYXAK4v7qsQabZEpTA0vfruYcIVeNYEbhbdTC1D6/oG/y1PDe000C9WHqrQefm4lnrK mgLOFGA8lgMG2+kVydvj+UQJvnvnPk4S2Z87mUeTjrWS3r2KlZQab4r2yb1V5Lv3Ocsc sc40MI2oYNR7bhacrxvF2iPkcFPsXevbR7Pgr+w4rjP7Prz6/+ts9KPUVUHAPw/OCXva 1Sjw== X-Gm-Message-State: AOAM530+xghtXJqKMnMXddN5lQqnbUTY93bqjFPg8epljI476xPVnvXn vmnDBYbuT8+ydtSt+RI2cJUe2qIm1NDW4iIjzwE= X-Received: by 2002:a92:6406:0:b0:2bb:f1de:e13e with SMTP id y6-20020a926406000000b002bbf1dee13emr2561159ilb.305.1645036051512; Wed, 16 Feb 2022 10:27:31 -0800 (PST) MIME-Version: 1.0 References: <20220204094619.2784e00c0b7359356458ca57@kernel.org> <20220204110704.7c6eaf43ff9c8f5fe9bf3179@kernel.org> <20220203211954.67c20cd3@gandalf.local.home> <20220204125942.a4bda408f536c2e3248955e1@kernel.org> In-Reply-To: From: Andrii Nakryiko Date: Wed, 16 Feb 2022 10:27:19 -0800 Message-ID: Subject: Re: [PATCH 0/8] bpf: Add fprobe link To: Jiri Olsa Cc: 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 Content-Type: text/plain; charset="UTF-8" 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_NONE,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, 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. 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? 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). 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. > > thanks, > jirka