Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp786620rdb; Thu, 18 Jan 2024 21:14:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IExoY4zor7hmUVNSiQ/J03b3ic4BtPxgs/0+Dujfd8nOVgRwis9fZFfv/q78SVWi/taObvO X-Received: by 2002:a0c:9a99:0:b0:681:7bab:be38 with SMTP id y25-20020a0c9a99000000b006817babbe38mr1629017qvd.13.1705641296344; Thu, 18 Jan 2024 21:14:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705641296; cv=pass; d=google.com; s=arc-20160816; b=zm68YSzmRfDkSgoOCWo/mkr+8/VWvvCOADUM97hQQb5MxzdZXVUbAHkOkUXvZcxwZk yUVVb1N28T6gwJXsHxX6Aiuc3QV3g3OeVuof5heZYzgzbvJtNf8GVzUmSQ64kLKbQ+e9 jJUIZtegiSROZEQVVx4b5KQO7K1FjcRJEruoni1FuNGXLq4zAgnemtjzrPwbuIkaGe51 9zMItyJP9uzWbwXwmBACzK7sZ4IxTxZQrijfSUBgu5SZkEBEoowzFITRoOphGRQHVeMc 1Ui3yvF7yJgP6b4TRJ2HIrNeU8XzKe0gxvmeg/O23Qpy2BgCPKFFWlY6kgVGpKZK4Ory krkQ== 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; bh=Heknx9B9Mq2DzjyZ9n1MXLrOGgOlHXA+fVx4XEJEn/0=; fh=d/CPh2GnG73MdhBy+oLllW0Jjs27ONLgxHBrCrmLn1E=; b=iVG6CxU34r7jbDsz/miprz4idVLBr/P4RVFGBWdpYOKIgrJylLeFy5lysSofrJ907z BsXyaVQtFc4MuaxKlWD5Hcdtbi2vKwoJjamoEz8KjNJkI9dxxQ3JhKJm8lEHaG+pftL/ GbHooWut+Pohzv2MGRC+F/c/uHn8x/K2gEWUTaynrRxsWm950HK0dPEOEKDV+ITkOhJb KGE4sqB7cpEAIBOqlZBHr/FiQpS3DTKK8dqZXvboUfuEeK8RRavIXAldbbZk6cNYQXst AD9wSX7O02841BBJtZnf2pkl4ZXvOUFT5YEqa3WeWxwBGBo5O3aDpwCSqB90aTQdSNwc EO9w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 b29-20020a0cb3dd000000b00680f6edff7dsi15996852qvf.357.2024.01.18.21.14.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 21:14:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30769-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; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-30769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 1E3F81C22AAE for ; Fri, 19 Jan 2024 05:14:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA3126FAF; Fri, 19 Jan 2024 05:14:41 +0000 (UTC) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 28DEA63DF; Fri, 19 Jan 2024 05:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705641281; cv=none; b=tRnEaAWmuF7F3YW9SJKIRkarQ2+VPt5iMKWSItl2beUTCD3iVPmmRSOeFufwFGocKWbpU5LQEMEq2PX/Dr1jQ7lsPUbIwANK/ohKkIPVAf5piiUVzrUYQ7YKAavkjXGhTzav0aE3HZ5eK02Af0MfUBmiswsTzwQeWBXNkmol8vY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705641281; c=relaxed/simple; bh=gxSzQTf6jmvbBw8nozGpd8UPCbitPnoQAkYe8hXwxzU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=j6FNoxrUUQyEDi8bPmDJzVglTei79cUkAbGIjnWO3AKtjFfNRFORcK3J27btLp0dSiS53CBrNxQrYTHQdqjJLYubsq67P7e3UlWH66+ThiggV1Mv0l+UtII9wT5fRgElFZqvvQBBaFnb/yLzptyG6Lna6ujvWv+rj3pEpFC++20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2904d8c29d2so107402a91.2; Thu, 18 Jan 2024 21:14:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705641279; x=1706246079; 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=Heknx9B9Mq2DzjyZ9n1MXLrOGgOlHXA+fVx4XEJEn/0=; b=CYbMyxcmXowrS52QWvD/8JevCnO7/i+Pbkz/42BPI+wM6YehzfX9dGmjK6y8HCCP6W QG9ztqDB5lpqBHjz7UZJl+fIHLGLmTx3viNV0KrDRxmA55FlAicvG1aA5j2msJdztPH5 4kK+YYiamk1cmkh2u6aqcKkHKC6q6d0kpo5vpNssviA8Szq28gCjLhB+Rq656W/kW5yy SfFZdTDZSyzZKnXaLGQHgM+TsX4/84O2Da2YqqdOegFc7meNAYWpAU48Bo9xRgxS2jzd Oyhc4ee1yfanyEnuqr0rurE0Wz6ZASD4tsrfcsHuaGnT/z5eDBnfTfkcyFPwKss6ihjE Ie/A== X-Gm-Message-State: AOJu0Yx5mBax5oksczVgQbVE0rSCb2AzoBpY1zSec5RJZm6P62FvUdxH BCIdoH29b9UBIafnwSwYMf//PzRo+BOerwy/E8sxHgsAzhJD84m/sMKpL0Cc1FtRLsSbSmCAV1+ 6xz2o4VWf79jS5kfruZJUskhdg7A= X-Received: by 2002:a17:90a:242:b0:28e:79cf:f1f1 with SMTP id t2-20020a17090a024200b0028e79cff1f1mr1562868pje.80.1705641279389; Thu, 18 Jan 2024 21:14:39 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240119001352.9396-1-khuey@kylehuey.com> <20240119001352.9396-4-khuey@kylehuey.com> In-Reply-To: <20240119001352.9396-4-khuey@kylehuey.com> From: Namhyung Kim Date: Thu, 18 Jan 2024 21:14:27 -0800 Message-ID: Subject: Re: [PATCH v4 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, Andrii Nakryiko , Jiri Olsa , Marco Elver , Yonghong Song , Song Liu , "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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, On Thu, Jan 18, 2024 at 4:14=E2=80=AFPM 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: Namhyung Kim Thanks, Namhyung > --- > 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); > > if (*perf_event_fasync(event) && event->pending_kill) { > event->pending_wakeup =3D 1; > -- > 2.34.1 >