Message ID | 20231204201406.341074-2-khuey@kylehuey.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3016265vqy; Mon, 4 Dec 2023 12:20:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkyvlfo5AP0LrgXiYIeZr2FiBPpDqSIM6gCIExO6g+UeDiycJwJmvDYh5pSYZwooiNOFsK X-Received: by 2002:a17:902:e88b:b0:1d0:83b5:c7ca with SMTP id w11-20020a170902e88b00b001d083b5c7camr2581349plg.32.1701721226526; Mon, 04 Dec 2023 12:20:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701721226; cv=none; d=google.com; s=arc-20160816; b=fdQHwrLr6haVa4TCZfXg7Dm/jzFXSIRasKAqoFwLdb5YZBPkmUBfXjUihIOm327why 2Q1rmBXGtYHlCyNw0Ld0MDBL9v5MYAzrHQa+t6nRz5LiDzR2ZCtH6OFER/4R1KeMEDof uXKUXFjOdkCktHUVDyeQX1+KRsYOVOEQrDESqM64RO4LN0hqKQ862gQdFvRnwPNlEa3w tPVAUjZVsaSFUQmExjJ/GrRym9kvYUs/Vq5J+CRjp7Xia2ts+yRw3BXXfXOI38sVebkn ALP4UdRD7RGQ+ftnfq8KnxhKRVwMisi4G2GRc7dJyxl1BEq75Jr52FdcBqJcTxDCYyMD 9L4g== 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=6c7W+Z0n44cx31K9z6TknZvQ8WpPWuGgMuK2rK3kYgI=; fh=ai81BKRgbVMbZ883XpQGwU8gim2sHdAWhG2zuYJfI1o=; b=It22o4w2r48sycRZADvX6XyBMwiV6f72MfHqI6eFDmUBV0M3mzQzNYYM8uiLHPN+SK AH912ePoRcbmpJCTraPky+q5LsmS2LOzNLwO9RZR7W7V6BBCoGJ1SpyGtPPFcMUn32im vLqU/GnHXjtwKUv+rPMLuh6qNUurPhDJj8dGYdxsWmpQq2WP/CfIVWzLhJF+w9c3C9DG NaHfPKNGTWfbq/8T6MRTWEn5ybFNZMBIbeycpnMKw4Gjbv+rg+YeF2uZXtulgUnBe71q EqWww1Rdg5YI9Z6NyBtrgC+ZzdV0xgpygU9//SkZ8oZX1E9vgMMlufzssl4AOQtlWBPu 5vSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=k1eHOOIj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a2-20020a170902ecc200b001c59b6ed118si8279537plh.157.2023.12.04.12.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b=k1eHOOIj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 910F38057955; Mon, 4 Dec 2023 12:14:44 -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 S233635AbjLDUOU (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 15:14:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjLDUOT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 15:14:19 -0500 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D636D3 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 12:14:25 -0800 (PST) Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-58e1ddc68b2so2000997eaf.2 for <linux-kernel@vger.kernel.org>; Mon, 04 Dec 2023 12:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1701720865; x=1702325665; 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=6c7W+Z0n44cx31K9z6TknZvQ8WpPWuGgMuK2rK3kYgI=; b=k1eHOOIjZWC+jz6H4eR7N1oP4jhctprLaO+KIUwjlmlkiW7c0V7YZ6v+8vvTxr2EwE rxcZCCbSwXtjG4jfE8Uf2CnCgieuULs0EO3NpvVuk6txOJKidgJqbk7lFfKOWC9dDdQ9 k09hV2lQyDPTzDKG7iVSEwTpNbHVIDtV09U6BfIszxtybx+fhNiL7IjWoQSDDFkA1/pW IiabBMclV/iwW41PR9S8vz1KyzXgCZlyaAPHnK0d846aoMlVFhgV7pOT/9tB3UEJRpb7 ItOl2w5LmspBJc/rKJbsrh+dD90S9LeYZ5qmRF/i19hGu0uMybS16/wy0Ct5giulVX9Q JyDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701720865; x=1702325665; 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=6c7W+Z0n44cx31K9z6TknZvQ8WpPWuGgMuK2rK3kYgI=; b=DG7agyKtjoE/WW2R6lNlJ0/x0JLHbrlAbM1l1t3Oi2SL5xqHzlljZO2y51TqXpnLFY CLnAcssB0X0ZX+jnAhE4lWy1sjyQSlRGwNybysmIQzFPo79+4DnUu7khn/k2BuitjhKs YVYYopDFaz0vT1ko/UlcMrgoBfGOJ1KXRUhxjj6hompDjZoNV7AGvcsLDRraKCDKSzba XMcNN+9L9xrXSf0+c68cGlZB+Lc+A9lVxwY4OqeinDj+D7s2XPRADr9+DFqkftgE17GE UBK3a1hjBlx1Ryt5Gch4x12HLG01odH7Fhkm+Z93a3uK7mPn2MSNOTDjsXzbpCizHD2c CrNg== X-Gm-Message-State: AOJu0YxD/Z+Ie2sUhUqGvTQIIvNO7I3/Em/ry9Xw6DV9hXy/4AmuP6iW qXyNFlNwHqHJYq/8srBBi3opvg== X-Received: by 2002:a05:6358:5208:b0:170:40b1:88ac with SMTP id b8-20020a056358520800b0017040b188acmr992899rwa.65.1701720864819; Mon, 04 Dec 2023 12:14:24 -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 n7-20020a63f807000000b005b529d633b7sm7894060pgh.14.2023.12.04.12.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:14:24 -0800 (PST) From: Kyle Huey <me@kylehuey.com> X-Google-Original-From: Kyle Huey <khuey@kylehuey.com> To: Kyle Huey <khuey@kylehuey.com>, linux-kernel@vger.kernel.org Cc: Robert O'Callahan <robert@ocallahan.org>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 1/2] perf/bpf: Allow a bpf program to suppress I/O signals. Date: Mon, 4 Dec 2023 12:14:05 -0800 Message-Id: <20231204201406.341074-2-khuey@kylehuey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204201406.341074-1-khuey@kylehuey.com> References: <20231204201406.341074-1-khuey@kylehuey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> 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]); Mon, 04 Dec 2023 12:14:44 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784384036582082495 X-GMAIL-MSGID: 1784384036582082495 |
Series |
Combine perf and bpf for fast eval of hw breakpoint conditions
|
|
Commit Message
Kyle Huey
Dec. 4, 2023, 8:14 p.m. UTC
Returning zero from a bpf program attached to a perf event already
suppresses any data output. This allows it to suppress I/O availability
signals too.
Signed-off-by: Kyle Huey <khuey@kylehuey.com>
---
kernel/events/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > Returning zero from a bpf program attached to a perf event already > suppresses any data output. This allows it to suppress I/O availability > signals too. make sense, just one question below > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> > --- > 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 b704d83a28b2..34d7b19d45eb 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -10417,8 +10417,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; > + } What's the distinction between event->pending_kill and event->pending_wakeup? Should we do something about pending_wakeup? Asking out of complete ignorance of all these perf specifics. > > event->orig_overflow_handler(event, data, regs); > } > -- > 2.34.1 > >
On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > > > Returning zero from a bpf program attached to a perf event already > > suppresses any data output. This allows it to suppress I/O availability > > signals too. > > make sense, just one question below > > > > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> Acked-by: Jiri Olsa <jolsa@kernel.org> > > --- > > 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 b704d83a28b2..34d7b19d45eb 100644 > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -10417,8 +10417,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; > > + } > > What's the distinction between event->pending_kill and > event->pending_wakeup? Should we do something about pending_wakeup? > Asking out of complete ignorance of all these perf specifics. > I think zeroing pending_kill is enough.. when it's set the perf code sets pending_wakeup to call perf_event_wakeup in irq code that wakes up event's ring buffer readers and sends sigio if pending_kill is set jirka > > > > > event->orig_overflow_handler(event, data, regs); > > } > > -- > > 2.34.1 > > > >
Hello, Add Marco Elver to CC. On Tue, Dec 5, 2023 at 3:16 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > > On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > > > > > Returning zero from a bpf program attached to a perf event already > > > suppresses any data output. This allows it to suppress I/O availability > > > signals too. > > > > make sense, just one question below > > > > > > > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> > > Acked-by: Jiri Olsa <jolsa@kernel.org> > > > > --- > > > 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 b704d83a28b2..34d7b19d45eb 100644 > > > --- a/kernel/events/core.c > > > +++ b/kernel/events/core.c > > > @@ -10417,8 +10417,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; > > > + } > > > > What's the distinction between event->pending_kill and > > event->pending_wakeup? Should we do something about pending_wakeup? > > Asking out of complete ignorance of all these perf specifics. > > > > I think zeroing pending_kill is enough.. when it's set the perf code > sets pending_wakeup to call perf_event_wakeup in irq code that wakes > up event's ring buffer readers and sends sigio if pending_kill is set Right, IIUC pending_wakeup is set by the ring buffer code when a task is waiting for events and it gets enough events (watermark). So I think it's good for ring buffer to manage the pending_wakeup. And pending_kill is set when a task wants a signal delivery even without getting enough events. Clearing pending_kill looks ok to suppress normal signals but I'm not sure if it's ok for SIGTRAP. If we want to handle returning 0 from bpf as if the event didn't happen, I think SIGTRAP and event_limit logic should be done after the overflow handler depending on pending_kill or something. Thanks, Namhyung
On Tue, 5 Dec 2023 at 19:07, Namhyung Kim <namhyung@kernel.org> wrote: > > Hello, > > Add Marco Elver to CC. > > On Tue, Dec 5, 2023 at 3:16 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > > > On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > > > On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > > > > > > > Returning zero from a bpf program attached to a perf event already > > > > suppresses any data output. This allows it to suppress I/O availability > > > > signals too. > > > > > > make sense, just one question below > > > > > > > > > > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> > > > > Acked-by: Jiri Olsa <jolsa@kernel.org> > > > > > > --- > > > > 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 b704d83a28b2..34d7b19d45eb 100644 > > > > --- a/kernel/events/core.c > > > > +++ b/kernel/events/core.c > > > > @@ -10417,8 +10417,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; > > > > + } > > > > > > What's the distinction between event->pending_kill and > > > event->pending_wakeup? Should we do something about pending_wakeup? > > > Asking out of complete ignorance of all these perf specifics. > > > > > > > I think zeroing pending_kill is enough.. when it's set the perf code > > sets pending_wakeup to call perf_event_wakeup in irq code that wakes > > up event's ring buffer readers and sends sigio if pending_kill is set > > Right, IIUC pending_wakeup is set by the ring buffer code when > a task is waiting for events and it gets enough events (watermark). > So I think it's good for ring buffer to manage the pending_wakeup. > > And pending_kill is set when a task wants a signal delivery even > without getting enough events. Clearing pending_kill looks ok > to suppress normal signals but I'm not sure if it's ok for SIGTRAP. > > If we want to handle returning 0 from bpf as if the event didn't > happen, I think SIGTRAP and event_limit logic should be done > after the overflow handler depending on pending_kill or something. I'm not sure which kernel version this is for, but in recent kernels, the SIGTRAP logic was changed to no longer "abuse" event_limit, and uses its own "pending_sigtrap" + "pending_work" (on reschedule transitions). Thanks, -- Marco
On Tue, Dec 5, 2023 at 10:17 AM Marco Elver <elver@google.com> wrote: > > On Tue, 5 Dec 2023 at 19:07, Namhyung Kim <namhyung@kernel.org> wrote: > > > > Hello, > > > > Add Marco Elver to CC. > > > > On Tue, Dec 5, 2023 at 3:16 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > > > > > On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > > > > On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > > > > > > > > > Returning zero from a bpf program attached to a perf event already > > > > > suppresses any data output. This allows it to suppress I/O availability > > > > > signals too. > > > > > > > > make sense, just one question below > > > > > > > > > > > > > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> > > > > > > Acked-by: Jiri Olsa <jolsa@kernel.org> > > > > > > > > --- > > > > > 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 b704d83a28b2..34d7b19d45eb 100644 > > > > > --- a/kernel/events/core.c > > > > > +++ b/kernel/events/core.c > > > > > @@ -10417,8 +10417,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; > > > > > + } > > > > > > > > What's the distinction between event->pending_kill and > > > > event->pending_wakeup? Should we do something about pending_wakeup? > > > > Asking out of complete ignorance of all these perf specifics. > > > > > > > > > > I think zeroing pending_kill is enough.. when it's set the perf code > > > sets pending_wakeup to call perf_event_wakeup in irq code that wakes > > > up event's ring buffer readers and sends sigio if pending_kill is set > > > > Right, IIUC pending_wakeup is set by the ring buffer code when > > a task is waiting for events and it gets enough events (watermark). > > So I think it's good for ring buffer to manage the pending_wakeup. > > > > And pending_kill is set when a task wants a signal delivery even > > without getting enough events. Clearing pending_kill looks ok > > to suppress normal signals but I'm not sure if it's ok for SIGTRAP. > > > > If we want to handle returning 0 from bpf as if the event didn't > > happen, I think SIGTRAP and event_limit logic should be done > > after the overflow handler depending on pending_kill or something. > > I'm not sure which kernel version this is for, but in recent kernels, > the SIGTRAP logic was changed to no longer "abuse" event_limit, and > uses its own "pending_sigtrap" + "pending_work" (on reschedule > transitions). > > Thanks, > -- Marco The patch was prepared against a 6.7 release candidate. - Kyle
On Tue, Dec 5, 2023 at 10:17 AM Marco Elver <elver@google.com> wrote: > > On Tue, 5 Dec 2023 at 19:07, Namhyung Kim <namhyung@kernel.org> wrote: > > If we want to handle returning 0 from bpf as if the event didn't > > happen, I think SIGTRAP and event_limit logic should be done > > after the overflow handler depending on pending_kill or something. > > I'm not sure which kernel version this is for, but in recent kernels, > the SIGTRAP logic was changed to no longer "abuse" event_limit, and > uses its own "pending_sigtrap" + "pending_work" (on reschedule > transitions). Oh, I didn't mean SIGTRAP and event_limit together. Maybe they have an issue separately. Thanks, Namhyung
On Tue, Dec 5, 2023 at 10:07 AM Namhyung Kim <namhyung@kernel.org> wrote: > > Hello, > > Add Marco Elver to CC. > > On Tue, Dec 5, 2023 at 3:16 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > > > On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > > > On Mon, Dec 4, 2023 at 12:14 PM Kyle Huey <me@kylehuey.com> wrote: > > > > > > > > Returning zero from a bpf program attached to a perf event already > > > > suppresses any data output. This allows it to suppress I/O availability > > > > signals too. > > > > > > make sense, just one question below > > > > > > > > > > > Signed-off-by: Kyle Huey <khuey@kylehuey.com> > > > > Acked-by: Jiri Olsa <jolsa@kernel.org> > > > > > > --- > > > > 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 b704d83a28b2..34d7b19d45eb 100644 > > > > --- a/kernel/events/core.c > > > > +++ b/kernel/events/core.c > > > > @@ -10417,8 +10417,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; > > > > + } > > > > > > What's the distinction between event->pending_kill and > > > event->pending_wakeup? Should we do something about pending_wakeup? > > > Asking out of complete ignorance of all these perf specifics. > > > > > > > I think zeroing pending_kill is enough.. when it's set the perf code > > sets pending_wakeup to call perf_event_wakeup in irq code that wakes > > up event's ring buffer readers and sends sigio if pending_kill is set > > Right, IIUC pending_wakeup is set by the ring buffer code when > a task is waiting for events and it gets enough events (watermark). > So I think it's good for ring buffer to manage the pending_wakeup. > > And pending_kill is set when a task wants a signal delivery even > without getting enough events. Clearing pending_kill looks ok > to suppress normal signals but I'm not sure if it's ok for SIGTRAP. > > If we want to handle returning 0 from bpf as if the event didn't > happen, I think SIGTRAP and event_limit logic should be done > after the overflow handler depending on pending_kill or something. Hmm, yes, perhaps. The SIGTRAP thing (which I was previously unaware of) would actually be more useful to us than an I/O signal. I am slightly wary that event_limit appears to have no tests in the kernel tree. - Kyle > Thanks, > Namhyung
diff --git a/kernel/events/core.c b/kernel/events/core.c index b704d83a28b2..34d7b19d45eb 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10417,8 +10417,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); }