Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp214212lfu; Wed, 30 Mar 2022 21:18:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUl4WKm6KxWtrm9hZHWyN2O+kZ56RLNl37+mVxcURccAPfK0Qr4JdxPp/M1MnQMutGR4jo X-Received: by 2002:a17:902:cec5:b0:154:6b18:6157 with SMTP id d5-20020a170902cec500b001546b186157mr3335153plg.145.1648700297040; Wed, 30 Mar 2022 21:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648700297; cv=none; d=google.com; s=arc-20160816; b=aiOIX9qZnIg5q7fCwZdHj2V58pusnUtctG47aoFskA0N/YyarADu42DU9vxfpmh4uA IR/Js+NfoazCp00lownry6ZSbzFgmPoe6UqQcdNC+mlAsAyGG6KzwYHb8fGicbKeLTlZ eLysCxSvhpCW47QH3UGO7XVSNh4bJCTwMzi2z/lS1MJ8Pg03ojyWQ08Vo26nH5azBFQk tFeAdyrEFh8TZsbOGPZsmZPr5vQcB92pBc3Q4cHL2bW+rBwC4d+osRCucYPAdylDglCW CBCvbVH4IQXTZZR9vtVlX4Ue2J4GwVBJb/NhjebyVUFS2qNmlEMK3k65K2VE/bmhI5EX JuNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=OeZ8/SZ1GczHo9IGsLxSD9nnX7NFl5IGvTh0bc7L8RI=; b=O2fVAx/pDr4ce/5X09JZGdxU/sYhS9FVOiXVMQsqSNalMbxs2d5Rn0sQxnbYheRAxN lsHSiQk3yae3z00TdJ220+IBHMqLNc80adNsRq2wkXzC/i/iMM56sOw8iRVzX5J0N9Xx R2FVaxdqLO0QHzkDKfzFsk2CZ5rAxg/9TQ20BvAtJXLWM87gXGktNgcTvRNb7ozv7dOu 9Z48y/dPYp0rjs0UFC0Ko/rCyl5c0WC4jJvbG5V9DS0UBmgQC/mUc5dhOKjz5/gehZcC kW/cmsr54txRRJ0KnFEdpxH5+K6WQfbI81hvIndexm0RMtUKrkD+jFR4V5sad1ALrL86 wgZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ZisbqAIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l15-20020a170903244f00b00153b2d165a4si3061384pls.428.2022.03.30.21.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:18:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ZisbqAIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB96F18EEAB; Wed, 30 Mar 2022 20:14:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350855AbiC3TS0 (ORCPT + 99 others); Wed, 30 Mar 2022 15:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350980AbiC3TR4 (ORCPT ); Wed, 30 Mar 2022 15:17:56 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 387A25575C; Wed, 30 Mar 2022 12:15:58 -0700 (PDT) Received: from kbox (c-73-140-2-214.hsd1.wa.comcast.net [73.140.2.214]) by linux.microsoft.com (Postfix) with ESMTPSA id 93FC920B96D4; Wed, 30 Mar 2022 12:15:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 93FC920B96D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1648667757; bh=OeZ8/SZ1GczHo9IGsLxSD9nnX7NFl5IGvTh0bc7L8RI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZisbqAIrDvBTni1uhnIdYvN6r90QUT5ABHvlHtIIFu2VOX6OYb63rx0Hd6IRq7SX0 1Ch9+QPGwTsMAvI0Keq1IqVVusqn/tYFV+ZzTAM/k3oxbq0D4Z7VoBTUz8bY1cPjAd l1D99Qe4+iRuqMru7NvStSeINgcgQuENqO+aduEo= Date: Wed, 30 Mar 2022 12:15:51 -0700 From: Beau Belgrave To: Alexei Starovoitov Cc: Song Liu , Steven Rostedt , Masami Hiramatsu , linux-trace-devel , LKML , bpf , Network Development , linux-arch , Mathieu Desnoyers Subject: Re: [PATCH] tracing/user_events: Add eBPF interface for user_event created events Message-ID: <20220330191551.GA2377@kbox> References: <20220329181935.2183-1-beaub@linux.microsoft.com> <20220329201057.GA2549@kbox> <20220329231137.GA3357@kbox> <20220330163411.GA1812@kbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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, Mar 30, 2022 at 11:22:32AM -0700, Alexei Starovoitov wrote: > On Wed, Mar 30, 2022 at 9:34 AM Beau Belgrave wrote: > > > > > > > > But you are fine with uprobe costs? uprobes appear to be much more costly > > > > than a syscall approach on the hardware I've run on. > > Care to share the numbers? > uprobe over USDT is a single trap. > Not much slower compared to syscall with kpti. > Sure, these are the numbers we have from a production device. They are captured via perf via PERF_COUNT_HW_CPU_CYCLES. It's running a 20K loop emitting 4 bytes of data out. Each 4 byte event time is recorded via perf. At the end we have the total time and the max seen. null numbers represent a 20K loop with just perf start/stop ioctl costs. null: min=2863, avg=2953, max=30815 uprobe: min=10994, avg=11376, max=146682 uevent: min=7043, avg=7320, max=95396 lttng: min=6270, avg=6508, max=41951 These costs include the data getting into a buffer, so they represent what we would see in production vs the trap cost alone. For uprobe this means we created a uprobe and attached it via tracefs to get the above numbers. There also seems to be some thinking around this as well from Song Liu. Link: https://lore.kernel.org/lkml/20200801084721.1812607-1-songliubraving@fb.com/ From the link: 1. User programs are faster. The new selftest added in 5/5, shows that a simple uprobe program takes 1400 nanoseconds, while user program only takes 300 nanoseconds. > > > > > > Can we achieve the same/similar performance with sys_bpf(BPF_PROG_RUN)? > > > > > > > I think so, the tough part is how do you let the user-space know which > > program is attached to run? In the current code this is done by the BPF > > program attaching to the event via perf and we run the one there if > > any when data is emitted out via write calls. > > > > I would want to make sure that operators can decide where the user-space > > data goes (perf/ftrace/eBPF) after the code has been written. With the > > current code this is done via the tracepoint callbacks that perf/ftrace > > hook up when operators enable recording via perf, tracefs, libbpf, etc. > > > > We have managed code (C#/Java) where we cannot utilize stubs or traps > > easily due to code movement. So we are limited in how we can approach > > this problem. Having the interface be mmap/write has enabled this > > for us, since it's easy to interact with in most languages and gives us > > lifetime management of the trace objects between user-space and the > > kernel. > > Then you should probably invest into making USDT work inside > java applications instead of reinventing the wheel. > > As an alternative you can do a dummy write or any other syscall > and attach bpf on the kernel side. > No kernel changes are necessary. We only want syscall/tracing overheads for the specific events that are hooked. I don't see how we could hook up a dummy write that is unique per-event without having a way to know when the event is being traced. Thanks, -Beau