Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3477910ioo; Mon, 30 May 2022 03:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGIvJLvwEXDNQxah/TqXhmDE0kDnmiQaxXh1aUwYN2OdZrUH/2zQTdh5InFlkodxFzAPed X-Received: by 2002:a17:90b:1d86:b0:1df:f670:dc51 with SMTP id pf6-20020a17090b1d8600b001dff670dc51mr22269811pjb.126.1653904903254; Mon, 30 May 2022 03:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653904903; cv=none; d=google.com; s=arc-20160816; b=ry9Jm49iibtS4ve5e/LnEd9Rmf3BXNiV/qh2THEY64W9/mmf96DKsWJme2HuR1cTlA hZwkC8kSrpz/Nh0RxgSRIae260TR5vN72xtLLI0gsNQDgbHFezSwjZq1f5TtkVBAi+Pz YZQIahPCpmkXHVrGUfoY9De6DXG8V2/dYPEJnWMNpweG+jJsjL28igJ67P60bTEoPWoY F8Tm2ZI9vT0zVNUDITIK4YyY5lNEkR+5pjp2neA8nBJsfk8wlW4wTeTeS7+2PRshxCB/ jrhiKLqACJpS2INTr7plWM7yPdA0AMkxq1rVD9FxA/cmXOowlFhHHaoEpynt74ZZoFkc q15g== 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=9+vUpzH4zsiyF0ITGPYTsdIpRtxFGEOt+NDBCWSgyyk=; b=UKPeC5EkWlZnILRshveHRWuVd22n1wj2vqxXqM4lAJ6Eoz7bPpLG9xm9CAHvwuw4wt hmwKYqI4GBBXM6SLuAcJzuWPugJ+7oLlsKL7Mgmzlnr+4IDjgPjstIwIIhXKAka1f1r+ C5G+5wWa+x8mbLljO2EdshR2AHNilWMgFJ78IxQlWHrXyX1rUUtDQ+QUBU4AaG8skZDZ o4wBqslPMiClb4C4LxlsfZ6mI2+dSc8GAuMIx4fV46w1hPg0UWEWq0igriAgc2KLnEDk 8BwkUKVxAkKa0gT7GsW+e3zk435jjbo+0GGqGWhMgvhMeHKWxmT0+MuePCB1kGLBFb2c 7gbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kKx1QfL1; 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 n4-20020a170902e54400b0015eb08a719csi9144962plf.512.2022.05.30.03.01.25; Mon, 30 May 2022 03:01:43 -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=@kernel.org header.s=k20201202 header.b=kKx1QfL1; 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 S229899AbiE3GBG (ORCPT + 99 others); Mon, 30 May 2022 02:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231518AbiE3GBC (ORCPT ); Mon, 30 May 2022 02:01:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD5B70918; Sun, 29 May 2022 23:01:01 -0700 (PDT) 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 B6ADB61024; Mon, 30 May 2022 06:01:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22C7CC3411A; Mon, 30 May 2022 06:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653890460; bh=9+vUpzH4zsiyF0ITGPYTsdIpRtxFGEOt+NDBCWSgyyk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kKx1QfL1RswEhDE4PDvaBIeKJDbfN2dG81BAsTb5bH5xuXKJX/bOWu13SFjiWgmVi Q9/Zyvj+E7r995uILsme/TtOZ6ClerEPr2gs6lRCEVQ0kIF74iAgxDl3vvO6A+ev2y ABVcwurHMwILkKT72jBXEYzJ6e6U3Huuob3BscWktyLZRezFkO/V63lLEVvzKYtYjf peYudkP/MORSnoyN/3NuMB8DvQ88PdT9yjWezxrfexBvSZKdOYVL6oSWpY9oM8WcId RRAKa2ZQrRjh0FU+e6NIdrhCFXkJzAFgWigCYQ7nyOWd1rg9gnYhyILjSF0Ja6owJb EJjYlQxJKr53A== Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-2ef5380669cso98522897b3.9; Sun, 29 May 2022 23:01:00 -0700 (PDT) X-Gm-Message-State: AOAM531S5mxlZHUJoHJJyeun48TP9N1wHIH0qrzAUcDsJvHxGAwiDydh IYhBB2usPsrHAnNAVrN1FJPmUIGHqJQG/DKfdWY= X-Received: by 2002:a81:5a87:0:b0:2ec:239:d1e with SMTP id o129-20020a815a87000000b002ec02390d1emr55732305ywb.211.1653890459185; Sun, 29 May 2022 23:00:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Song Liu Date: Sun, 29 May 2022 23:00:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 0/2] Add PROG_TEST_RUN support to BPF_PROG_TYPE_KPROBE To: Daniel Xu Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Sun, May 29, 2022 at 3:06 PM Daniel Xu wrote: > > This patchset adds PROG_TEST_RUN support to BPF_PROG_TYPE_KPROBE progs. > On top of being generally useful for unit testing kprobe progs, this > feature more specifically helps solve a relability problem with bpftrace > BEGIN and END probes. > > BEGIN and END probes are run exactly once at the beginning and end of a > bpftrace tracing session, respectively. bpftrace currently implements > the probes by creating two dummy functions and attaching the BEGIN and > END progs, if defined, to those functions and calling the dummy > functions as appropriate. This works pretty well most of the time except > for when distros strip symbols from bpftrace. Every now and then this > happens and users get confused. Having PROG_TEST_RUN support will help > solve this issue by allowing us to directly trigger uprobes from > userspace. > > Admittedly, this is a pretty specific problem and could probably be > solved other ways. However, PROG_TEST_RUN also makes unit testing more > convenient, especially as users start building more complex tracing > applications. So I see this as killing two birds with one stone. We have BPF_PROG_RUN which is an alias of BPF_PROG_TEST_RUN. I guess that's a better name for the BEGIN/END use case. Have you checked out bpf_prog_test_run_raw_tp()? AFAICT, it works as good as kprobe for this use case. Thanks, Song