Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1801745rdb; Thu, 7 Dec 2023 09:06:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFvD+fTFoY146eJuBpfx5JjgkC+RxgNSbGCmtwg/Sa8Yr/6CKMiAqyRlpBM0cxlLporNpK X-Received: by 2002:a17:902:ce92:b0:1d0:af28:461a with SMTP id f18-20020a170902ce9200b001d0af28461amr2886239plg.12.1701968785261; Thu, 07 Dec 2023 09:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701968785; cv=none; d=google.com; s=arc-20160816; b=mez9yyDjWVcVEwuwv3VgK0A8XdmOVRPCYZG9PnoRB9mDl7xl7xG+NGOW1NRcf3phvL dFxIW//4Umb4Z4CaeAClRDhiN9JDObksE0M7SRL1VxWsH+9JOY4ayjejSck17JYJ6Uov pOBBWBTCMv4XIxLr9C2Bvss/QfuFv0OjaoW6U4+dKzhj8CueLIvE1YzY4+0BIQumiANa x8LYogbL0juPEpu6Hv6AG9ZSY1CNICBBZ8ml/yO4jcjtPaIFTihyw7T6vrFDy6GjemSB amoBbNByvJ+bLgxxL6n26qlHBdAzVI/Q6cmWII44mDVJBnylbhXX3pzpPObzy0A3OwlT Hz1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/gQwCYDHPBBWnGreQGj5kMmktVS56VhncbMZUIjTkxA=; fh=L+WTYN0S35MPjivZQOBqw072Ab87TgCWc9ACzMtp0nc=; b=jmOr1sWqv8kNSSF9W94jXI+QOiGKwUUaqLe7pdvkdQUbockNehmPRzKjLyw68U3OfY q4PsoL+gbbjX8WMFY7R8xHULxoya/csUCgsFFNZVOULOlC9xBWnuHS0GLTPvTewd6rsx cgTnnzsFfmiwAkEg+t42IbXjMynPtvOKNK99FM4LWjZKJ41J6kKVCZbaUV8C5CC8i9UM FyIGjq3zo1Fgx1kKJUbHvC0KHCVfTChMuBpYGbtbIj7+7d/XqwXbXZcGsOhKnPw9VZNm 33Tys6bAZtwgDjp4FE7D/ILxQ0/8a9kK1hRZR5teh9gG3sLZkdGfQzeHoGSIbd2BqZDp QiTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="N/nxXtBZ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id p8-20020a170903248800b001d0c906f613si42281plw.492.2023.12.07.09.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:06:25 -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; dkim=pass header.i=@google.com header.s=20230601 header.b="N/nxXtBZ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8441280324E7; Thu, 7 Dec 2023 09:06:11 -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 S1379413AbjLGRF4 (ORCPT + 99 others); Thu, 7 Dec 2023 12:05:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443194AbjLGRFn (ORCPT ); Thu, 7 Dec 2023 12:05:43 -0500 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150E210F1 for ; Thu, 7 Dec 2023 09:05:50 -0800 (PST) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6d9d1962bbbso748785a34.3 for ; Thu, 07 Dec 2023 09:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701968749; x=1702573549; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/gQwCYDHPBBWnGreQGj5kMmktVS56VhncbMZUIjTkxA=; b=N/nxXtBZdALdkfa05rASSt+SKtNvnIxvZ9lp2fYxAANLa2BIwY3Uy5QkBvcimzBTjS 2+ukcvhC6xj0NLeLo7Ae2/MiIiIVs8lttDZK3rTY7nTSwCXvAY0Oa9dWfuxgnhJgRUoN rPNpCOnFwDgw16ZpMxxQL3/8P93M3A+DgBuLAS7aKY7NTx7dgMBODbwkx9BRlQvEYoch l/vTd9SCrh/30LFxRA8KZo4vembEIafl63CEWfjKG+9X2Iyg2M/g8ONleNv39jtZ0N3+ 5q3wZtzRYEe/y/7DVLc3lt4r5IgrHTrWtyWU1s0otBK75Ckbl6Qtvdwktk00wBBBnSh+ 4p3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701968749; x=1702573549; h=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=/gQwCYDHPBBWnGreQGj5kMmktVS56VhncbMZUIjTkxA=; b=Bqv0xNlSs0jDOt+J6xe01BSeb86Vnz/W7qR+A6mAP0vHYdkht6h466QF5owJt1FQEv Utxn3yaMzVlKUG6OxMAuZAn6jr5i3rj8ktlcHkAfd8CynVYNM1D+E2rrGhadgPttHFLt Z7PWEMov2cJUkygOKIGgedGRi+ClR9DE2HNnoXl8rjyNUftaiDKPf9yW3t3X8pvGhrHd z7jit9vA4C63FoimHlo8+tuWrixyzAlj9bQ+uHWvkEUZwWgk7ywgsCp2oB7wN5UnP0Bc OkOQWpRiVOT7B0DhtxqHiPCL1rvMSarV4iVuxc+jcKO94m2lXwbfFuer2O6d8A0RC24w 5jyA== X-Gm-Message-State: AOJu0YyjC4EaUAVscDVWy4OiNpFsMpHvO4GlL2Hp0DyXr/M338zBowZZ lv4lQGBHvPB27cZPm5HgL/EtyC4qDV/Grk6/AWkCLw== X-Received: by 2002:a05:6358:5e14:b0:16d:f743:4107 with SMTP id q20-20020a0563585e1400b0016df7434107mr2967267rwn.3.1701968748863; Thu, 07 Dec 2023 09:05:48 -0800 (PST) MIME-Version: 1.0 References: <20231207163458.5554-1-khuey@kylehuey.com> <20231207163458.5554-2-khuey@kylehuey.com> In-Reply-To: <20231207163458.5554-2-khuey@kylehuey.com> From: Marco Elver Date: Thu, 7 Dec 2023 18:05:10 +0100 Message-ID: Subject: Re: [PATCH v2 1/3] perf: Reorder overflow handler ahead of event_limit/sigtrap To: Kyle Huey Cc: Kyle Huey , linux-kernel@vger.kernel.org, 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" 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 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]); Thu, 07 Dec 2023 09:06:11 -0800 (PST) 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). Allow an > overflow handler to suppress the other visible side effects of an overflow, > 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_event *event, > */ > > event->pending_kill = 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). Although I can see why this solution is simpler. Perhaps with enough comments it might be clearer. Preferences?