Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp467665rdb; Tue, 5 Dec 2023 10:08:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPP4W64mfgB8x7b+eWKM9moY7SlA4V7IltRFYdjQcQoydQtgGPVAbLphllAdrgziBg//rd X-Received: by 2002:a05:6a20:be25:b0:18f:97c:385d with SMTP id ge37-20020a056a20be2500b0018f097c385dmr1902380pzb.55.1701799689859; Tue, 05 Dec 2023 10:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701799689; cv=none; d=google.com; s=arc-20160816; b=LWqaVrxD2r6zKZTt83Z21yug8ybdkwaxpkiT6uuF3J0F5jL3aQ9yWfNZbhBjjcVrcY YQaQz+Ffj0pAaYB+eWMAUTMXtptGdPw30YwcF/YaudBq4RmCP3zoeMj+YCRwhIzWlwt3 s8AsyzP/EpOJDpCxzSluHXONANK3FUFsG1IdI3Eh8j5q0fy0vdEETIIB3zxY/FMQsEwI RtrTD3ibv0AoK5h+ZHY/V9ttyLii0g0kgPSn/It20s25qwLONAd5P3mN5Si8RrSmQpXm 5Qe8BYJDJ8COfrFqFKzrUBsbT6Y8YXCSh6bMuu4jxKZQoS1U9p1BELzg13kAvW1j27qm 6Iyg== 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; bh=+bkoH/wpOJ3idqNj/JiKQNdvlBqBFr0SWbiWsRZnKk4=; fh=sJ7c8Vn2JlDN5dG37O4176fITVEhxPN/ZLshGF9TuMQ=; b=pSLTPwoxXSZ81G3boS0vjKUcZUIkgXqsXFPaPyMorntRGKaVplZ6ty+30E5BScXmel hFB5IqWceOOhuEI8Ca8dPEcJjNo4TE2BWpOLSkH7UvUfWC3rAkp1wSCSufbMU9NRcUyH 0/zzIiDsLDJW++vhRw19c5DXtxXKHQ7XUNttrtWYfdWvfGsUu+U9LIFtPHcAoZH1e7+O W+rZuEGlnuJo8fyBW3eVUWDuThmCfM1Bbm79m7MYoB0hQeCLd1HTPVCyRdsuoCTTgxm5 L0qPqJTcN/ARfAcJR42AkfAbrFn2Ro0ag9AZrhMZrHadpkFNZPcNZOi/WKo8mwIUqigq IkjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id w16-20020a634910000000b005c21fcf96a2si9948444pga.825.2023.12.05.10.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:08:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B6E0F80966EC; Tue, 5 Dec 2023 10:08:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235112AbjLESHs convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Dec 2023 13:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbjLESHr (ORCPT ); Tue, 5 Dec 2023 13:07:47 -0500 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 340F1B2; Tue, 5 Dec 2023 10:07:54 -0800 (PST) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-28659348677so42503a91.0; Tue, 05 Dec 2023 10:07:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701799673; x=1702404473; 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=eNlzMFur71ZQLLM8yVbvG7H8ZNU7xWznyiwruW2zco0=; b=mmpoplhQu5uU/XSuuWP/AqZ8VpkAKj5UQwW7THhA8AUjNqnjE16Xc1Z13cI5HcQUlS JhAkQt7b4jSEUjH8ondLXyM64q6MnYaLfFhFn1f57pww8Guh7wjzt0I27dXkjldJSOIS ML53Ydc4wt09wtjhaEgjrTBFymmNmJ7ADTQHVWTTvfdgLqoxHdUlKTexwM9xfzUVY8Vl v4UV9moer2GAJzslTjtrB4hMMssifMK1F6Aub0UIh64xbePDukSavbJUXW+78T0eRoiI g4vMGjt3drqWBGFxqWRoc1FWLH8YPixAnViCX7vyyeZgf5RBTJYCHHtp10vh4Ys2Aw67 cYKg== X-Gm-Message-State: AOJu0YzT5jZn00jLY3thcs/QSy0hE2wCz7g4olUqF8HMWe3DvD5q8a+3 ULKve4jgBhQv7SS9mrXhSNZEo0N6w6FX/JAOyrQ= X-Received: by 2002:a17:90b:1c0b:b0:286:bda8:9633 with SMTP id oc11-20020a17090b1c0b00b00286bda89633mr1926839pjb.25.1701799673408; Tue, 05 Dec 2023 10:07:53 -0800 (PST) MIME-Version: 1.0 References: <20231204201406.341074-1-khuey@kylehuey.com> <20231204201406.341074-2-khuey@kylehuey.com> In-Reply-To: From: Namhyung Kim Date: Tue, 5 Dec 2023 10:07:42 -0800 Message-ID: Subject: Re: [PATCH 1/2] perf/bpf: Allow a bpf program to suppress I/O signals. To: Jiri Olsa Cc: 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, Marco Elver Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 10:08:06 -0800 (PST) Hello, Add Marco Elver to CC. On Tue, Dec 5, 2023 at 3:16 AM Jiri Olsa 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 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 > > 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 = 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