Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp478454rdb; Tue, 5 Dec 2023 10:23:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfPMQO5oE18E2eMVSqJchg651fxKZflCP0HMR2l2wKdnTBaQUmGxkEczBtFms5TIFdzLtz X-Received: by 2002:a05:6a21:788b:b0:18b:d823:5362 with SMTP id bf11-20020a056a21788b00b0018bd8235362mr3914153pzc.48.1701800637116; Tue, 05 Dec 2023 10:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701800637; cv=none; d=google.com; s=arc-20160816; b=IY5T4idKxB0lhG2oehBn7UPN5kIpK9uMgBXfAncjKtzL/f0AEbNlP/CvDxTkvVvWnZ nJoRgErW/bWjjrwkDAvUwT4DXca5CcwOh35IgG6u3GioZd0fddVrPYgFUd65l+HblBO7 PE6xWmeektwXb8p/WsAunUliPVloAgBIy9kuzJn7BgV1krM6Sjl0HwcsG9XwTnC6R9DD 4HKrCLQi2DzB7tZ9Tio7TFUPR3La7reIJcSWvoPIiWyPgwW5cfRrnma00VspgkjN+A6s DNABe0SLv3zYgZ+LtjQHLU8AZDTynJX3Bb76NJuW5D8TXHnAil47x9BBGRjP5hSy9b+G fG6g== 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=v+0YlV3bBjMI57c/U4EB7oIqdJ8ldlbudM2aWbhqhfU=; fh=JSraC/ItrSAbERFIvNhSCQ85mEu71uquus1TP6FeuUM=; b=vxkHqtJnltMcVrXzpxILOK5MAJIEqjFJHdrwd6tuU7RiYVBqA1zF2O/5kipzSWQdzT J/v1Y1YFFlzn/mfM38xxS42w5hP0E78FS6k9ryDlH1nt7pUe1qE9RHURoh56QNVzcuVy EbJW6Lj883ikfbranAOPS4EijUx3G/cdSFl4yb1VPPJWn21Ak4rh3wlYbfX/KMoTHiNp kc+2D2x/ZKYKtwHlvETFN6pMvBSgbch9cAtqtZ0+sIzhgjUOAwn3qOYpaM2VVQ4MDbTY CSIcrJFtY4GtvlEuaaYVq58QjQZD+qtlF75aWipff8bAdtHDFFRn5qMJWJPEDCJ0Inw4 PzBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kylehuey.com header.s=google header.b="OwGcd7y/"; 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b006c98123e8acsi10064133pfl.24.2023.12.05.10.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:23:57 -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="OwGcd7y/"; 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 241428041FDF; Tue, 5 Dec 2023 10:23:54 -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 S1345907AbjLESXi (ORCPT + 99 others); Tue, 5 Dec 2023 13:23:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235647AbjLESXi (ORCPT ); Tue, 5 Dec 2023 13:23:38 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D580D1BE for ; Tue, 5 Dec 2023 10:23:43 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a1a0bc1e415so563028466b.0 for ; Tue, 05 Dec 2023 10:23:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1701800622; x=1702405422; 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=v+0YlV3bBjMI57c/U4EB7oIqdJ8ldlbudM2aWbhqhfU=; b=OwGcd7y/rv/7lEe1ubMO6IEKyPg7ia2YgVEA50a9URa6nktRIzuMWBTslrYMTj0IPS 1Ur1dbbODFAhoyF9OYZKYFP9707UxeEnxuE/ciLDebn31FlkscteI2flGj/QTYH/fDya cglI6gszPsw2Cv88t6yTcI+vr8bwBKrAI2x76562sGnte1+jxeBx4+0RwyneXrDY3s0d 1bM9bGNVKz8q2MVjuoaLbGi9cUsxxb6Crs8iwz/XEJOvaniMAEAJK+nWqTLgVwjFh1ea lr6KVtHNflooM0mdmqkIveAXTdotK/74xkjIGpwHwm6A8mnsW9d32pg8Y437ATeraKgr dlEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701800622; x=1702405422; 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=v+0YlV3bBjMI57c/U4EB7oIqdJ8ldlbudM2aWbhqhfU=; b=RZDPw1/DN4FBdjOfnql49pT7wx6v40G7gHKeEyiQ6LZ6lVItyPs1U2Ntti/rxXPxiU aU1lK57JcwZGgid1wkJtHr0g9ArAOFil5QtZdBc/bcHboiMDPDp/w7M6SGmRvFj+1Nz4 zcapGb3X0O+CVMg4AT41gtR6dTXqkOuxwLAFMZAHBZYIvuJ4W3aT5rzpB67JoHq1kaji i3Q8H6w9158K/MT4gT0VHbcgkzfu2xJsaYoHM1038UoKj7J8c5EzOVdUOdVCju0h+ejL waxphmvIk2DNsJIuY69tZ3tCdz9Bp44b9TrRhyxgU0vOIfJe/qJdPwyVmwAm9bUHiWRL uZzQ== X-Gm-Message-State: AOJu0YzLx8yxSTRJV4jpy9be7tNpGVpYp82E7kw1c5CW5tBdCsAt6qDf sMmoZfPCwPabhKETwzDg9ANe5LtRd38if1f7Uq4s4g== X-Received: by 2002:a17:906:1003:b0:a1b:81c6:3900 with SMTP id 3-20020a170906100300b00a1b81c63900mr1503399ejm.80.1701800621992; Tue, 05 Dec 2023 10:23:41 -0800 (PST) MIME-Version: 1.0 References: <20231204201406.341074-1-khuey@kylehuey.com> <20231204201406.341074-2-khuey@kylehuey.com> In-Reply-To: From: Kyle Huey Date: Tue, 5 Dec 2023 10:23:30 -0800 Message-ID: Subject: Re: [PATCH 1/2] perf/bpf: Allow a bpf program to suppress I/O signals. To: Marco Elver Cc: Namhyung Kim , Jiri Olsa , Andrii Nakryiko , 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=-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]); Tue, 05 Dec 2023 10:23:54 -0800 (PST) On Tue, Dec 5, 2023 at 10:17=E2=80=AFAM Marco Elver wrot= e: > > 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 w= rote: > > > > > > 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 = wrote: > > > > > > > > > > Returning zero from a bpf program attached to a perf event alread= y > > > > > suppresses any data output. This allows it to suppress I/O availa= bility > > > > > 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 = perf_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 The patch was prepared against a 6.7 release candidate. - Kyle