Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp474492rdb; Tue, 5 Dec 2023 10:17:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSwb2ShGWwhaBKl40k85A3HWBVBSv35nVRetOnwZWWY49kCZmRCL2iTybFUNA7IjRseKpr X-Received: by 2002:a05:6a20:e595:b0:18f:97c:8259 with SMTP id ng21-20020a056a20e59500b0018f097c8259mr3316481pzb.99.1701800251891; Tue, 05 Dec 2023 10:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701800251; cv=none; d=google.com; s=arc-20160816; b=ve0mGnFhXnJFTIPP/6l9989IRKq4WznfOviPARGXWwdwdHafKhwO6Lypg5qpLkZ9P8 gXVa9bItJwQ75cEtq8HrbU/pliNxnp6gfdBC5h8p77rUySkzzk3hDyLYN2nFiUt8F94r uAtI+uahZoabKxci0l1hYtbNGaNxqLBLPvnCpKwVQbtsT4PxcWl+TNC6BrKGQYErHcAq R/p8vP9tl3L0eye3IHaNwU8Uw2Jxv9KEbA9tri7H6PF2jqSqeP2KbjCCt6lUXnANF36w d/ZPDUUcH4aN5M2PSa9B//bdABw6AJofyQe0Y7trGOWQpDvXMOSIBhOgWYFx2CAGapSq MpHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=rDi8w67oLrCVnWUnDYFdDwzLTH62p8zVTFKrJGR7vTA=; fh=QZInXtC7bksl1WxpDUx0PilReqE2ZYrNgtIVUjn/+9c=; b=UGXkRBR32I3yjin0mQ2yDSylKqT2NJRuTmNrveHD8kDm9oD1EJSOlNlosSTcj9JfO2 2Aa2B/V+mpnuDnMsixVI8rZaszUc1HWxbh97arT64NrzF3g+rb0GbRnG3Rw4kRob8+JO DyDSlQJE0eMY0T2l7EGOKxjou/zS4BWRTCjyLdh1Pvc6LwcmvGtGritA1Jz9fFGUWLbK X+BW6cgpkzSDjtkusUMIh85yfC/sLr86pNjZc2posCI9sfSNDvwiUzykJDJNZbBNHmZf V8yveIldYxrHhOdTI+jfQNnQbvzd6F9ozVrkLcNXM5cztyxpZ+CpK0RR0CCE6J6nbbg/ Md2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=T5zedPar; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r199-20020a632bd0000000b005c14fc66cc1si9603782pgr.22.2023.12.05.10.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:17:31 -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=@google.com header.s=20230601 header.b=T5zedPar; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6F60F80A3120; Tue, 5 Dec 2023 10:17:29 -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 S235635AbjLESRM (ORCPT + 99 others); Tue, 5 Dec 2023 13:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbjLESRL (ORCPT ); Tue, 5 Dec 2023 13:17:11 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CBC690 for ; Tue, 5 Dec 2023 10:17:17 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b83c4c5aefso3360110b6e.1 for ; Tue, 05 Dec 2023 10:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701800237; x=1702405037; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rDi8w67oLrCVnWUnDYFdDwzLTH62p8zVTFKrJGR7vTA=; b=T5zedPartWcsSubHoFT0v9EkdqfSoBTx4JJjvCaW6LJyr1VJGToiDW5yiki1CiuIqk rp+3A3RN+mULd1/avj0jZ/h9a31Ekl2Jnd1SRladgxSe6eMJHqc757INfvoj4WcYK47H fIcoSBSrNlTpVInIYRwpQ+NJQwTXyHltRdJ60EScLgGPYQ+gL8DKAYZUl9qanLJ1gR86 eHywPwoOCGh3ncpyH7/SBS7xSkVSqRjfrWQoyxnKGq8OJhZr6K/W4uWysims260yfa+h tocvC57EMWZoIYxaPqGXq5eQQkKU3HvaDcZ9+S6BLjiwBHj1NzFHXAmKOILZ4jwz9kmk CvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701800237; x=1702405037; 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=rDi8w67oLrCVnWUnDYFdDwzLTH62p8zVTFKrJGR7vTA=; b=hjo3++6KvwPgBK0c1FZ8nT+hE455ZWmWGQ0vSHkjsN7400UUCdTmA01IQ+o+wtVtDk z0erb5SvNP+Y3+uC3hebFpdg7f98C2m4CjKFkmPz04rWWvTGwLWYzCmQ2PyUAtrSx2TV gp4Psk7j3HrHgxfHENr6njIJLtOeMJ1h8udQgq3O8VPYIT/C4u0Z/pKZcsUm/2qzRu53 enjU/F1trxpjKiLl8R23+zlHn2kUopo3dd71oXETZmFxWE1VjpBgO4plnVja97Ok2UKt S85qMMqg4pDSesZgRMUqzmZFspUKVoQ9hz3peUwZPilYl3L//rpfpcrrB6npb44csJoq 3Vsw== X-Gm-Message-State: AOJu0YzUO/GQ0JLV06t2xjwyOB1V0/frMKsJmrO39R/jwDIt0LhmpF4t FwZKkGOQs1FJo0ot4llUhggb9m99OCWCVB6HWHQ3Bw== X-Received: by 2002:a05:6870:9d9b:b0:1fa:1355:da45 with SMTP id pv27-20020a0568709d9b00b001fa1355da45mr7508586oab.11.1701800236823; Tue, 05 Dec 2023 10:17:16 -0800 (PST) MIME-Version: 1.0 References: <20231204201406.341074-1-khuey@kylehuey.com> <20231204201406.341074-2-khuey@kylehuey.com> In-Reply-To: From: Marco Elver Date: Tue, 5 Dec 2023 19:16:38 +0100 Message-ID: Subject: Re: [PATCH 1/2] perf/bpf: Allow a bpf program to suppress I/O signals. To: Namhyung Kim Cc: Jiri Olsa , Andrii Nakryiko , Kyle Huey , Kyle Huey , linux-kernel@vger.kernel.org, "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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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]); Tue, 05 Dec 2023 10:17:29 -0800 (PST) On Tue, 5 Dec 2023 at 19:07, Namhyung Kim wrote: > > Hello, > > Add Marco Elver to CC. > > On Tue, Dec 5, 2023 at 3:16=E2=80=AFAM Jiri Olsa wro= te: > > > > On Mon, Dec 04, 2023 at 02:18:49PM -0800, Andrii Nakryiko wrote: > > > On Mon, Dec 4, 2023 at 12:14=E2=80=AFPM Kyle Huey w= rote: > > > > > > > > Returning zero from a bpf program attached to a perf event already > > > > suppresses any data output. This allows it to suppress I/O availabi= lity > > > > signals too. > > > > > > make sense, just one question below > > > > > > > > > > > Signed-off-by: Kyle Huey > > > > Acked-by: Jiri Olsa > > > > > > --- > > > > 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 pe= rf_event *event, > > > > rcu_read_unlock(); > > > > out: > > > > __this_cpu_dec(bpf_prog_active); > > > > - if (!ret) > > > > + if (!ret) { > > > > + event->pending_kill =3D 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