From patchwork Thu Dec 7 16:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 175282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4906774vqy; Thu, 7 Dec 2023 08:35:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFbYDQBHctvgYbTL+WX91qjNWscsEcwAe1fZyiTlo0jEA+pSu7nHbrh2kSHL0LqDQhQRJZ X-Received: by 2002:a17:902:d212:b0:1d0:6ffd:e2b4 with SMTP id t18-20020a170902d21200b001d06ffde2b4mr2480483ply.78.1701966958269; Thu, 07 Dec 2023 08:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701966958; cv=none; d=google.com; s=arc-20160816; b=VdIXrtvh50QsJlPQHl6s+aKwl3Z87af4ByWvK4dybYEpEHRPEY9ccv+G3QUOVe9lg3 hPT/unJZmN8GcRAcpGKmsikSpuBQ23xdNl2I3fW9Wo9YR4VsekQEWRCz1YAhN2kUiUrB T+vibxzjcNpB0nWDin3dI9Y59MSXCV22VQ7P3/BUX+QVf3L+wBQx+SRy4VjV3xOLBWWm qok8nvyCcufXEx25AJvnzjFlBawJ65ZgyXsvIrdgnQ6uv11TK5WWFA5Rh5BRvhPh+p1N bNw625SEd/dEFrQ+XT7Ms01eLVBFw+jJF30ZHEl0g1AJr+j2jflqPRq/iES3fur50mNc L/AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dWj1IWQKQUAn53hJd+8gzkbOyC7Uc3/+Xnz5vVEOJAM=; fh=TgNdCu0nkwWF6I0gv1FaAZU9nxNhZAbxhuG8wY4k0B8=; b=Hvm5AuoVcYaPMX4jI07DWwJqiw08CcncOM6rYRiTaiv3IInIjiUJj+NYI8Jyl2a0Pb oEjJ7S97cQ7ZcT/zK7cbWF05Sk4ey4xH48djQkC6ae5+1qUjUTt7StSBore2A1dtwclz lwbRjacrVcC50T6lBd/LZoUd17CtsxB61T5ykolQ+rSSDnqoNKYUpZEa9lhwPvOsakOm ExXyHj8KfztCtaYHfm/F6Pik4wZiNXGQpmR4ssXTKT6yegHQkASE4NmgKtLDofjUvTGn nDcPORtlLuFtwOmhMwMDge2T61k4izRdN+pNwhhmkL9xxpz/K8cQy0TG3ukable042V/ QCGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=VVwDBW55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c12-20020a63d50c000000b005c677a35324si1444906pgg.464.2023.12.07.08.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 08:35:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=VVwDBW55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9977E80A07F1; Thu, 7 Dec 2023 08:35:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233010AbjLGQfN (ORCPT + 99 others); Thu, 7 Dec 2023 11:35:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbjLGQfI (ORCPT ); Thu, 7 Dec 2023 11:35:08 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D849312D for ; Thu, 7 Dec 2023 08:35:14 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d0538d9bbcso9409055ad.3 for ; Thu, 07 Dec 2023 08:35:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1701966914; x=1702571714; 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=dWj1IWQKQUAn53hJd+8gzkbOyC7Uc3/+Xnz5vVEOJAM=; b=VVwDBW55m0+CDPNtEo5vhp4IUC/kBBuTg9UYkGBv86g2h2uAjCqobJRyhnpOQVvSbG qATy2zfqJ6o4+Kkj5+W9rp2Rdv2C7Hsx86tKWmsJTlH3we8umq9P5y+/kqoQn8xTMFSS 3TSpknLzz1YrQRWyRl7xdHsCusaNWCrP+5IfhGReajs7G54gnc+u+TaBrmUz0vlTH08O iUec9Ff9BoKUu3RpIG1XVYA7Fns4e0RAKZB9lk2TWN1yOssf/JchcpWxGguZj1Vo+9Xl l1bYLVMtDf5CSkPUtmEsqBWmkLfP47Q6G8AEaXrhQJieSN0+JyOiNTYU5JmQs8r9nBwQ ffpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701966914; x=1702571714; 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=dWj1IWQKQUAn53hJd+8gzkbOyC7Uc3/+Xnz5vVEOJAM=; b=n+D8snVCZTvVDKLDAveraub5/vuSq23seTmb/6KMfpb1fCCRs+HOcgcT62jyPQocDV MDiVEkKa/m5UCpQwJEmxXFbehbKKoHDVquddrYsSTG+mC3QdzomyNpIAUnhmPe8+DzJH xA09QPH+FWpBsoeH05S0cTfOUlW3NZVEY3FDoCIF7ENYRp2O5byJcLUm/NSYnJ0a4cVw p1zBPbqUaDFjOcszW5gDHbpxdEl4XVM4Fufkq6lA/shOBe9Fz49ta2zwVURvJsu9GrUb mtwlk5rGJpf0JRK0IrIGQLwveksJURSuMLQTk+67pS/pgg51w6zUQZHKi0qrLHCZoT5P exeQ== X-Gm-Message-State: AOJu0Yxmhbsiyn+6DoZQimQAOC4nNk+yUpdGGtnNDt+IdiBYHLeelrMT ywny5G41D4n9i+0QwjM3ZSe6SQ== X-Received: by 2002:a17:902:b48d:b0:1d0:6ffd:e2ef with SMTP id y13-20020a170902b48d00b001d06ffde2efmr2666645plr.137.1701966914046; Thu, 07 Dec 2023 08:35:14 -0800 (PST) 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 iw15-20020a170903044f00b001d1cd7e4acfsm6143plb.201.2023.12.07.08.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 08:35:13 -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 Cc: 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 Subject: [PATCH v2 2/3] perf/bpf: Allow a bpf program to suppress all sample side effects. Date: Thu, 7 Dec 2023 08:34:57 -0800 Message-Id: <20231207163458.5554-3-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231207163458.5554-1-khuey@kylehuey.com> References: <20231207163458.5554-1-khuey@kylehuey.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 08:35:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784641705289973812 X-GMAIL-MSGID: 1784641705289973812 Returning zero from a bpf program attached to a perf event already suppresses any data output. By clearing pending_kill, returning zero from a bpf program will effectively pretend the sample never happened for all userspace purposes. Signed-off-by: Kyle Huey Acked-by: Andrii Nakryiko --- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 19fddfc27a4a..6cda05a4969d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10421,8 +10421,10 @@ static void bpf_overflow_handler(struct perf_event *event, rcu_read_unlock(); out: __this_cpu_dec(bpf_prog_active); - if (!ret) + if (!ret) { + event->pending_kill = 0; return; + } event->orig_overflow_handler(event, data, regs); }