Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1500233pxb; Wed, 30 Mar 2022 05:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVOSTY9He5/KFnMhU9OXCaYsHpLUN7AM8cDwEWsfxauQ7pJnpmkHHOhNrfoH4Of3PnBDg2 X-Received: by 2002:a05:6602:2dc4:b0:648:adac:bae8 with SMTP id l4-20020a0566022dc400b00648adacbae8mr11725946iow.9.1648642036627; Wed, 30 Mar 2022 05:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648642036; cv=none; d=google.com; s=arc-20160816; b=XBXzRwDPojJqwKfjXPuKI6X3n09zOIjgI3g0qBKlcP1tStCjgt1+HTLM3HhPKH0u8p WaumAzfoYxK59RFed3JxwIbiGBskl2lGW2ji3hLdgfY2OQojMqYh7cW0emPO3D0ZJGDT fylmZ/nv41M6Z9Cuj6EahCYHBR4DZPAoCPmFlaKtdO0P6iHvkQZQ6vPs2ACjiZpMFMZF dSRDtAIPjCOgod3l2LCqxKttAiInffB2nvyk59oOEkmIJyQH35wuw1DciMUaZ+bb5TtR WFYSAUkI4QEWpuwdh35DHLQEC+zbysfGwbK2AruW3mm6JisCXlBX9bX9DxmhcSP7/qbV mCGA== 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=LHFIzlMHcD6qDSToyvl5dbn+nrgausa4lYRWBBJH19I=; b=ROqzVStXPbM+nUMbWJjJQt1TAnL1SWICFAAI28rFoTZKJ4wd8WIy8jUI/ZodI8RJN1 O6XGqSHndGJwJX7LseTQZnc1+zUZUINyPN1j8vRoxi1yjHm++RgZYnvSuCqQbCqu25Dk 1FeQbIt2mfo0YjIxOmyT12J9nLXmuAQtFPTdDy/8SEotH4cXlSjqu57VNu++YOD46RaG wZibvT3bFP+yXMyvhBJZM0KOC3OO+t0eXFqbSsMN7S4/50/3MUHT+yFgQHzwPLmKb9k4 ved1+i/CLKDN/Qts3YlTkmN6bIcJgA8U6o64ZFk868s5jlQ7KYjtrF0GGco/5vtSwizI lPCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p9di60D4; 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 g14-20020a92cdae000000b002c9e77aae92si1336044ild.5.2022.03.30.05.07.03; Wed, 30 Mar 2022 05:07:16 -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=@gmail.com header.s=20210112 header.b=p9di60D4; 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 S241351AbiC2X4i (ORCPT + 99 others); Tue, 29 Mar 2022 19:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241293AbiC2X4e (ORCPT ); Tue, 29 Mar 2022 19:56:34 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19790BF59; Tue, 29 Mar 2022 16:54:50 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id s11so17265326pfu.13; Tue, 29 Mar 2022 16:54:50 -0700 (PDT) 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=LHFIzlMHcD6qDSToyvl5dbn+nrgausa4lYRWBBJH19I=; b=p9di60D48ivYtNgPnBsoYU638rald7+YwO7G9bXpnCNkl5b2QhXxBuTBqdgauIvS3r 89gnjBFR5nK3jUvuVPKaNxcolrTNT1gDlxTNfIQU9okqUmBA3gw3swPqNHe5VL2jVdVZ yLUfDE4ETCu4ROdmeBkJZcm7xtGFQbYcJAhBDtQGoSDYNFKh1I7HOskXhmtsbdSzTa/m GTCAy6rLqrzOGu8Y9gCb3SgBDBNi8IO9Do4jY/Pp7Em5w+AQlRbrqGjS/Srusq5LMPhc C6iFpIEEQ/Og8OZlXeE++4RyuAMfPhZItMuHjbYK1KuOAc2wrkzhRdX2KdeAwDKdu0rg CW7A== 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=LHFIzlMHcD6qDSToyvl5dbn+nrgausa4lYRWBBJH19I=; b=MKoJalFrkjV0TmWxwa5JfszBCIMVYKgDVc0Xy3/DtFzJ0cyCevpwUleHbw73qlCP9E ssMIAdhAIDu8Rv0f+B2cXIGqLxqsRuAGUnCkRC1Lo3KPe+L5RgaS+KQLGsCYqbUFqojQ um++ZpZ1vfSizTJHyGXNstgTEwYv/0x1NnTCPvV7Xm2F/2xMoIaurw/kuulu0oYUoVhr xSN3OUJohuAT1WWES9PTKMFr7jTzfARAvjw3DUddYwFlgjCahLSFmNjPDzQ71OCTmg7R VsV39iDqAo4NgbbVp7ZnyTfttK1Or9OUSHshj8gDYp+yNoAD0q3eC4NVZ5ebb2fLknlS tn0g== X-Gm-Message-State: AOAM533O8gYpi4SOcuZau4WahHAGedp2oDL2jxDmGFwDn/r9SPatxpj7 2llH2ifaa4AQz2qNA7U7jS1dmYkiBdslOAUNAuk= X-Received: by 2002:a05:6a00:995:b0:4fb:607d:444c with SMTP id u21-20020a056a00099500b004fb607d444cmr11351045pfg.69.1648598089571; Tue, 29 Mar 2022 16:54:49 -0700 (PDT) MIME-Version: 1.0 References: <20220329181935.2183-1-beaub@linux.microsoft.com> <20220329201057.GA2549@kbox> <20220329231137.GA3357@kbox> In-Reply-To: <20220329231137.GA3357@kbox> From: Alexei Starovoitov Date: Tue, 29 Mar 2022 16:54:38 -0700 Message-ID: Subject: Re: [PATCH] tracing/user_events: Add eBPF interface for user_event created events To: Beau Belgrave Cc: Steven Rostedt , Masami Hiramatsu , linux-trace-devel , LKML , bpf , Network Development , linux-arch , Mathieu Desnoyers 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, Mar 29, 2022 at 4:11 PM Beau Belgrave wrote: > > On Tue, Mar 29, 2022 at 03:31:31PM -0700, Alexei Starovoitov wrote: > > On Tue, Mar 29, 2022 at 1:11 PM Beau Belgrave wrote: > > > > > > On Tue, Mar 29, 2022 at 12:50:40PM -0700, Alexei Starovoitov wrote: > > > > On Tue, Mar 29, 2022 at 11:19 AM Beau Belgrave > > > > wrote: > > > > > > > > > > Send user_event data to attached eBPF programs for user_event based perf > > > > > events. > > > > > > > > > > Add BPF_ITER flag to allow user_event data to have a zero copy path into > > > > > eBPF programs if required. > > > > > > > > > > Update documentation to describe new flags and structures for eBPF > > > > > integration. > > > > > > > > > > Signed-off-by: Beau Belgrave > > > > > > > > The commit describes _what_ it does, but says nothing about _why_. > > > > At present I see no use out of bpf and user_events connection. > > > > The whole user_events feature looks redundant to me. > > > > We have uprobes and usdt. It doesn't look to me that > > > > user_events provide anything new that wasn't available earlier. > > > > > > A lot of the why, in general, for user_events is covered in the first > > > change in the series. > > > Link: https://lore.kernel.org/all/20220118204326.2169-1-beaub@linux.microsoft.com/ > > > > > > The why was also covered in Linux Plumbers Conference 2021 within the > > > tracing microconference. > > > > > > An example of why we want user_events: > > > Managed code running that emits data out via Open Telemetry. > > > Since it's managed there isn't a stub location to patch, it moves. > > > We watch the Open Telemetry spans in an eBPF program, when a span takes > > > too long we collect stack data and perform other actions. > > > With user_events and perf we can monitor the entire system from the root > > > container without having to have relay agents within each > > > cgroup/namespace taking up resources. > > > We do not need to enter each cgroup mnt space and determine the correct > > > patch location or the right version of each binary for processes that > > > use user_events. > > > > > > An example of why we want eBPF integration: > > > We also have scenarios where we are live decoding the data quickly. > > > Having user_data fed directly to eBPF lets us cast the data coming in to > > > a struct and decode very very quickly to determine if something is > > > wrong. > > > We can take that data quickly and put it into maps to perform further > > > aggregation as required. > > > We have scenarios that have "skid" problems, where we need to grab > > > further data exactly when the process that had the problem was running. > > > eBPF lets us do all of this that we cannot easily do otherwise. > > > > > > Another benefit from user_events is the tracing is much faster than > > > uprobes or others using int 3 traps. This is critical to us to enable on > > > production systems. > > > > None of it makes sense to me. > > Sorry. > > > To take advantage of user_events user space has to be modified > > and writev syscalls inserted. > > Yes, both user_events and lttng require user space modifications to do > tracing correctly. The syscall overheads are real, and the cost depends > on the mitigations around spectre/meltdown. > > > This is not cheap and I cannot see a production system using this interface. > > 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. > > > All you did is a poor man version of lttng that doesn't rely > > on such heavy instrumentation. > > Well I am a frugal person. :) > > This work has solved some critical issues we've been having, and I would > appreciate a review of the code if possible. It's a NACK to connect bpf and user_events. I would remove user_events from the kernel too.