Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1833492rdb; Thu, 7 Dec 2023 09:54:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWybUPtcyjnDZQT1YAra7K2TVXtQKEcK5ZaFq1e4UVqxgq4tj6T91exLynnF0wS78W8H/E X-Received: by 2002:a05:6358:9886:b0:170:17eb:3786 with SMTP id q6-20020a056358988600b0017017eb3786mr3715721rwa.46.1701971686703; Thu, 07 Dec 2023 09:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701971686; cv=none; d=google.com; s=arc-20160816; b=bEwvOMFYSd/4/l7JwWiJPDGmKkDuQ6IWSuwuEkRscNEMS613Sp2gv09IBr+JlVmcw+ BM4x5/iINcuzqJak1Mac4YdSJikp1DBfCf7QeLIBf7sL2TXMxjhKa/Q0GDZcRl4/IdPw 5OBnvoolv7okliExbEaWqnMSijksG5cDbo0ZDWpjrn47FSYqIvQe514D5sHy9NtM/rle 2IgAJ+Nah/oy6bjvElbRW+Co9bxUT0oze0lbHB5Av8eNzdbQPtgR7a6lGFe09pb2MrhB HZNIsKwn7EWODZ0ovGFesldV17q90yAwQ6iFDYwjz9fSyCR+HDKLEpZeZYzdmeY9Jjz6 eaRQ== 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=/FYoDefF8AqdfjCaLos2fQ25+4YPa8J7nFuTpXaVzvQ=; fh=hPqsWc5xeVTNKZRDPirAB5sSDaOuBgYK/Ytnfezv5+Q=; b=TTNt8DWgNkgzEeUNBhvygEyA7QkY0rxe3xk6jM3nayvJGsGeb6TUpzXY9Zq8revguC b/kwTdOb/Tzk8nZPuqij4m0Jrb+WEBknNBRBAMkUc1HQzeH1St4LEmiMfz9vxjnOXmyD Z+2ExPtrA9yfRjD7Lq5EGvdpj0mIm40m/ks15WPtV5I/vU05qya8UI1Dpk+WX/UQJ4Oz izIaXu2a5ocGmWyoDJ73vACE1PdR7yOtFRmgpN1ARMdg0Nn3QwRE2P/y9g2tpruz2hLt NOzjVb4/qb4DY1rXj97EgapWo1592cM9wlzfdJGQ+vYwu3f8afg9O5sPfHo3qIPKU/U4 v3TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nscd7MPm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j4-20020a654304000000b005c661efffd0si50421pgq.754.2023.12.07.09.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:54:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nscd7MPm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7BE7E83348AA; Thu, 7 Dec 2023 09:54:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbjLGRyc (ORCPT + 99 others); Thu, 7 Dec 2023 12:54:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbjLGRyb (ORCPT ); Thu, 7 Dec 2023 12:54:31 -0500 Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA01512E for ; Thu, 7 Dec 2023 09:54:37 -0800 (PST) Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-4b3203cdc78so215817e0c.2 for ; Thu, 07 Dec 2023 09:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701971677; x=1702576477; 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=/FYoDefF8AqdfjCaLos2fQ25+4YPa8J7nFuTpXaVzvQ=; b=nscd7MPm0v7G5mqo0mtyez0Bazh9fU84X4WFn2rMHFJ6op4ZgAPcyXkYOI95TrRJT2 fQshIVw1M/F5N7IIW2Hg7yEIeRXVcvsGvEToNSpVP5MJweKfcJ0FNX5CP6LdjIuY1mv5 t5V8dtXI2HIjbIjc/OQi8y5TqbFn79SgEZMsiU33MJHDzQOBs8vdRVbEwYDubG1wxfSV L9sAzYJNoWD5551OSXYhHx48Rphjo1MGtIdf6orO4H2zeVGKeCW9nVMRBNGASCPbOF6M RteEVPqcoEvq3hKDV2CI8/UGT8HrVcj675DKa+G9+b8NSrru0AvGJ98XsceXWxqryXLs MxYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701971677; x=1702576477; 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=/FYoDefF8AqdfjCaLos2fQ25+4YPa8J7nFuTpXaVzvQ=; b=udqyv+IWEnKBWDHcuY6D3xMyQUDLb/dfGKEVJnqzB1ZlC1H6qe4aFRmYydAjgscRMl Qco74DB4OQg4PGTb4vnBjxJ9B2UtX5OseVNmMdpbNSw9feMKv2pptv6zZ9EouGtJ+Fki A1LibiXjm88IDcJh/DrBwVN59SgYMjX+N9SBvwlbnnRPt46T2KifI1QnH8SPnyZQONFW 5BxV8fmPCo+YRnoRs9Z9dHrvltNNRJbLfxWAydIZCZAeXyQB3AuY4ViPIK4xJwqxoyIq ZrNSG3lPa/ERcDEnnIhrxp4tkVk3KGnp7JeRZK0V6sf4ahL789Zad2RBytkzE/KdIRi2 ZuKA== X-Gm-Message-State: AOJu0YxV8tnUKoKWkZVLAjt+xJtSkIfp8LF5XMZRb+Si5DAeQhAckbTe /YOyiNmzaOPDUc2IX9Z8XhmKajd8SweDqyBVSh1qDA== X-Received: by 2002:a1f:4a03:0:b0:4a1:7278:3bf5 with SMTP id x3-20020a1f4a03000000b004a172783bf5mr2632426vka.4.1701971676821; Thu, 07 Dec 2023 09:54:36 -0800 (PST) MIME-Version: 1.0 References: <20231207163458.5554-1-khuey@kylehuey.com> <20231207163458.5554-2-khuey@kylehuey.com> In-Reply-To: From: Marco Elver Date: Thu, 7 Dec 2023 18:53:58 +0100 Message-ID: Subject: Re: [PATCH v2 1/3] perf: Reorder overflow handler ahead of event_limit/sigtrap To: Kyle Huey Cc: Kyle Huey , open list , Andrii Nakryiko , Jiri Olsa , Namhyung Kim , Yonghong Song , "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 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:54:44 -0800 (PST) On Thu, 7 Dec 2023 at 18:47, Kyle Huey wrote: > > > > On Thu, Dec 7, 2023, 9:05=E2=80=AFAM Marco Elver wrote= : >> >> On Thu, 7 Dec 2023 at 17:35, Kyle Huey wrote: >> > >> > The perf subsystem already allows an overflow handler to clear pending= _kill >> > to suppress a fasync signal (although nobody currently does this). All= ow an >> > overflow handler to suppress the other visible side effects of an over= flow, >> > namely event_limit accounting and SIGTRAP generation. >> > >> > Signed-off-by: Kyle Huey >> > --- >> > kernel/events/core.c | 10 +++++++--- >> > 1 file changed, 7 insertions(+), 3 deletions(-) >> > >> > diff --git a/kernel/events/core.c b/kernel/events/core.c >> > index b704d83a28b2..19fddfc27a4a 100644 >> > --- a/kernel/events/core.c >> > +++ b/kernel/events/core.c >> > @@ -9541,6 +9541,12 @@ static int __perf_event_overflow(struct perf_ev= ent *event, >> > */ >> > >> > event->pending_kill =3D POLL_IN; >> > + >> > + READ_ONCE(event->overflow_handler)(event, data, regs); >> > + >> > + if (!event->pending_kill) >> > + return ret; >> >> It's not at all intuitive that resetting pending_kill to 0 will >> suppress everything else, too. There is no relationship between the >> fasync signals and SIGTRAP. pending_kill is for the former and >> pending_sigtrap is for the latter. One should not affect the other. >> >> A nicer solution would be to properly undo the various pending_* >> states (in the case of pending_sigtrap being set it should be enough >> to reset pending_sigtrap to 0, and also decrement >> event->ctx->nr_pending). > > > I don't believe it's possible to correctly undo the event_limit decrement= after the fact (if it's e.g. racing with the ioctl that adds to the event = limit). > >> Although I can see why this solution is simpler. Perhaps with enough >> comments it might be clearer. >> >> Preferences? > > > The cleanest way would probably be to add a return value to the overflow = handler function that controls this. It requires changing a bunch of arch s= pecific code on arches I don't have access to though. Hmm. Maybe wait for perf maintainers to say what is preferrable. (I could live with just making sure this has no other weird side effects and more comments.)