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=1796300127; b=FS4IXk1tsiDznHVXUX1q+U7KM7P3sDGZvqCSkRBoU6ej0sOry+SKvLAl/gAFKkYZUMnP n5CobJowst0GZX3JnJ6cbaBsFaYUguqQNRPw56iqmqPLzeq+M5TYRRRXy/fAd/ND0bHqx dlKHbRmUO7Ptc+ed1HK3gnrgeLjcDMJvqHPIxPub/JSdhhYKGxuIYCy+B4u388wBSJxbu kVs36k5Kzw4rP7QEa0cnJKQh/KKQq4AKFR06nM3lENtetdpRX7Hm97hliKojk3yRLNzen 51t0aXDNCGa0uTbgELe7hGN8OB6ScBNNrHeXBE15ZeSbrtdhgbgyVFezFZFS2fYgTAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796300127; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=czJd/ejXoze1OHeGbbIIHf+5QnnCNB0LhK29H5ZIntU=; b=aOKJmvwrrlfM5sK/NNkJNo32dDt5lXiaT90Rpjb/NE+g1LRTAFJtU8bh5Otrhv4bN+Et SmYYJO+M+gds71kkX/C8TvrE7wwKYR5N7oKJkfCaNu+BNkwy9gejl1NWLspyFpaQwP0gU LNQlx5m7s/Ls5s0koCdym0kjMtGhE08TWfQNl6MbYLVSd+VSexWFLk+U7U7gOwtiyoMwL vjMLSlEm6+RKolYbIE7/vKiDgAgvqC23+uwZkl3xqEO5sCD0ZfGmNU2vj7QLBgzotbXFk +srP1wbAvfq98AKySgao11IwlZfFvdX8mchkJ/hlwriHyOotT+XkkbwyzCHkYVKDHzQ== 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=Elw701yi; 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 9715B606AC02; Thu, 3 Dec 2026 12:15:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9715B606AC02 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=Elw701yi DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=czJd/ejXoze1OHeGbbIIHf+5QnnCNB0LhK29H5ZIntU=; b=Elw701yiU2H0SgDtDz/afzW0BL UMoJzT8sQ36b8B5mNyIdhvX9R3EU+7khcsuTmyqyb78RSni9ayZRh5weUv+irHhd6gu9848BLqR4M EWxUjSGr/8kxIqPFSKF8aJOtt1pOiekYHiWlmQqozWFfKF0VeQLMtBg+zb7y2QIP6uQsmoaLWC6qT c4FlelLoZC2mCCkFmU5ErNwcEQcTfMuiKl6qm7dyaLVhdMghlXg+rN4nO4lkyKi1vOMTcYwMGH7rF 1VA4Xhqi25TZhdpTWg+9P+GxvQLs1CvDmJbdNNUdgwTkXFbxO7GFKGOhDbuP7rissAsQshefh/grf 7FteirtQ==; 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 1xZ5ic-0000000DFqA-1aHb; Thu, 03 Dec 2026 12:15:22 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 6E768300673; Thu, 03 Dec 2026 13:15:20 +0100 (CET) Date: Thu, 3 Dec 2026 13:15:20 +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: <20261203121520.GN2883950@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> <20261202101737.GF2883950@noisy.programming.kicks-ass.net> <20261202142639.GE83911@noisy.programming.kicks-ass.net> X-Mailing-List: linux-perf-users@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=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Dec 02, 2026 at 10:24:26AM -0800, Ian Rogers wrote: > > > - 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? > > > > I got rid of that speculative 'ON' thing, but I'm not convinced of the > > result, see below. > > Replacing event_update_userpage()/group_update_userpage() in-place with > event_set_inactive()/group_set_inactive() looks much cleaner than the v4 > detour. A few bugs I spotted in the draft patch above: > > 1. In group_sched_in()'s partial_tail loop: > - `if (partial_tail) perf_event_set_state(event, PERF_EVENT_STATE_INACTIVE);` > is missing `if (event->state <= PERF_EVENT_STATE_OFF) continue;`, > so it will transition disabled (OFF) siblings in the tail to > INACTIVE. > - For a *pinned* group that fails on a sibling or commit_txn(), > group_error: moves all siblings to PERF_EVENT_STATE_INACTIVE while > merge_sched_in() only sets the leader to ERROR, leaving the > siblings stuck in INACTIVE (so if the leader is later re-enabled on > a filtered CPU or detached, those siblings remain INACTIVE). > - Similarly, if __event_sched_out(group_event, ...) in group_error: > consumes pending_disable and moves the leader to OFF, siblings > already transitioned to INACTIVE earlier in the loop remain stuck > in INACTIVE when merge_sched_in() exits at `state <= OFF`. > > Since merge_sched_in() already calls group_set_inactive(event) for > flexible groups (and sets ERROR for pinned groups), having > event_sched_in() and group_error: simply roll back to ON (no > __event_sched_out() or partial_tail) avoids all three cases and keeps > the single ON -> {ERROR, INACTIVE} transition in merge_sched_in(). Yeah, fair enough. > 2. In __perf_event_enable(), without __perf_effective_state(), enabling > a disabled sibling while its group leader is INACTIVE needs to match > the leader's state: > > if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE) { > if (leader->state == PERF_EVENT_STATE_INACTIVE) > event_set_inactive(event); /* or set_state + userpage */ > return; > } > > Otherwise the newly enabled sibling stays ON and accrues 0 enabled > time while the leader is INACTIVE (until the next rotation, or > indefinitely if counters are held by pinned events). > > Happy to fold those into your version and re-test (including hybrid + > pinned-blocked/rollback tests) if this direction looks good to you. Yeah, that seems sensible. Thanks!