Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2390362rwb; Sat, 8 Oct 2022 07:06:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Wx+ggWpur6QZ6Y2SmEBxtrM3cp5yvpkKpFOqks6zPxFRY58QAPnI+2F6JUuyLiwAW3dy3 X-Received: by 2002:a17:907:6e18:b0:783:87e0:4e2d with SMTP id sd24-20020a1709076e1800b0078387e04e2dmr7775944ejc.650.1665238003957; Sat, 08 Oct 2022 07:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665238003; cv=none; d=google.com; s=arc-20160816; b=djgOVZtPvj2d3hiefuk0Z/WIf1qhVU5wfd5woysbuu7uQHP2tRKFzcaBglbriAZa1I 5R84BU7RTThDfgEbsNLW7WVmTz2nXC9J0b6flKcO8OtuVM2v7jXqcT3fHO/rTS1y6PF5 Yjr4z/79vzuuwEDfQ0w/L2t7qr7ZGKhhYdoi6Fu8DJnsy9pxhjALvp1jWNuPo5nTtsJP hXJEDLIBmnhQ6//O1T6aLbddTK/OxCImZ1SZ543vwyREVY0Pv5f3Q3/ygm+lh0c9eyyT Dxx2dpvoYbInDgVP1lmziYtp14wOuv9lfVrukaGl7uB72IyeBDknRi9ggWsOK9KEreM0 oWZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AwbDRp9Us0UrL0zD8MoR0o+YWUfajcsfFiC3fOiNTTM=; b=HB4YhQOGbs5WYDtqT1lUaG+Qnu1TPuBe9fceW8XO7Q1erHSHU1feyOBuSb4HZLDo1s NM/fQqllLuTWka6CB5XAfKPomvdiOua3KS5k3/WttLHaqqdVENRdQfjuY8AEJhzKdqv1 T0i5F1ZqwwbIVc4DKfN66OWbELz7NDcZ5g4X4VjhI2aljhLURZ2/1H63uFAYS1dQoVp7 NLccij+TP0OznGRjtRmCZ9XiIYJWRWHIjlDJkYjrBXPtSS3XsAM66HsDVuqTs8hB+5iq vaS3onngPeW+/LBYJEeF5HS1OkoSN0PlQc+TnGOYaqthUaNZc9rINr3EcfluljtY1E+r ujNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pCwuzjOU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a170906541400b00782e9b7305dsi5306923ejo.266.2022.10.08.07.05.56; Sat, 08 Oct 2022 07:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pCwuzjOU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiJHNvp (ORCPT + 99 others); Sat, 8 Oct 2022 09:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbiJHNvo (ORCPT ); Sat, 8 Oct 2022 09:51:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE9403ECEF; Sat, 8 Oct 2022 06:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=AwbDRp9Us0UrL0zD8MoR0o+YWUfajcsfFiC3fOiNTTM=; b=pCwuzjOUz0tWxwqCc497YfpRKw GoU+CgGL0UXNHqWQDw6wxV0PNsWghQZbu5omagYEAcZ/vvldxR5NZUSI6TEjqBemhLaeOutUW0muR upAxaNbzc+pEB1jyucMju4l+KOYzTfwnVzWy6zxtPiJidGz2bfpN0yzxi58BLjp6HcqoVd9LJ8CEk DWGzmr1dA0EWVHWEM2omUSPz5OP5knxW5L8/8KHc46viRA1jcXx5MkpHiHy1nhYBlBRyEKWiHH6Kt hbgVd0cu75fExTLp8IM8XlyLX4EBh+4phzZiFPTrDzcG2Zw0rZ02+Xk8Lvjra1AsGRjQGkvZ15WOr BMbXS7PQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohAEj-002ijA-Nd; Sat, 08 Oct 2022 13:51:29 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 65D62300445; Sat, 8 Oct 2022 15:51:24 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3CD5C2BE948B4; Sat, 8 Oct 2022 15:51:24 +0200 (CEST) Date: Sat, 8 Oct 2022 15:51:24 +0200 From: Peter Zijlstra To: Marco Elver Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Dmitry Vyukov Subject: Re: [PATCH] perf: Fix missing SIGTRAPs Message-ID: References: <20220927121322.1236730-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 07, 2022 at 03:58:03PM +0200, Marco Elver wrote: > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 9319af6013f1..7de83c42d312 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -2285,9 +2285,10 @@ event_sched_out(struct perf_event *event, > */ > local_dec(&event->ctx->nr_pending); > } else { > - WARN_ON_ONCE(event->pending_work); > - event->pending_work = 1; > - task_work_add(current, &event->pending_task, TWA_RESUME); > + if (!event->pending_work) { > + event->pending_work = 1; > + task_work_add(current, &event->pending_task, TWA_RESUME); > + } else { local_dec(&event->ctx->nr_pending); } > } > } That whole thing can be written much saner like: if (event->pending_sigtrap) { event->pending_sigtrap = 0; if (state != PERF_EVENT_STATE_OFF && !event->pending_work) { event->pending_work = 1; local_inc(&event->ctx->nr_pending); task_work_add(current, &event->pending_task, TWA_RESUME); } local_dec(&event->ctx->nr_pending); } Except now we have two nr_pending ops -- I'm torn.