From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C462C379999 for ; Mon, 2 Feb 2026 16:34:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770050049; cv=none; b=fhY0Tsmzb6ECmJL+a5JyqhhUGuYoW83QM4FaMR9jWt/Cq/RAfyvpa9atHFUU5dlfDrw3bDgcen4ldZNlzbMEqIWOvd2AROho7LEZLunqBWX86rvv9QXigfDpvThSVThXiMLdJEKF8gaE9lwGm9+8uiFY58FgDCEeKx50ZH9rzMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770050049; c=relaxed/simple; bh=ExkcZnFSwuc+JuR9EFm7XDBy23ubJxTnfsA/QOLt/w0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EXbuLUYN3F9TSKdkeFkF3d9FBZoLt08GAfMEGKf6TOrEOfXl0+EsEmKXHU2cAALC/nvPPZq4AXUPHIz6Yyy2+18uiDbRtbwuEyauOy1RcHv2LUC+kFhXpELqPw5NjrXCKuYIm8CGxrn1lBLP2W7PAx0045FTUjVBzZYDuURjRFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=UAZ3KRki; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UAZ3KRki" 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=miJHn80bFQZR+vmsxLi5NgRTqTRjuETmQiCYwr3f0jw=; b=UAZ3KRkiQFPfXyvzEotNolR9qR soNgbmJblwNRQv60rC/pYkI+xYKC7Bo/e8MVpp1hlGFpfDvzZyuELj6W1DytoX7gOm0pI0vDDIeLF 4FC7XGp5tCRAxaNjQl3pBBkelqQo0w/N7Uv+/dSXfd8/pVxP/XfNhcrDWzBkwg4i7OTbP2APnFveW hm2OqVnhIPNKAOJZguByoiS3T9cgeMsCDYHNn8K6hDW0uDnoUWetRRR/txonju1pu4zCRfxZjwvXz T2q2tX1md4emPNJu8Q3lWzmofQy3XNLnwFeAslfyolF7tLbjArrYcMIcVzznviMWYYDohmD3z+LNj A1OYzLrA==; 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.98.2 #2 (Red Hat Linux)) id 1vmws9-0000000Eqqe-3LJr; Mon, 02 Feb 2026 16:33:58 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 062A33008E2; Mon, 02 Feb 2026 17:33:56 +0100 (CET) Date: Mon, 2 Feb 2026 17:33:55 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, luto@kernel.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, oliver.sang@intel.com Subject: Re: [PATCH v2 5/6] entry,hrtimer: Push reprogramming timers into the interrupt return path Message-ID: <20260202163355.GI1395266@noisy.programming.kicks-ass.net> References: <20260121162010.647043073@infradead.org> <20260121162508.011240183@infradead.org> <878qdbfbza.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878qdbfbza.ffs@tglx> On Mon, Feb 02, 2026 at 03:37:13PM +0100, Thomas Gleixner wrote: > On Wed, Jan 21 2026 at 17:20, Peter Zijlstra wrote: > > while (ti_work & EXIT_TO_USER_MODE_WORK_LOOP) { > > > > + /* > > + * If hrtimer need re-arming, do so before enabling IRQs, > > + * except when a reschedule is needed, in that case schedule() > > + * will do this. > > + */ > > + if ((ti_work & (_TIF_NEED_RESCHED | > > + _TIF_NEED_RESCHED_LAZY | > > + _TIF_HRTIMER_REARM)) == _TIF_HRTIMER_REARM) > > + hrtimer_rearm(); > > Two things I'm not convinced that they are handled correctly: > > 1) Interrupts > > After reenabling interrupts and before reaching schedule() an > interrupt comes in and runs soft interrupt processing for a while > on the way back, which delays the update until that processing > completes. So the basic thing looks like: irqentry_enter() run_irq_on_irqstack_cond() if (user_mode() || hardirq_stack_inuse) irq_enter_rcu(); func_c(); irq_exit_rcu() __irq_exit_rcu() invoke_softirq() irqentry_exit() irqentry_exit_to_user_mode() irqentry_exit_to_user_mode_prepare() __exit_to_user_mode_prepare() exit_to_user_mode_loop() ...here... So a nested IRQ at this point will have !user_mode(), but I think it can still end up in softirqs due to that hardirq_stack_inuse. Should we perhaps make sure only user_mode() ends up in softirqs? > 2) Time slice extension > > When the time slice is granted this will not rearm the clockevent > device unless the slice hrtimer becomes the first expiring timer > on that CPU, but even then that misses the full reevaluation of > the next timer event. Oh crud yes, that should be something like: if (!rseq_grant_slice_extension(ti_work & TIF_SLICE_EXT_DENY)) schedule(); else hrtimer_rearm();