From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=90.155.92.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206669; b=v2TzjDKDxY8QqBb1lULVXVxXSQTBOE/QAcNA9usuguuYeQcUi1F4j0Mlg3rFuUYw87E3 Wbcy/RFmunPmDJm254v7UK74xT1eFQD32UBTzhL1eWmH1K2211QA2wbmGS41i5LG+MWdW +qqeS4YacyYgLwAJ0emzerCa+ZvMecieOWrbtjZITmV5djl2UiHGIpW6VB1DylyIoYNN0 mtkRA9IHz4UiFPFYDHLbL0uKHLdy0L4nc+aprYuUCry1NuhGTxx8GrvYTzkYAS1wuF8Bv izCK8WOQNop4d7oAx2jV8vzryGUycbz2JeQiEyTZmU1ZrvEF7Wj73XjVdD9lHNS7mzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796206669; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=HKxV/piv8WB5LSuru6GGiVJT+Hgp4vYvVxbkZXGDaA4=; b=lEJX8ua8Di7TE1QCBtsu99cOCshLnTWWxDY8dEQEO0iA191+GoLrZaGLJ+8j9l0/AwQw 52ETkg3XjzNUQ6ZHdKy3AyZmetQy3uvuWeHt3ZPnWjLX2+K0HPBGGPGVz8G9D5MlisTRJ qE9A0DAzOhtCSUgKxCblfDD1QDlLfD4eEjU/ZtG77nGJCMvkKTHRZICF/L2I6nEIIGQbh dZwfFphwcq2kySksncAuS924AtkfmCB91439NE9DvrSPl1fSa4AbccIFFvkofHyTsZTEk x+di0NVRPyrgOcNadd7Tbubw7JaqW5a5gcwsRnACv+4KYZ59ef71FlG1uucPBmnLgjQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=PiV8wtDa; arc=none smtp.remote-ip=90.155.92.199 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBAB8606A32C; Wed, 2 Dec 2026 10:17:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CBAB8606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=PiV8wtDa DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=HKxV/piv8WB5LSuru6GGiVJT+Hgp4vYvVxbkZXGDaA4=; b=PiV8wtDaNZvjr8RtaNuenuyGqu Bma8rpZzlRkCyqJhPPUhyQk0zx7stVIiUAB5AQL5r8GAd6HprVo8SKN49G//4pJ6ilTcyajNijgM5 zIpuQi8moTkXDs+DWlr7Cy4ERXyZs7mQRikcGVloY6XRLesC0avpwbgoBYrzhQOq2zsHT/DamtMYz N5tw372ayLkkQEHyUZOEb/dbCsrSpwmA6SBPJUvYt9OliqCLPTz8gej/gItjmbwkGq5Sp8X+t8v6t 4UM9UDx5G32HpFkeDYKisLQ1KVt0b1G0PzU6l+6cUfI7Jl1/i9adw7xkrQDMIX64cSF66X52YD8nr P0R/INKQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYhP8-0000000C9RB-3j0O; Wed, 02 Dec 2026 10:17:39 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4101B30045A; Wed, 02 Dec 2026 11:17:37 +0100 (CET) Date: Wed, 2 Dec 2026 11:17:37 +0100 From: Peter Zijlstra To: Ian Rogers Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , James Clark , Andi Kleen , Dapeng Mi , Kan Liang , Thomas Falcon , Stephane Eranian , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] perf/core: Add PERF_EVENT_STATE_ON to fix filtered event enabled time Message-ID: <20261202101737.GF2883950@noisy.programming.kicks-ass.net> References: <80d983c5713537f5743b69e9b35ced1177e4732e.1795589380.git.irogers@google.com> <20261125123712.GP1813469@noisy.programming.kicks-ass.net> <20261125130233.GO2669272@noisy.programming.kicks-ass.net> <20261201091858.GE2883950@noisy.programming.kicks-ass.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Dec 01, 2026 at 08:47:55AM -0800, Ian Rogers wrote: > Fair criticism - I used an AI assistant to help iterate and test > between v3 and v4, and I didn't keep the v3->v4 diff tight enough or > list all of the resulting churn in my reply. Sorry for wasting your > review time. > > Specifically, the unlisted changes in v4 were: > > 1. group_sched_out() / group_update_userpage() move: > Once siblings stayed in ON (inheriting INACTIVE via > __perf_effective_state()), group_sched_out() iterating siblings would > hit `event->state < INACTIVE` and skip updating sibling userpages. > That led to moving event_update_userpage()/group_update_userpage() up > in core.c, calling group_update_userpage() from event_sched_out(), > and adding the `if (!active) return;` shortcut in group_sched_out(). > Looking at it again, calling group_update_userpage() inside > event_sched_out() and moving those helpers 1,600 lines up is ugly and > unnecessary — if group_sched_out() itself handles the !active case > (or updates userpages there instead of in event_sched_out()), none of > that weirdness is needed. > > 2. READ_ONCE() in __perf_effective_state(): > Was added so `leader->state` isn't loaded twice in the two checks > from lockless calc_timer_values() callers. > > 3. `if (event->state <= PERF_EVENT_STATE_OFF)` in merge_sched_in(): > Previously implicit in `if (event->state == PERF_EVENT_STATE_ON)` to > avoid overwriting OFF if group_sched_in()'s rollback consumed > pending_disable. > > 4. `bool inactive` passed to perf_group_detach() / > perf_promote_sibling_to_leader(): > Because siblings now stay ON, __event_disable() clears the leader's > INACTIVE state before perf_group_detach() runs, so without recording > that the detached leader was INACTIVE, promoted siblings would stay > ON and stop accruing enabled time. > > Before I send a cleaner v5, I'd appreciate a quick sanity check on two > things: > - Is the `__perf_effective_state()` + `perf_event_set_state()` direction > for INACTIVE siblings what you had in mind (with the group_sched_out / > userpage weirdness cleaned up)? > - For event_sched_in() / merge_sched_in(), do you prefer keeping > event_sched_in() reverting its speculative ACTIVE back to ON (with > merge_sched_in() doing ON -> {ERROR,INACTIVE}), or would you rather > see the state transition structured differently? Hold off on the v5. I can't seem to make up my mind on what I want here. I'll poke at the thing a little.