Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp750218rdh; Wed, 14 Feb 2024 10:09:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWDBlZLomUBCEjYVC5zRlPgukLUMpgzGElM6gSY+gb3WcNzlhNnNLsYwgtTkSDFrqQ1W2qZKJIBMIP5K5BdWd18CF5J6iDEejEXvo20dw== X-Google-Smtp-Source: AGHT+IG1xGRvhjpNDz2So7hT+q0fVt376jx5dV20x8hi3vEb8IZI+oiif0rXwoYXCxPI07cWQq0Q X-Received: by 2002:a92:d201:0:b0:363:8df1:c52a with SMTP id y1-20020a92d201000000b003638df1c52amr3598237ily.8.1707934155202; Wed, 14 Feb 2024 10:09:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707934155; cv=pass; d=google.com; s=arc-20160816; b=GI8ljZNffgEinFUNOCuRaqPRk6zP3GYNB66vJrcZ4zzTU6jJS/mDkIJIV55iJUesYW 84pQSjnJEkWf6c2jkH41YMq9nNqcoyiirf923kGcLAzIDrcMZFfL6KU0OB+sN31tlzC2 dsYMyE9qd0bOE5qDUgda+MylEWUCgdgnErKNkSKpCxDx3xCiT8rpmkw74tNVqVBXFumw GK8Cf3QGKQloynr+b7Y0NDXXDRd+TAdGz2IvxyyNB1r+s/toCyzwM2NhmTbqVA46vbXc oQRCn1wlH21fIUYb4Lmx8zQhOnfJ0h9qN0Z5zRzNt5m6z4TuB2uPp1LH5WBalqWmnREM K0QA== 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=HG1Z9345f9l/NkzG8Y/mlPsfRpv6azyFKs0IWGP/jfI=; fh=bDscMnaYJaj3GKxZdaQWK6H9HrpxYHEI2pJPNB9zEvo=; b=Axi5ouwUEDQUTlyj9ZCI8Y3Z8yw2HYlm+K1I0fzqcQJAahlDd/NjM4LA8S0VNlbQIa /bPjmZH0PXyes+Qmx5Nki+k4/YC2Dy7kZVAlfEgAr0qRiiDZh43HAFicL5XdQJbasgzW +o9xCKRll7x5rygquD8Ob3E08st6hngmaY4cqh0bTlNwoCJ5SSlH8J+j970EfQSa0jL9 dJn8DBZ+WR8ZChQDB+iaIn079caMr2C6r2RcuA+pANUKf6vaHlS8QT5o8n/28YvsV3ku gpugrPY214guHg59bghhLPOZNKxMfN/Yq3Z8sOephG0PI6aozRU6fvBKgK9SPKf3gHlp LCBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=OPM2+jI5; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-65699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65699-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXBrk++Pbctf3kf7bQf/IufmP8ZrgnFWFbAwu/DrMVUwbkjbSPKHXrZEPcSZIbaAI8wz9sN6wYfO0yCX/EMLkIQdbRTaQM2YK3rnsrUdg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id dr11-20020a056a020fcb00b005d8e1dc1df6si1087871pgb.731.2024.02.14.10.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 10:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=OPM2+jI5; arc=pass (i=1 spf=pass spfdomain=kylehuey.com dkim=pass dkdomain=kylehuey.com); spf=pass (google.com: domain of linux-kernel+bounces-65699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65699-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 99C84B2E793 for ; Wed, 14 Feb 2024 17:41:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1304B8594C; Wed, 14 Feb 2024 17:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kylehuey.com header.i=@kylehuey.com header.b="OPM2+jI5" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 A339185651 for ; Wed, 14 Feb 2024 17:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707932449; cv=none; b=uSfiFVxdV8OgnIB+5NPxFaJhGi/qf0TjFz6SBqhhIMIQ71ivNNvNZRAfH3Lyf+AruA5dkP6b9e6oE1m/Wk+yBO4zuWxnS+oP54K5vokpquuBQiu1ga39kihZ9l9AFO4EHHEGlIXyOSL2TlLW0oa/IsSKbzoAPFCe/ySUMUyGdNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707932449; c=relaxed/simple; bh=PX2QIRe/Ic85BaGVX4Y1MwT3KJ9EiLQ96IEJSBjyAmE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MnrFyiJ3MdIt7mACB0Q+2eRvMHab4QohJgby1NlEGCz++4PzZHqGFeAxThiJuKJgDLTfdyYUN58Yut6JxAN/VesI/WaYuyHIAirvGsXy10Rpjl2kNgdJZaBe08SNX83tiQ8ddPa05V05C1il61pJ7zT9Xs3yFk+SyDk33w7sX9A= 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=OPM2+jI5; arc=none smtp.client-ip=209.85.210.174 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-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e0a37751cbso33305b3a.2 for ; Wed, 14 Feb 2024 09:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1707932447; x=1708537247; 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=HG1Z9345f9l/NkzG8Y/mlPsfRpv6azyFKs0IWGP/jfI=; b=OPM2+jI5a1lsGQN7mpklD9h+LInX4e/9Kti3Ophc6GHXLnrZIOULn5dEbwoQ+cnVSM /LsWpst9DYAO7/0u9Uz0o9wnwtFGILz9q0YRJvKVNfmG0Jl5aqKvirnRNa5OUWa8B1GP SR5yGTs9QKvKp5Js+L7mzTpFNSZ3eJxEAYSFdvIr+twcCP+Le1AT6LQx+UWbpQMZQAN8 SVPyITIlvaUcFzbyLV9AMY7dzZHIQCDVthQwfXelaRmMkwC95H+OG+sUTSbWpfiCu+ns CaITZlwXfkv6RMcdQ7UAgaKHQFCEHRhTs+xBtgga0XFo4XdmmTMdXRsIzUFjM1LfEOYj m/+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707932447; x=1708537247; 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=HG1Z9345f9l/NkzG8Y/mlPsfRpv6azyFKs0IWGP/jfI=; b=wCxja54g+TN//nsiIvjiKDIQmcFKovBDAN2WPmmw5mvVwLAK0FVdpNx4CNtfGmTCQ5 3gu4avKNhVC27K0GFsaik6VFMU5Vd/zLLzQLTo7zfwa0COWV8fODWGJW1pcgh40+TYXL n5iZ9N+uF8+4OSr+3QjApgzS3XQW1AzLY7Nn68mnj9V8HTE7xGoW7ClW+xk7RoN6RlMK KaIc2mh+Y0bovPV+FM7yZhRcDwo8GjhxRTw5vC0K6CuRnvSdozL8yGv1Whsy8WmpSaU4 9Boin65d58UwCqvfu1iDfF7FA65W6N/ttaFZ2bYzWdW9m79hTHlD6OgmGThia3lujWoI Ag5A== X-Forwarded-Encrypted: i=1; AJvYcCXuUk8gr0J9laWZLodOFxboDorEWXjSRXdJZloUXtfgfNn4eHy/IkGRlpk6c4GcwuuJJ7OxCaYxqKzPbPArOCyOSlVlR7ar+6bduqGY X-Gm-Message-State: AOJu0YyzzpPDdztnBf1WmnygLAIO9fOr+qSPZvJIY/FhHm/npsx9O63r 4ymYrZxSIKRsLrlhlMPyFc30naKNVXVORZFr7eDk2pithRDnh8el1YWnpY408w== X-Received: by 2002:a05:6a20:5a05:b0:19e:34ea:36ab with SMTP id jz5-20020a056a205a0500b0019e34ea36abmr2596022pzb.16.1707932446967; Wed, 14 Feb 2024 09:40:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXCVm9x2c70Y3aUaKd5dJ9CyzyMqThObPmrRdxYZr+tKeNMU1F1t+87B11jHOCr3NjPSIjrc8unAoIFwG9j0ZWYfOUjq8Y//B8Ho60+jtM9/uIvVF7wEczEsKXfEZdbu4k/Y9gDo56B4zs5WTz7e8HU/vqmCrH6Z6MWpoEhr0laUxGnMeEoblbsvak/hKw7m0PitxNEgtda/ZfHIx0dItrJ+KMd2YuYqP6+nIRaMrV0tkWBYd60QoHOrxAP1b91xYjlvSOiS+hrHyKD+87Vj1ixhRsn3cZeOHk/i5mZamezp2z0CE4R0OzfEWoHj2rf9Ebdhn1/cnVD7Y+EXw1jOIXyYLZaQiQ2HfJEXyp/cgEvJd9nuISq0xMvVvHjqsdlKV2SDcOmjp1mCfBjDHkRZLt2pQEMu/cQUcGGi9PpWFjBJ0N3u1KcM3kfAj3rOcfBr8ouBYBh3YG/6Dn+nmnZP3fQNVfkKmR6Ilx/c0SR4B7kSy7dcKwVlQwpXqUThPCp6ernnDjQJbXCLoZAo4D5a47aC5fgS7he5A8wX+LihWY1lh8= Received: from zhadum.home.kylehuey.com (c-76-126-33-191.hsd1.ca.comcast.net. [76.126.33.191]) by smtp.gmail.com with ESMTPSA id p5-20020aa78605000000b006e0874cbaefsm9567604pfn.27.2024.02.14.09.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:40:46 -0800 (PST) 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 , Song Liu , Mark Rutland , Alexander Shishkin , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Subject: [RESEND PATCH v5 3/4] perf/bpf: Allow a bpf program to suppress all sample side effects Date: Wed, 14 Feb 2024 09:39:34 -0800 Message-Id: <20240214173950.18570-4-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240214173950.18570-1-khuey@kylehuey.com> References: <20240214173950.18570-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 --- 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 = __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); if (*perf_event_fasync(event) && event->pending_kill) { event->pending_wakeup = 1; -- 2.34.1