Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp794600rdb; Thu, 15 Feb 2024 16:14:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+axHpnmU4Fd80G0OWSBT6mGDIvQzW7gE2xNNPCVA6BOH45qLHMh7HgocBOxwlNMBxkyAJSYsk1/sQS0z/Oo8SdymWUmZHoswuCvb6Kg== X-Google-Smtp-Source: AGHT+IGIbQcGC3hGWX6QG1L/+fYHSoAYJ0FEbIPaE6/kXz6Ujg5PMhg4nHTT1ve+rpIROI1xYYw7 X-Received: by 2002:a05:6808:17a3:b0:3c1:345c:3b5d with SMTP id bg35-20020a05680817a300b003c1345c3b5dmr4286880oib.2.1708042463146; Thu, 15 Feb 2024 16:14:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708042463; cv=pass; d=google.com; s=arc-20160816; b=0MITivmvma9ILH3G0RP7NvzgLCAbT1+43r0d5yU+sMjl4kGjEsWy1BENsflNW8HCXS 74UFmOajzY8SgOEVP7v9Gfcd6YWLIP5lc+ezQy8tAcc2RCgB2W5M3lQHVu7Vrn1C7O7A v6Sj4HqVNmR+3uOhEZsSvDy+mZ1hEbRQvBkV3+1DZCldv6DPdOZXL5WTwksi3x1krkuW ZzNAUbNr2IgvZHtCdGX+I2zHaAwHJfl/tG8mD+5KLN+dMnN+HmaOUC4x6ochU8XYDByI HcQBbLCc5kmahjeyInHf9BRqQhFfk7Z54fZ09zFmwp9Vl3cEXULMHMrpBZ3WL9z5+9F8 eFvA== ARC-Message-Signature: i=2; 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=VP/5h+SFOqXWog8lvjT9gXJwkgwdET6/xnyGoYUrUPc=; fh=BUY8aUj5tz/qe26m8bED74qJSmJBPlKjmeLESs3Na4s=; b=bKN6aauBrHKFpHbFSEPSynQkm2QWEfQKZeBNoMqIiPLaQkKfM7PVNf1iQ/Vm6BMlf+ cT0pSH+FHQhcxwIM82XVJScm8syGmrIttsIek1g2r3ri2qs6jg8FqFZOk8esvbqjs292 DRcJx9E0SH1O2miJOyMaAHK0GpE8JxuLu/8oZFY4/EKujWXSr2ofs+eCLeolMYU9Zef3 pufAkbXDNDREq0d64TDXjziJIuvQI986DOvSF1u7n3Op95F93Exh+y55Vuu6wHc6GK88 owrvBkNjS4sxgkG6RxCqJBYnc+YRhHwjkfK6ZfNbdaSUBvawA56Y/qEPqF6hT/MwPFSb YNOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EExMkWbe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67884-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fo9-20020ad45f09000000b0068ec08c8732si2772914qvb.195.2024.02.15.16.14.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:14:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67884-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=@gmail.com header.s=20230601 header.b=EExMkWbe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67884-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 DD02B1C20D6E for ; Fri, 16 Feb 2024 00:14:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBC101C11; Fri, 16 Feb 2024 00:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EExMkWbe" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77F1AEC2; Fri, 16 Feb 2024 00:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708042454; cv=none; b=ZGbyeduyu6WR7sIcvRJcMaXpYRB5UJa9a2XORCxmj6nr0VyZpBYMTHRvWTNYzI0xRwygS6CkLivu0sv9SeC8o9raw1EDABEGrbolrtooh/EtcrK39c4Q7H3UZ0iws29K9v419ZnJkhYsZFrD1CwpVhaExd41dBAj+j6OEPsutjI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708042454; c=relaxed/simple; bh=DTuSJ52J8N/bX5W9VU/x7SAXIJrn5eN4LG3JgCE/Q4c=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gFcJ9dOR5Ew8R7ZinDqqB4TxQ/YkON7sG9sjbZv6l+xvLpK3YNexiQLliPF+uAERi00GMJoANZpitIDN0zpqv0vaD4NdTWiG0+YHcYoMXdiak0r1uwgMSmNYE0cfsqPemEGtr73zcgIp8/fNu/XXmafWubNwax6cqTEsu/dP21c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EExMkWbe; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5dca1efad59so1354726a12.2; Thu, 15 Feb 2024 16:14:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708042451; x=1708647251; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VP/5h+SFOqXWog8lvjT9gXJwkgwdET6/xnyGoYUrUPc=; b=EExMkWbe7Y6IODudWEM1LotiPHfoBUDEviizsvcWknDZQxaYfG5ndlbMCZiCr3R8mW vGojo4CmuLs3RQeq3yVjSfUwBcj9kXLyOmQsrbux1A6nnn4HecvPBhx7EeA6Ch328Wja AtKa3F549FzbnR49bko2EOflZjaa2SNym54FRp7myyJjPy361we8V7EPhsyG4DTOfsWO OeNRzp6u/ktH2IDnyQCuicrK/XtI0l9C9QgnEaEDzfbZt5gB4ofrPihY3fhbR61lZUGa G15Uv+rSwjAh2CQWDcp2/P7bn9EmtNpw14up3tgFI2coroH4/aHJMTg8Srp6wTGyq7rH 2CEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708042451; x=1708647251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VP/5h+SFOqXWog8lvjT9gXJwkgwdET6/xnyGoYUrUPc=; b=TEciIaekf1VnNo24wf1zRo4Va5WIPUfvBl48gr4s0MBC8zyT0G/x/fodxxyzmcReoJ Z/NWDm1RSxxXV1Sf9duyCmw0M+M6SbiMMCtumbj7sxAdU8G19b6TfXfAXZyGwYRzDSRB zUIEOSSCG4i19eLtKQd39dC3kKtjSDttoJl2JbXBq+MO1rWFyMpV2Wlc0rcnD9hk4QiA IA1Ee9H8B+y6B9DzkPTIjhOk71e8zZWWlB4RDC+l5e/dU3jmnuACSUtaIgTSdaRXyK9R R+zl4GWbuhdwnEry68XcbBbU4TFEdtiAEJjNIz+lnOAnutlIqI9ZZFikJR/reBQIfQH0 8eqA== X-Forwarded-Encrypted: i=1; AJvYcCWlhW7rpU85oebcuEEpKO6xu/yJ5E22JYPUJmULSziquOLIt0mjAhSulAnEvh5scIZT+RfAoo2mXQYaw7bPniDVyh4CTQqwN4tr54qKYe3nfRXZrvxSlBskqnmsgwtuc60gYpGMthKgvdMy9jLmCyibPB7Pbbtex21jkFBOKKzCb5x7Cw== X-Gm-Message-State: AOJu0YxEdpnnCkNewNxAWe2lMz/Smz5tV6ZYX0egurK0TmQPcQdVbP+7 N0fvD1oiwc/luWa6NHjaOgISQMVO49O55T6p9mzQ9OR/L3Iq8Zmd66g+h897abBCw1pNXl1Ki+F 1qgZi+Nfrkg6ZR9W46ogXKWIFt0s= X-Received: by 2002:a17:90b:1e0d:b0:299:32f0:8124 with SMTP id pg13-20020a17090b1e0d00b0029932f08124mr492527pjb.42.1708042451599; Thu, 15 Feb 2024 16:14:11 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240214173950.18570-1-khuey@kylehuey.com> <20240214173950.18570-4-khuey@kylehuey.com> In-Reply-To: <20240214173950.18570-4-khuey@kylehuey.com> From: Andrii Nakryiko Date: Thu, 15 Feb 2024 16:13:59 -0800 Message-ID: Subject: Re: [RESEND PATCH v5 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, Jiri Olsa , Namhyung Kim , Marco Elver , Yonghong Song , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , "Robert O'Callahan" , Song Liu , 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 Wed, Feb 14, 2024 at 9:40=E2=80=AFAM 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 > Acked-by: Jiri Olsa > Acked-by: Namhyung Kim > --- > 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 24a718e7eb98..a329bec42c4d 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -9574,6 +9574,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 > @@ -9623,10 +9628,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); > Sorry, I haven't followed previous discussions, but why can't this change be done as part of patch 1? > if (*perf_event_fasync(event) && event->pending_kill) { > event->pending_wakeup =3D 1; > -- > 2.34.1 >