Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp834702rdb; Thu, 15 Feb 2024 18:01:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7Ly95unEB9+fUwln0Iz8IMwBcPVMY8C57/OhA/TPDuG3d35kTvtDz60V5+2/FZMiUGRZTAzRPkKbU/TW52mbvG9P6pHjIf2grRVAypw== X-Google-Smtp-Source: AGHT+IHurrq/do1AMldpMMy8sE6nJ+cyLUxJuz68X3aFBWhAhAeT74zSm92eLezr08YRlbX6gkUP X-Received: by 2002:ad4:5fc6:0:b0:68d:e13:db35 with SMTP id jq6-20020ad45fc6000000b0068d0e13db35mr4683562qvb.55.1708048861983; Thu, 15 Feb 2024 18:01:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708048861; cv=pass; d=google.com; s=arc-20160816; b=XQcVhZ3nbjqABEeI7fdZSVYu7q6vq+YrQy5W3TT8NTdeDyI8yw+LQlJTu23j8HtmPO Og+xaMtxK+u5PHHgRGiMeDjFCuhk/dSrEtugO5q1SLOwFzISqLZ5Ybbp3jh236lDVnP0 s86a1M4DuxD308RsRaWq1tguhfxTic35As8oYZITgiYfeVdhUW30MwM4brj6b6abMJ+x hiAt4+kCuP8ci19M6jE+0Xlbs401fuZTHovCPvnNkjdkpxOzTpbEMeKDkXv97EmLLOqj xspoRacNl8Tl+4oPrl8N0Z5CYfhLt+jW0tiGshHx9pXJsZzEdQVOTojc4/2TPkozF1g3 F6YQ== 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=Mkh1NITpOSxywtc0rXIfkglAv7pc2Po+WHLtzXx3g5M=; fh=mJwSKJ909LMYnbWO0UXoUq8VtjSRtklQaZU178LWhpg=; b=JEzu7KEfhQ6fhOll1fDsjBL5PPdPJNgt/ZVKNMa9pT0m3K0lyFNDmsz3PeVzWUFJGN x5F483D29NJWBzQdMXM8Ovf3Kt5X/NaGAnYVy5wE14p3Tu/iji1vmXTBSeW+W6wZ4908 XOGhmktDU/huOiCm4juLcus22UwnKOxiOjhKRV/P3kF+ph0I+krlijqOhsjJblyIGgUx BwM5ql4qeIwNDRNUPApa/PHX05r/3bgrKuoOoPOwA1Crnfo3L5npQ9n/+oHfLVTp7b5E Vo/CIPs6klBATOHKSmKVlsH+wuqlKLsSp58Xu06c9+wl6u00bUR5pX3hRkuSYbUzSuXL 6w9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=DkCTWick; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-67959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67959-linux.lists.archive=gmail.com@vger.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 r5-20020ad45765000000b0068f2abbb4a8si1775806qvx.294.2024.02.15.18.01.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 18:01:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67959-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=@kylehuey.com header.s=google header.b=DkCTWick; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-67959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67959-linux.lists.archive=gmail.com@vger.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 180F71C2164D for ; Fri, 16 Feb 2024 02:00:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA15EDF69; Fri, 16 Feb 2024 01:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b="DkCTWick" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 F30B0DDAD for ; Fri, 16 Feb 2024 01:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708048797; cv=none; b=gtsalL/LzMU8SmtOYgEk30fvt//HOn36noVmQrrxblMfSOtKyaM/bhwdEwxIQxoqFmxWmThuQOwowTGoZ2f+KcUzK6YvBjsUvUZvzQoHjnlRsITYqelILzonapYiHfzEbjat3hb3qoLpXuyM5dExaADY1k9livin7wQ43dzHRo0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708048797; c=relaxed/simple; bh=6Jf8Tf3YNL8Iit35UP///6Wu8rWBNYzPIySyhB9DyxQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=OZxQU2S+OE5esyV3dHwxrCtN+FHwg4CuOuU6Ax5vtgzHYptHBWBkM7lxgjCi7tFbNtvhzw7EuL48lJuUel6rbrO1ZL64jA34HTu0bWGXoJwfXfcxJ71MbAbR1HN7GUh+P5MKLzRbwMRScZYohXtBJSbqkwF6yiSkXUy8qhK8Kxc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylehuey.com; spf=pass smtp.mailfrom=kylehuey.com; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b=DkCTWick; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylehuey.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylehuey.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a3122b70439so173440266b.3 for ; Thu, 15 Feb 2024 17:59:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1708048793; x=1708653593; 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=Mkh1NITpOSxywtc0rXIfkglAv7pc2Po+WHLtzXx3g5M=; b=DkCTWicksi/iGrSwllQAvEn0iDjk5BaGaBQ+GgjBTOTwHL0pgWMc1LYxy8F6kY9Hwq dGrxgywpRbRrrMmt/NwgHdR/h6r08EjjdU9t9YBzUaZauDNvDkrHkVOMWoMV5UVhE8IH a+8xXqIdS1guLqD9bMjHK/JujRg26lUdUB7cqitSEX5LPz/xxkGpXvbSHeLCAD+/6Fkg wz4uoPjqHrdhDp07919YKejqyY0N73BbcJRUa9N0UMxgyKCSiD+hqfQ/JjCq3pe88/ue gLrc9n0GIfJTBWT2IqNom/QsWLvvgI31mHsbopd/0EqHV/xqahT40f/f/s3Sjdk/yHXQ g5ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708048793; x=1708653593; 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=Mkh1NITpOSxywtc0rXIfkglAv7pc2Po+WHLtzXx3g5M=; b=FeHPIbH8MhZE/ObLW4qWcWYdmU/kh2Vy9+7/8ibtndlceodp2aloz4KO+YnOWY9Ki7 RhvhJTPfOP8z+9FaSV/+VwY8VMCG3ZZzs8IXoj3eu61Ewni8RwjZg4WWWwgkvBaLLGbp 8FDWP/f1/PQ3NEXdyEG5bA856eIUZvC0jNmw2B6iTaERINenUPemra90jzQrvhzhX1Te FxNAiVZuH0VGR0DOLR0UJNbg/DraSgnlBIJY9E5uxR5qG9viTEik56XdD+fAov33ph/L 3pUuncQqeiSZg2Dcpo5l2Q4m/OmPpJedxsyUqle2oBr8F4QtE7jr5EgTQa+O9F2Fhqlf Gu1Q== X-Forwarded-Encrypted: i=1; AJvYcCVMP7sefaV6703TyEFjtwZOehD+JQBRxTHbp+mwB4gr6UnXzNn510xuNjvDsvE+IA7AHfarmlmMYAJG0F1PeoSRIXwJn47mgY9WZmD9 X-Gm-Message-State: AOJu0Yz3XxVSvyQofyBSYNixer7PDBj/f2ysF3h/lWdCG0dqWURAwtIk hZrDZcfGu/AwOm2j/o3coGKgGXxtZUE/MntOORE9rI911RvYzLKePr4SzcCxyuQVf6kbi7fiq+u tqfk0IZGTxChnhchbFk+tqvL9xE/S7kDVh64y X-Received: by 2002:a17:906:e52:b0:a3d:678e:d020 with SMTP id q18-20020a1709060e5200b00a3d678ed020mr2263334eji.43.1708048793090; Thu, 15 Feb 2024 17:59:53 -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: From: Kyle Huey Date: Thu, 15 Feb 2024 17:59:41 -0800 Message-ID: Subject: Re: [RESEND PATCH v5 3/4] perf/bpf: Allow a bpf program to suppress all sample side effects To: Andrii Nakryiko 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 Thu, Feb 15, 2024 at 4:14=E2=80=AFPM Andrii Nakryiko wrote: > > 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() i= n > > 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_eve= nt *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 inherite= d > > * events > > @@ -9623,10 +9628,7 @@ static int __perf_event_overflow(struct perf_eve= nt *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? The idea was to refactor the code without making any behavior changes (patches 1 and 2) and then to change the behavior (patch 3). - Kyle > > if (*perf_event_fasync(event) && event->pending_kill) { > > event->pending_wakeup =3D 1; > > -- > > 2.34.1 > >