Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6824064rdb; Tue, 2 Jan 2024 15:10:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwqNFojt+f5nZ0KBRyQcq/bgXyd1R6AXpD0CCqxFzIreDDqXly3A7VX5bSme2/pWX2AA5E X-Received: by 2002:a05:6808:30aa:b0:3bc:151d:24f6 with SMTP id bl42-20020a05680830aa00b003bc151d24f6mr1362149oib.79.1704237040298; Tue, 02 Jan 2024 15:10:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704237040; cv=none; d=google.com; s=arc-20160816; b=aQLICR6b0uyTG2CTTTBEX0L0NuRvsknIcm7lEG5UzIFC3rP+GhP5zffeaN130PFnXw gsYcpiHXY9NTg3FyQHuP4Cb6zrbpgbRscRhKGHNiZqlzn4HAC1U4ZLdOU3t5TZO2Qx8F WaNzp7raDqExlHHkp52WdVQqpoRqneYakJWXWmgE6y0sGJdZp9r41P49Iu37yM6kZEfb 3WhFidWW1aZjBFcno/wMGszPqMWrQ8ZFNGV51DNbrAaYOWHZ38iph8gAz9Wf2luKaAT4 p5pMYh6W5ESUW9+EOzxX4/NdzOhDj1psKRT5Iwa83N/rYvAQQ1vKsthdX7zj8qBcc0y3 rN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=UFeQqO+MQnZop/3NK9Oaba0m5BGSCQ9IHlbNjSIYzXo=; fh=nyEdS10mxrsMOkkMNreKeRijF5sNyQpzU0pkmR/jRFE=; b=oSDkTEd1q1q7Yb4V9Jfl6flHpjplbnT4NFz6IW8fJGTAhWOIOalQLpJDIhH6wrcvue G9WzPIbmUdn5ElUcnH402N8qoOymxmNPpgT5LUbdWm5/JLLjgYiqs4lvCU8SFdipkkep J8Zz5hj7+rnj50opCrCYcwydCNLPI9n3MZAky0YpOKZm0XDgmVIohKUEU980RrX6F1yp sftT0oK9dsPSMHMBcsFnK82Qsda8bmqZhpx8M+l+SLM1lzNgObs472jbiaGSxdpzDaKR YivyyKLzkw98ppi6ro9knZnYZphwnvdVIw75l1Iv7nQCtnevVNkQHXgKnCpm49UQo8Nq +svA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MMgKZl3e; spf=pass (google.com: domain of linux-kernel+bounces-14965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z12-20020a0cda8c000000b0067f74f4aa5asi29936250qvj.532.2024.01.02.15.10.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 15:10:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MMgKZl3e; spf=pass (google.com: domain of linux-kernel+bounces-14965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E8411C21AFA for ; Tue, 2 Jan 2024 23:10:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9C311775E; Tue, 2 Jan 2024 23:10:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MMgKZl3e" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF8EF1773F; Tue, 2 Jan 2024 23:10:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84F8DC4339A; Tue, 2 Jan 2024 23:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704237025; bh=cdt3nYEybKmQbfM3ySTBLTkjCOPXxwLzf6bFeEjafcI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MMgKZl3euaIgRS/rdh3jsKLdafUBcRNE+EkY06ex3veFvlpzzUZQeHr2pi3Lp2p72 70/dCGRnNy/fxoN1jEjUvsH5YYQReOflkBhLznZF+z2xAvcOXC4eJOFC5wvrnC8fuG s0gcaVOkXC1KWRsNSIDEcXwgRUXlWDHoeVzmfNHa1UjQo+5DO/PbHM4llvbRKEqqve J/t4fmsmRpc7jI40g/Ln4j3FzslxaAxtshBB1kBp9KiweeNov3w0d5K2S1CoKhJcyx 80YsMwMWWJWnuumbwguUAyNwkHNODVWnZcUlJqOiG5JDsZsr8DFg14PVW6W0jx49Tp WvWeE+8UgUhRQ== Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cd10001532so13787051fa.0; Tue, 02 Jan 2024 15:10:25 -0800 (PST) X-Gm-Message-State: AOJu0YyN4wxlin9LAoP0L1SUsiw1Zz7PKF36LaK6FT69/FXYa1AhuuXD c5mYcfWaJwkdNP82JEuKSn2yXg71GBnDaVBeLE8= X-Received: by 2002:a05:6512:b83:b0:50e:6909:7f68 with SMTP id b3-20020a0565120b8300b0050e69097f68mr10274917lfv.117.1704237023754; Tue, 02 Jan 2024 15:10:23 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231211045543.31741-1-khuey@kylehuey.com> <20231211045543.31741-4-khuey@kylehuey.com> In-Reply-To: <20231211045543.31741-4-khuey@kylehuey.com> From: Song Liu Date: Tue, 2 Jan 2024 15:10:12 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/4] perf/bpf: Allow a bpf program to suppress all sample side effects To: Kyle Huey Cc: Kyle Huey , linux-kernel@vger.kernel.org, Andrii Nakryiko , Jiri Olsa , Namhyung Kim , Marco Elver , Yonghong Song , "Robert O'Callahan" , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Dec 10, 2023 at 8:56=E2=80=AFPM Kyle Huey wrote: > > Returning zero from a bpf program attached to a perf event already > suppresses any data output. Return early from __perf_event_overflow() in > this case so it will also suppress event_limit accounting, SIGTRAP > generation, and F_ASYNC signalling. > > Signed-off-by: Kyle Huey Acked-by: Song Liu > --- > kernel/events/core.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 54f6372d2634..d6093fe893c8 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -9541,6 +9541,11 @@ static int __perf_event_overflow(struct perf_event= *event, > > ret =3D __perf_event_account_interrupt(event, throttle); > > +#ifdef CONFIG_BPF_SYSCALL > + if (event->prog && !bpf_overflow_handler(event, data, regs)) > + return ret; > +#endif > + > /* > * XXX event_limit might not quite work as expected on inherited > * events > @@ -9590,10 +9595,7 @@ static int __perf_event_overflow(struct perf_event= *event, > irq_work_queue(&event->pending_irq); > } > > -#ifdef CONFIG_BPF_SYSCALL > - if (!(event->prog && !bpf_overflow_handler(event, data, regs))) > -#endif > - READ_ONCE(event->overflow_handler)(event, data, regs); > + READ_ONCE(event->overflow_handler)(event, data, regs); > > if (*perf_event_fasync(event) && event->pending_kill) { > event->pending_wakeup =3D 1; > -- > 2.34.1 > >