Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp171197lqn; Thu, 11 Apr 2024 18:52:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJXPQCMzfpePiUTWO7lpEBmsguZFL6usASJ4FMYBYPT+CsqST59a+GLHO+vb2/6neyD9l/LXRfbPjUPesAssxwzI3AMg647+ze/B0qug== X-Google-Smtp-Source: AGHT+IFmTQtFrXhpYaW5T3K5kAjaglqnjoLy0t+7aXu4Tpvde2ul2GmT8wrwWjso/WYRnwaZDEoh X-Received: by 2002:a05:620a:4785:b0:78e:b98f:e0e2 with SMTP id dt5-20020a05620a478500b0078eb98fe0e2mr1416357qkb.52.1712886735819; Thu, 11 Apr 2024 18:52:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712886735; cv=pass; d=google.com; s=arc-20160816; b=iPpVLNRhi3FCJydE2KVVM+EQLG+6aBDuwbxR3gSO9jHyXE8RVcXo7LG/EOodYEAeo/ xGYJukaDQ7jxrjO+PwkBM+ATVLkLIZapzFbXxHLHjzK5XoATQzDP9gHqcJ7qUgPXHFyn ho1Pop7XTN12cxxrYksiBiLh5+2A6h77HMRl0oHjXjOtjFSCJRUBZu661WW03wVSo5xB 2wjsf84mVS++9Xg7pV379ltXmkwDsM8E2xNuPhcTUZW3EHktCErOVgoNf8ESdA4DgJqa 8bB72ghKhIc2BgZbIGZivlt/GosVqlYEVP/Y6fZ4c1dF5bcCfKMT7a+jrKrjtTJNgIDW ZBfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6W3XOu1JzCFnI8d0V7+Yp4cwFPdA5VsCmQsQwSODsxU=; fh=uq0xD92NtWdtEMQOvdNbWusQG/aPrPLJm5w/WZ6FA9c=; b=Ek1Lsug+lIbJsmyDrJ5ZGQlBViTwQ9lyjJ938HvejOXu5cYKVGZtOyo8ChmgWzDlTa CcvXG/R0Yw9dlN6TF7rrPq50NlY+9wzpR4E01h+wRyiVqhXvtQNwHLu7Dhurn16qnBEl I/6WQi5++jTdHFaAVKqTTWU+OEKYQvIrTL46kEJ1PUEmSbZ2I86IrH946aI9uEf9XqG2 qAlPVH0n8uqFrsJbTwerq2sDcbZcVDxOn/1dGJA0YRe0yM3W8150W8+OBa2dO8dCTqoo TRnEKyfxhewf832pZ62wYcHC/GL+kypaVTH7g1xcxtM1C23fmJqVvja5lCXZz1pxXIB8 HFqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=CCl9p0GX; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-141787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141787-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l26-20020a05620a0c1a00b0078dba304ed7si2728820qki.423.2024.04.11.18.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 18:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=CCl9p0GX; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-141787-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141787-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 3DF081C22389 for ; Fri, 12 Apr 2024 01:52:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B5EA1BC59; Fri, 12 Apr 2024 01:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b="CCl9p0GX" Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 E77A7168A8 for ; Fri, 12 Apr 2024 01:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712886659; cv=none; b=iKw/fXQRcNAA7PHUGGK7kno44uBzpFF/h6lWNco8/+l7+hzXdmyCmeV8PSJFejsIO2XzS179ION/j2QqILhflm2rUaMTGkgh3luO5c7zbQdLQ8aAjwAGqqS1xnbr2pkdHBM0rKeWX45Y+9qI7xCT48XzvVv+3zakZH/bLsCJtUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712886659; c=relaxed/simple; bh=AdlygNz0RFZef1mcIWoB8it1jPVZwP5sUo9GIGfOMoo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gmf9q9oqIB0XmYnVnbRlH0pElKfbnwk8nW2BHNmZJsfos5L7mJkiLikM9pKyohVl2kIL+a+5Hg4+SLxID9Wbr3EG79Cvz3QpnXomTvOZ2O17G9/JRPGJlS2fo8eqNI4O5JZduyJDp7s0KpOzmolIunEXrbcvdxTaxO5wPJgt3QU= 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=CCl9p0GX; arc=none smtp.client-ip=209.85.128.169 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-yw1-f169.google.com with SMTP id 00721157ae682-6181b9dc647so4605367b3.1 for ; Thu, 11 Apr 2024 18:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1712886657; x=1713491457; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6W3XOu1JzCFnI8d0V7+Yp4cwFPdA5VsCmQsQwSODsxU=; b=CCl9p0GXVhmMlklK1/QoFpwlvhnnwH9VJ6mihBgzv9ai+0wV+zdgyYF5DDcwfVvZ0A NpAeMCJ5pzQDBeMCHLV+0RSIyNcdBBLSlWajhj8zmISfuWrCP/6eJbLx0NlvF4o+Vu/5 QJvaBVvfdXhfmvj2FBV7mONS8Pr0sxnKTRr1zdEpruDXSTIGTG+FS9BRCePljkO1+shF JxeBCMBF+8/FBc5e9LoLcpFnwUanMDBr7bFwUvABXtPlt9gt/LzxWUbpy5dhr+GjWMcc KLp0vUJeh4MtKQWg8Yhfa7JeaUt4OmhD+gmfZW6AJsmST2OSMn6sIct5UVZEu+MuGXLl 9hYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712886657; x=1713491457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6W3XOu1JzCFnI8d0V7+Yp4cwFPdA5VsCmQsQwSODsxU=; b=BNpf7nX0muX4PI9QhUh5fy+gr280UFTEO2xaDlQGi8OjMwzP1kezYTVtR+REFTWe8c VTIoJTa9//YfTd4S7hQBD8AChfn/3xw9OL9ywN8gOIoSH5Y7osuP7BEMNdrsz/Ny4AQe QPUs6nmfVb2LpiI0zs1kWzLxxg/45fghI54de0nqK4Dco4I7tV2FiXpqcVcnihpzJXff fp3x9HqHnhvMMtZcO4DvqME/5iqI1pvlTvCMf48+eflnyCuuuyPJR1PStR3kYJjZlFEp HaLGk/hBu7uood1TNdxKAhAoJDPxq3H5RFwva1OkXzPvVHA+OXKggnipHflLmptVI22g h0lg== X-Forwarded-Encrypted: i=1; AJvYcCXtMl7wmSM5oJFPA7IzlwkO9oGCkT9qGqI5p/aFofeUgPnmJIjnaTOwJWiXf8pIFlpAR9X+SEwhq5VNweIpB1QPVGnwXooBQqJMFi/9 X-Gm-Message-State: AOJu0YxvoM2pa8Jv2wn/OIT8jahYEJGW/sg/kVTTKbBhb+L0CTIvelTS DEN1OcJs+cLhoTT/DTZQl4WQiuqcygjbuWPTeCWkms6SzwGtY/45ROpMEJSZfg== X-Received: by 2002:a81:af54:0:b0:611:5ff6:2608 with SMTP id x20-20020a81af54000000b006115ff62608mr1280098ywj.28.1712886656935; Thu, 11 Apr 2024 18:50:56 -0700 (PDT) Received: from ip-172-31-44-15.us-east-2.compute.internal (ec2-52-15-100-147.us-east-2.compute.amazonaws.com. [52.15.100.147]) by smtp.googlemail.com with ESMTPSA id f10-20020a05620a15aa00b0078d76c1178esm1756677qkk.119.2024.04.11.18.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 18:50:56 -0700 (PDT) From: Kyle Huey X-Google-Original-From: Kyle Huey To: Kyle Huey , linux-kernel@vger.kernel.org, Andrii Nakryiko , Jiri Olsa , Namhyung Kim , Marco Elver , Yonghong Song , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: Robert O'Callahan , bpf@vger.kernel.org, Song Liu , Andrii Nakryiko , Ingo Molnar , Mark Rutland , Alexander Shishkin , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org Subject: [PATCH v6 6/7] perf/bpf: Allow a bpf program to suppress all sample side effects Date: Thu, 11 Apr 2024 18:50:18 -0700 Message-Id: <20240412015019.7060-7-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412015019.7060-1-khuey@kylehuey.com> References: <20240412015019.7060-1-khuey@kylehuey.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Acked-by: Andrii Nakryiko --- kernel/events/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index fd601d509cea..cd88d1e89eb8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9658,6 +9658,9 @@ static int __perf_event_overflow(struct perf_event *event, ret = __perf_event_account_interrupt(event, throttle); + if (event->prog && !bpf_overflow_handler(event, data, regs)) + return ret; + /* * XXX event_limit might not quite work as expected on inherited * events @@ -9707,8 +9710,7 @@ static int __perf_event_overflow(struct perf_event *event, irq_work_queue(&event->pending_irq); } - if (!(event->prog && !bpf_overflow_handler(event, data, regs))) - 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 = 1; -- 2.34.1