From nobody Sun Feb 8 05:09:14 2026 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 2AF04396B97 for ; Wed, 21 Jan 2026 16:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012889; cv=none; b=BWv3By9ePGukNkRGPhtREzO2yACBKRs3mtHMm8ZC1+MQPBvcHsUjbjd2FWAKtGfojiqoDTpFncqNO1QNs6XkPSzZf+Sz3+ywnCAQVyTJt6TjtHmllqyAtYSZYEV3dJlzts2qpPGuIERnw5NcbTuEQp8F9siTLd2TlN3oRlbrn1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012889; c=relaxed/simple; bh=QtrqkoYJsnIkuOBMGJHP+36/t+zPVCwOWnlALYPggR0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=UgyVQMxU25dFO8F9S79n4uOOPNW+gjlA7Ij8oFPNgP1V6WimtuNgR756a5/E+XrTwXnxhFdQ8GWFnoOBkBIBJt4rHtee/FGEODddK2P/S8b91q/TqNafrq7mRCKNk2ioj65grgAnoENPuW5elCxiv/5eHbmN1uk//4XJ/uGuNdM= 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=lcgpKNd5; arc=none smtp.client-ip=90.155.50.34 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="lcgpKNd5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=gqLEudNvaPfbSGEvzjBZ0OxAdYIj1wUbWbu4Ls3as1s=; b=lcgpKNd5yn0oyXe8tnvWUaow8P p2vALDJ6mfHtNTrA3WkUgZ8dRjFCiFzAMwU/x6izoLH76xEcx4DgT0SoHYTHd07wCPZXySBodRYYM hhiOsDtU0hE8NepTGUFMA1meyanGs3Mcf9KRmLptQbNlZjnsga63sDLe64Ww49qoJ3y/W8XDfCTTG w/LwhwaqkEZz2dZtZUpCMOoWKm8K1PCr9g3paBXii6t38vzA/vIP/u9CBtA4ceMQJK+OxCU9AqSrI 81MZGfHwTzWYP14G7XvgPc6b+Lh4fcwLLgMKsjllFbmDyxiYBYBUKz91mXGYgNNLd4IUnZQpeYR8B cAXcyhpA==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vib3k-0000000GawQ-40kG; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id D2424300328; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162507.525037175@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:11 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 1/6] sched/eevdf: Fix HRTICK duration References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The nominal duration for an EEVDF task to run is until its deadline. At which point the deadline is moved ahead and a new task selection is done. Try and predict the time 'lost' to higher scheduling classes. Since this is an estimate, the timer can be both early or late. In case it is early task_tick_fair() will take the !need_resched() path and restarts the timer. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Juri Lelli --- kernel/sched/fair.c | 55 +++++++++++++++++++++++++++++------------------= ----- 1 file changed, 31 insertions(+), 24 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5511,7 +5511,7 @@ static void put_prev_entity(struct cfs_r } =20 static void -entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) +entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) { /* * Update run-time statistics of the 'current'. @@ -5523,17 +5523,6 @@ entity_tick(struct cfs_rq *cfs_rq, struc */ update_load_avg(cfs_rq, curr, UPDATE_TG); update_cfs_group(curr); - -#ifdef CONFIG_SCHED_HRTICK - /* - * queued ticks are scheduled to match the slice, so don't bother - * validating it and just reschedule. - */ - if (queued) { - resched_curr_lazy(rq_of(cfs_rq)); - return; - } -#endif } =20 =20 @@ -6735,21 +6724,39 @@ static inline void sched_fair_update_sto static void hrtick_start_fair(struct rq *rq, struct task_struct *p) { struct sched_entity *se =3D &p->se; + unsigned long scale =3D 1024; + unsigned long util =3D 0; + u64 vdelta; + u64 delta; =20 WARN_ON_ONCE(task_rq(p) !=3D rq); =20 - if (rq->cfs.h_nr_queued > 1) { - u64 ran =3D se->sum_exec_runtime - se->prev_sum_exec_runtime; - u64 slice =3D se->slice; - s64 delta =3D slice - ran; - - if (delta < 0) { - if (task_current_donor(rq, p)) - resched_curr(rq); - return; - } - hrtick_start(rq, delta); + if (rq->cfs.h_nr_queued <=3D 1) + return; + + /* + * Compute time until virtual deadline + */ + vdelta =3D se->deadline - se->vruntime; + if ((s64)vdelta < 0) { + if (task_current_donor(rq, p)) + resched_curr(rq); + return; + } + delta =3D (se->load.weight * vdelta) / NICE_0_LOAD; + + /* + * Correct for instantaneous load of other classes. + */ + util +=3D cpu_util_dl(rq); + util +=3D cpu_util_rt(rq); + util +=3D cpu_util_irq(rq); + if (util && util < 1024) { + scale *=3D 1024; + scale /=3D (1024 - util); } + + hrtick_start(rq, (scale * delta) / 1024); } =20 /* @@ -13373,7 +13380,7 @@ static void task_tick_fair(struct rq *rq =20 for_each_sched_entity(se) { cfs_rq =3D cfs_rq_of(se); - entity_tick(cfs_rq, se, queued); + entity_tick(cfs_rq, se); } =20 if (queued) { From nobody Sun Feb 8 05:09:14 2026 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 5762B392C44 for ; Wed, 21 Jan 2026 16:28:05 +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=1769012886; cv=none; b=acwvjRFzeRXLB2CDi/jp4v24SRxgdKqX9MfGW/5eYBsrpE0asff/RZ68pQWemFcNGWRS7Ecriy0TOQzZCviFrbp66231KJ2TfQ9F1fS4eSnvemZl65EvRANX0XDxb/RvlHr6u+u/cXK7YkYbcx59i/4KH55Enxg3gEbszS+2BFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012886; c=relaxed/simple; bh=R0EtHI742GZCTWZUDFegChs24SN0RP0BIfIUeuIPh1g=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=nJjac56wnvRW/qKtuvxHgvrrbkR5YnCS7+HxlxFwBjwv2uIsNEJExqHbGSJnafEvMdyXmqic2QJclVdxH/n/P/I3cfugiAyvHH5P3qMUtu9NDaPHYcAzNLp8xI72gdchltx6fGpvfXANbesv4kkEGt9u9Y3EpNuwEo9puqGs0RA= 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=pgS/zjnS; 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="pgS/zjnS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=tvvsM4kL8n8wd6yKl1nxlLNT9z4fxtjHxXhTPLGstbo=; b=pgS/zjnSimW+j5uOy+4K0aydTV rrWL4yDHLTOdxQ3POj72f74i6hsVuw6KjzVS9/0DtKuLBnv6Oe8JuflQ/Dc+xDuERuKEOovv5sE3O BoygO54j6SIFLnPMMx0meWqjEyb6F0hhNAxe0g9HfQBrRSOXICbKxoUf3a6NLhD/7dnpHRjml690u PHI0kz96LBsfwrhT/1+L7oWUOH8a4OSMzq5u5JuPoTcgEmo8iqCj3Dr85+ktMX8uGmwj3keoMyB0C 1nuKGh5L0+3hY11BpzWeNKkxui4TtHsNC0HLn2AF4nbs09Jff90uW+odpHAUV7curw5CxncGa+V/Q oCSDIcLQ==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vib3l-0000000GOpP-0WQZ; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id D783E3007E1; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162507.643471683@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:12 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 2/6] hrtimer: Optimize __hrtimer_start_range_ns() References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Much like hrtimer_reprogram(), skip programming if the cpu_base is running the hrtimer interrupt. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Juri Lelli Reviewed-by: Thomas Gleixner --- kernel/time/hrtimer.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1261,6 +1261,14 @@ static int __hrtimer_start_range_ns(stru } =20 first =3D enqueue_hrtimer(timer, new_base, mode); + + /* + * If the hrtimer interrupt is running, then it will reevaluate the + * clock bases and reprogram the clock event device. + */ + if (new_base->cpu_base->in_hrtirq) + return 0; + if (!force_local) { /* * If the current CPU base is online, then the timer is From nobody Sun Feb 8 05:09:14 2026 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 2AE7C3816F0 for ; Wed, 21 Jan 2026 16:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012888; cv=none; b=TlBsSpl+vcE2r20wxSnF3PUnrpw679LwlqmrhKaQC48M4bJr5fnEbC09BdFVGa7erPelXhhDbxJSx0AFI2cDRw/r8yV8mK0H4KUcGKjXkfHL1Pk2emyH4eWcY4prdRSRPvDz+jzGvVA6T2fUV5Jk4Pn8+cAgDW9qS2dcfSyNMDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012888; c=relaxed/simple; bh=0Ey+1N2Hxv5YdcsktFxzOc68YsFpgUKdYMeszaUjAs0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oYemfZ8hHRwiiBxwY7dWzpDve1pUSSV1FFOzln7Y6BBr3vyRasl33wFVPq14QstfZHoH9LB2V5xpj+XQjvR5k5m5XriUQGqCZ+5lBW5XAHhwjSWazXdvhVNlnvP/CrqLCyHAxEqMbfUpwPi3xN5i+l24jsW22xqxQZee5v+yTzo= 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=wHTQ+8RV; arc=none smtp.client-ip=90.155.50.34 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="wHTQ+8RV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=xhQjenhj+1KIIYr2K0a1VS1Uz/3yXC7PKxy9whRk81I=; b=wHTQ+8RVoqOgZPpryTbe2MgFnH TC5u6elmARkQ2GVN2MwpSJnrfN7gWaiLxhQ7wBCxg8L5ZHRwPjjHijBo/XjY76yLkBpFMWaO/y9BY ACbK2NCLV5Fd9I6swRYsUqApzTibZpCcqyfr2Koz6MsSrFb9ECtA7/eGXvS+C8tb6l/Xi3jT7wbve VtlR7JYOvlgDJzCypONMs6sFEtEmyU++ItHbp1x3VSXS59LoXM8ZVaJqxg5UyaAA3OR4pFFvZg+jq hKsVB3DiFIP2oQmLumzbBlTxfZL+JEafm936IDusEQ19ayMVMHX/rh4xjHu8FFhbpvfpAhBlpg2M5 gXAM5c7Q==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vib3k-0000000GawR-42QX; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id DC3B7300B8A; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162507.757183816@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:13 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 3/6] hrtimer,sched: Add fuzzy hrtimer mode for HRTICK References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Upon schedule() HRTICK will cancel the current timer, pick the next task and reprogram the timer. When schedule() consistently triggers due to blocking conditions instead of the timer, this leads to endless reprogramming without ever firing. Mitigate this with a new hrtimer mode: fuzzy (not really happy with that name); this mode does two things: - skip reprogramming the hardware on timer remove; - skip reprogramming the hardware when the new timer is after cpu_base->expires_next Both things are already possible; - removing a remote timer will leave the hardware programmed and cause a spurious interrupt. - this remote CPU adding a timer can skip the reprogramming when the timer's expiration is after the (spurious) expiration. This new timer mode simply causes more of this 'fuzzy' behaviour; it causes a few spurious interrupts, but similarly avoids endlessly reprogramming the timer. This makes the HRTICK match the NO_HRTICK hackbench runs -- the case where a task never runs until its slice is complete but always goes sleep early. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Juri Lelli Reviewed-by: Thomas Gleixner --- include/linux/hrtimer.h | 1 + include/linux/hrtimer_types.h | 1 + kernel/sched/core.c | 3 ++- kernel/time/hrtimer.c | 16 +++++++++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -38,6 +38,7 @@ enum hrtimer_mode { HRTIMER_MODE_PINNED =3D 0x02, HRTIMER_MODE_SOFT =3D 0x04, HRTIMER_MODE_HARD =3D 0x08, + HRTIMER_MODE_FUZZY =3D 0x10, =20 HRTIMER_MODE_ABS_PINNED =3D HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED, HRTIMER_MODE_REL_PINNED =3D HRTIMER_MODE_REL | HRTIMER_MODE_PINNED, --- a/include/linux/hrtimer_types.h +++ b/include/linux/hrtimer_types.h @@ -45,6 +45,7 @@ struct hrtimer { u8 is_rel; u8 is_soft; u8 is_hard; + u8 is_fuzzy; }; =20 #endif /* _LINUX_HRTIMER_TYPES_H */ --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -928,7 +928,8 @@ void hrtick_start(struct rq *rq, u64 del static void hrtick_rq_init(struct rq *rq) { INIT_CSD(&rq->hrtick_csd, __hrtick_start, rq); - hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, HRTIMER_MODE_RE= L_HARD); + hrtimer_setup(&rq->hrtick_timer, hrtick, CLOCK_MONOTONIC, + HRTIMER_MODE_REL_HARD | HRTIMER_MODE_FUZZY); } #else /* !CONFIG_SCHED_HRTICK: */ static inline void hrtick_clear(struct rq *rq) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1122,7 +1122,7 @@ static void __remove_hrtimer(struct hrti * an superfluous call to hrtimer_force_reprogram() on the * remote cpu later on if the same timer gets enqueued again. */ - if (reprogram && timer =3D=3D cpu_base->next_timer) + if (!timer->is_fuzzy && reprogram && timer =3D=3D cpu_base->next_timer) hrtimer_force_reprogram(cpu_base, 1); } =20 @@ -1269,6 +1269,19 @@ static int __hrtimer_start_range_ns(stru if (new_base->cpu_base->in_hrtirq) return 0; =20 + if (timer->is_fuzzy) { + /* + * XXX fuzzy implies pinned! not sure how to deal with + * retrigger_next_event() for the !local case. + */ + WARN_ON_ONCE(!(mode & HRTIMER_MODE_PINNED)); + /* + * Notably, by going into hrtimer_reprogram(), it will + * not reprogram if cpu_base->expires_next is earlier. + */ + return first; + } + if (!force_local) { /* * If the current CPU base is online, then the timer is @@ -1645,6 +1658,7 @@ static void __hrtimer_setup(struct hrtim base +=3D hrtimer_clockid_to_base(clock_id); timer->is_soft =3D softtimer; timer->is_hard =3D !!(mode & HRTIMER_MODE_HARD); + timer->is_fuzzy =3D !!(mode & HRTIMER_MODE_FUZZY); timer->base =3D &cpu_base->clock_base[base]; timerqueue_init(&timer->node); From nobody Sun Feb 8 05:09:14 2026 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 15BD532ED27 for ; Wed, 21 Jan 2026 16:28:04 +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=1769012888; cv=none; b=Y9yKZFDimHtIiB3eQfKB147XC+89vCa7BxDhbG2z9uf51ug/+UE0fzY8MjduSlZoG9CHWcCmh5jRGzbeWFt+nOXqLW0GZrPcsYiiX1X2bED+qyrhdHTtgJrqydjhfbGmDDkZkirloK9Fhg/cNQX3wMn3C3xtK/6f+tSRbsqPcWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012888; c=relaxed/simple; bh=nkRh0zoa1wb7KWILX2rkE+WfDaLMenhee0GDCugCODg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Yl4cCLspJlils24avyjwb1MHd2mRDxhxy/jn4rdxVZraT8hXQ99R/acTyrcijBsiPpX8pEcY6skByajjSnaFRS8iuL54jGPYtgoZIcMbQKfmgrmo+cY61FVACxAzNkmK3CqvaIen0AxC1ukx/6pWbc4eEvwXkLqjeN+1wWFo7Yo= 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=Ipw+2iMo; 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="Ipw+2iMo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=i/e6ipjEvjUpvQ1N8nr9Vxs1Rh/qX1Ik2QYKpUjY4A4=; b=Ipw+2iMo0IchgSM0VYstr9pQGz /idx/x9qE5X8X1R1wqQMMPC0kv8KgQnsnYm+VO0q7ysb03I9n75c5JVoCewskX9guGGGaeS8jzW3E gbdalUbMQjMlzjXg+XYyO1JF/NpioJfb636p1Y5L5e8LEWie0PcRRkQqnN+fBwOqBTEN57d8219ZN 9cUU7pmQrMiScl8PI6Lg7KRGdmdgbwgk/oqQT7A1jrjVZIf8L1gbILOTTG9i0LNL/hsN5mY/SaJyN RM9fsUMYTmleN/oVrmRAkTpKla0A23XWiR+Huwg9CoojifSZlCrhKKmVb/fFqKD2kv4VP2s/iEzNB sr+oa9aQ==; 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 1vib3l-0000000GOpQ-0WNc; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id E2071300BD2; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162507.877520597@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:14 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 4/6] hrtimer: Re-arrange hrtimer_interrupt() References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rework hrtimer_interrupt() such that reprogramming is split out into an independent function at the end of the interrupt. This prepares for reprogramming getting delayed beyond the end of hrtimer_interrupt(). Notably, this changes the hang handling to always wait 100ms instead of trying to keep it proportional to the actual delay. This simplifies the state, also this really shouldn't be happening. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thomas Gleixner --- kernel/time/hrtimer.c | 87 ++++++++++++++++++++++-----------------------= ----- 1 file changed, 39 insertions(+), 48 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1889,6 +1889,29 @@ static __latent_entropy void hrtimer_run #ifdef CONFIG_HIGH_RES_TIMERS =20 /* + * Very similar to hrtimer_force_reprogram(), except it deals with + * in_hrirq and hang_detected. + */ +static void __hrtimer_rearm(struct hrtimer_cpu_base *cpu_base, ktime_t now) +{ + ktime_t expires_next =3D hrtimer_update_next_event(cpu_base); + + cpu_base->expires_next =3D expires_next; + cpu_base->in_hrtirq =3D 0; + + if (unlikely(cpu_base->hang_detected)) { + /* + * Give the system a chance to do something else than looping + * on hrtimer interrupts. + */ + expires_next =3D ktime_add_ns(now, 100 * NSEC_PER_MSEC); + cpu_base->hang_detected =3D 0; + } + + tick_program_event(expires_next, 1); +} + +/* * High resolution timer interrupt * Called with interrupts disabled */ @@ -1924,63 +1947,31 @@ void hrtimer_interrupt(struct clock_even =20 __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); =20 - /* Reevaluate the clock bases for the [soft] next expiry */ - expires_next =3D hrtimer_update_next_event(cpu_base); - /* - * Store the new expiry value so the migration code can verify - * against it. - */ - cpu_base->expires_next =3D expires_next; - cpu_base->in_hrtirq =3D 0; - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - - /* Reprogramming necessary ? */ - if (!tick_program_event(expires_next, 0)) { - cpu_base->hang_detected =3D 0; - return; - } - /* * The next timer was already expired due to: * - tracing * - long lasting callbacks * - being scheduled away when running in a VM * - * We need to prevent that we loop forever in the hrtimer - * interrupt routine. We give it 3 attempts to avoid - * overreacting on some spurious event. - * - * Acquire base lock for updating the offsets and retrieving - * the current time. + * We need to prevent that we loop forever in the hrtiner interrupt + * routine. We give it 3 attempts to avoid overreacting on some + * spurious event. */ - raw_spin_lock_irqsave(&cpu_base->lock, flags); + expires_next =3D hrtimer_update_next_event(cpu_base); now =3D hrtimer_update_base(cpu_base); - cpu_base->nr_retries++; - if (++retries < 3) - goto retry; - /* - * Give the system a chance to do something else than looping - * here. We stored the entry time, so we know exactly how long - * we spent here. We schedule the next event this amount of - * time away. - */ - cpu_base->nr_hangs++; - cpu_base->hang_detected =3D 1; - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); + if (expires_next < now) { + if (++retries < 3) + goto retry; + + delta =3D ktime_sub(now, entry_time); + cpu_base->max_hang_time =3D max_t(unsigned int, + cpu_base->max_hang_time, delta); + cpu_base->nr_hangs++; + cpu_base->hang_detected =3D 1; + } =20 - delta =3D ktime_sub(now, entry_time); - if ((unsigned int)delta > cpu_base->max_hang_time) - cpu_base->max_hang_time =3D (unsigned int) delta; - /* - * Limit it to a sensible value as we enforce a longer - * delay. Give the CPU at least 100ms to catch up. - */ - if (delta > 100 * NSEC_PER_MSEC) - expires_next =3D ktime_add_ns(now, 100 * NSEC_PER_MSEC); - else - expires_next =3D ktime_add(now, delta); - tick_program_event(expires_next, 1); - pr_warn_once("hrtimer: interrupt took %llu ns\n", ktime_to_ns(delta)); + __hrtimer_rearm(cpu_base, now); + raw_spin_unlock_irqrestore(&cpu_base->lock, flags); } #endif /* !CONFIG_HIGH_RES_TIMERS */ From nobody Sun Feb 8 05:09:14 2026 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 5757433F8CE for ; Wed, 21 Jan 2026 16:28:05 +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=1769012887; cv=none; b=u2NaoQjASQX6uUkqUq07ROxuXkeoC6Rr/uOdJ4n1dNSnEtqDP8WKJY+9mGwSug/8Tj7dD/tEdS1Xk09frJY99NHtDKd6oUZ5HsnYe0qnhQNeSt1wrqYaHDnnLs+KGNa/P8gcFSKAvvyFQjRm+MDiJHk1fP1d32Z+RJR9xhym0fs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012887; c=relaxed/simple; bh=Te9y/CXZYZgYptay9SL//Uu1/GDdxFQu0ViL6tC4QBk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=CMEY9YrDW45ZBZraldxO7Wsz+JbdOv8NFF8Niw9N4g9+SwdvWSRj42I73Uw6FU5L6xOo4dGrBwNjKPQho47tAfRep3TwN/4kOQOCbuKVGnT4n+FJ32sic/GBwf0BZBWsE06xNZxPCK+aZG9CWTOKyYxQDnfozqr18ImKeaAGPGM= 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=BkfzvKkU; 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="BkfzvKkU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=aBh7zs+ECeKPDwLLEVf7stzalM/R9is2GnAU+cT0P0c=; b=BkfzvKkUK+yfnht0zA7LvOxNeZ V2yiHfj5O1sgPT/pOR9lAkRDtgbnzbJqyqpiy8Pc9SpbPlYxa8t2J9xos+Mvprj4abiViZF0dWxsm M8zMhUDCkhjozEr4ylj1aDZGSBsdg6mn6B5JlFvx3UYvcpup/xw3KoHpVPE4e80Ueymskgig97Kh+ DPcZc0xaCL4QyKM5s8WVQixbhlImLLusy2OA4nfDt4wiBTY9wRlIfj7bLbB+gtmJLXHXokV4MTerq U8P89DQ+JVZXehZssp5p7uPYROVZcre6n9MXQU6tiVlJd66bvG57d+ezngIz96OSRafQ7JV2kGdYq GE6G8dMA==; 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 1vib3l-0000000GOpX-2hF1; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id E6A4E300DD3; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162508.011240183@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:15 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 5/6] entry,hrtimer: Push reprogramming timers into the interrupt return path References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently hrtimer_interrupt() runs expired timers, which can re-arm themselves, after which it computes the next expiration time and re-programs the hardware. However, things like HRTICK, a highres timer driving preemption, cannot re-arm itself at the point of running, since the next task has not been determined yet. The schedule() in the interrupt return path will switch to the next task, which then causes a new hrtimer to be programmed. This then results in reprogramming the hardware at least twice, once after running the timers, and once upon selecting the new task. Notably, *both* events happen in the interrupt. By pushing the hrtimer reprogram all the way into the interrupt return path, it runs after schedule() and this double reprogram can be avoided. Signed-off-by: Peter Zijlstra (Intel) --- include/asm-generic/thread_info_tif.h | 5 ++++- include/linux/hrtimer.h | 17 +++++++++++++++++ include/linux/irq-entry-common.h | 2 ++ kernel/entry/common.c | 13 +++++++++++++ kernel/sched/core.c | 10 ++++++++++ kernel/time/hrtimer.c | 28 ++++++++++++++++++++++++---- 6 files changed, 70 insertions(+), 5 deletions(-) --- a/include/asm-generic/thread_info_tif.h +++ b/include/asm-generic/thread_info_tif.h @@ -41,11 +41,14 @@ #define _TIF_PATCH_PENDING BIT(TIF_PATCH_PENDING) =20 #ifdef HAVE_TIF_RESTORE_SIGMASK -# define TIF_RESTORE_SIGMASK 10 // Restore signal mask in do_signal() */ +# define TIF_RESTORE_SIGMASK 10 // Restore signal mask in do_signal() # define _TIF_RESTORE_SIGMASK BIT(TIF_RESTORE_SIGMASK) #endif =20 #define TIF_RSEQ 11 // Run RSEQ fast path #define _TIF_RSEQ BIT(TIF_RSEQ) =20 +#define TIF_HRTIMER_REARM 12 // re-arm the timer +#define _TIF_HRTIMER_REARM BIT(TIF_HRTIMER_REARM) + #endif /* _ASM_GENERIC_THREAD_INFO_TIF_H_ */ --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -175,10 +175,27 @@ extern void hrtimer_interrupt(struct clo =20 extern unsigned int hrtimer_resolution; =20 +#ifdef TIF_HRTIMER_REARM +extern void _hrtimer_rearm(void); +/* + * This is to be called on all irqentry_exit() paths that will enable + * interrupts; as well as in the context switch path before switch_to(). + */ +static inline void hrtimer_rearm(void) +{ + if (test_thread_flag(TIF_HRTIMER_REARM)) + _hrtimer_rearm(); +} +#else +static inline void hrtimer_rearm(void) { } +#endif /* TIF_HRTIMER_REARM */ + #else =20 #define hrtimer_resolution (unsigned int)LOW_RES_NSEC =20 +static inline void hrtimer_rearm(void) { } + #endif =20 static inline ktime_t --- a/include/linux/irq-entry-common.h +++ b/include/linux/irq-entry-common.h @@ -224,6 +224,8 @@ static __always_inline void __exit_to_us ti_work =3D read_thread_flags(); if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) ti_work =3D exit_to_user_mode_loop(regs, ti_work); + else + hrtimer_rearm(); =20 arch_exit_to_user_mode_prepare(regs, ti_work); } --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -7,6 +7,7 @@ #include #include #include +#include =20 /* Workaround to allow gradual conversion of architecture code */ void __weak arch_do_signal_or_restart(struct pt_regs *regs) { } @@ -26,6 +27,16 @@ static __always_inline unsigned long __e */ while (ti_work & EXIT_TO_USER_MODE_WORK_LOOP) { =20 + /* + * 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)) =3D=3D _TIF_HRTIMER_REARM) + hrtimer_rearm(); + local_irq_enable_exit_to_user(ti_work); =20 if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) @@ -202,6 +213,7 @@ noinstr void irqentry_exit(struct pt_reg */ if (state.exit_rcu) { instrumentation_begin(); + hrtimer_rearm(); /* Tell the tracer that IRET will enable interrupts */ trace_hardirqs_on_prepare(); lockdep_hardirqs_on_prepare(); @@ -215,6 +227,7 @@ noinstr void irqentry_exit(struct pt_reg if (IS_ENABLED(CONFIG_PREEMPTION)) irqentry_exit_cond_resched(); =20 + hrtimer_rearm(); /* Covers both tracing and lockdep */ trace_hardirqs_on(); instrumentation_end(); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6814,6 +6814,16 @@ static void __sched notrace __schedule(i keep_resched: rq->last_seen_need_resched_ns =3D 0; =20 + /* + * Notably, this must be called after pick_next_task() but before + * switch_to(), since the new task need not be on the return from + * interrupt path. Additionally, exit_to_user_mode_loop() relies on + * any schedule() call to imply this call, so do it unconditionally. + * + * We've just cleared TIF_NEED_RESCHED, TIF word should be in cache. + */ + hrtimer_rearm(); + is_switch =3D prev !=3D next; if (likely(is_switch)) { rq->nr_switches++; --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1892,10 +1892,9 @@ static __latent_entropy void hrtimer_run * Very similar to hrtimer_force_reprogram(), except it deals with * in_hrirq and hang_detected. */ -static void __hrtimer_rearm(struct hrtimer_cpu_base *cpu_base, ktime_t now) +static void __hrtimer_rearm(struct hrtimer_cpu_base *cpu_base, + ktime_t now, ktime_t expires_next) { - ktime_t expires_next =3D hrtimer_update_next_event(cpu_base); - cpu_base->expires_next =3D expires_next; cpu_base->in_hrtirq =3D 0; =20 @@ -1970,9 +1969,30 @@ void hrtimer_interrupt(struct clock_even cpu_base->hang_detected =3D 1; } =20 - __hrtimer_rearm(cpu_base, now); +#ifdef TIF_HRTIMER_REARM + set_thread_flag(TIF_HRTIMER_REARM); +#else + __hrtimer_rearm(cpu_base, now, expires_next); +#endif raw_spin_unlock_irqrestore(&cpu_base->lock, flags); } + +#ifdef TIF_HRTIMER_REARM +void _hrtimer_rearm(void) +{ + struct hrtimer_cpu_base *cpu_base =3D this_cpu_ptr(&hrtimer_bases); + ktime_t now, expires_next; + + lockdep_assert_irqs_disabled(); + + scoped_guard (raw_spinlock, &cpu_base->lock) { + now =3D hrtimer_update_base(cpu_base); + expires_next =3D hrtimer_update_next_event(cpu_base); + __hrtimer_rearm(cpu_base, now, expires_next); + clear_thread_flag(TIF_HRTIMER_REARM); + } +} +#endif /* TIF_HRTIMER_REARM */ #endif /* !CONFIG_HIGH_RES_TIMERS */ =20 /* From nobody Sun Feb 8 05:09:14 2026 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 424283A1D1A for ; Wed, 21 Jan 2026 16:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012890; cv=none; b=aStWKZGjDG4e94G8Q+eBC/KqVHaVe7gDm8u9SdaqyXZHaWf6I731eOObESONaCyKdoTXjKsTLMmHKnrKS/Uw/eWzPPMMWz/zVts2zfMIK6LVlLbvupqxhiwKQvFQavDoskAYkXUGe7CyHAgIuVXcLUIzeeHE1VMd4p94t4xBKMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769012890; c=relaxed/simple; bh=qkWIvC5GwgaCPs1KjymcOs1WLgj1KHKSDopczLfSVD8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=irO6TIXZ1UVmuafNihHgilJAmqu40m0OstQa063L7u2ANi430TeF1xSDNX3kjbwrHkIPmIcP4OOucZPxqZVEQIt4I08i8NYD6WHpY/xiikZIHi4mf68Ig56ux0euFIYP1qZqHYsp5D8GV/m4p5gylqCtujLZeTL6/FrnMy+6F90= 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=uSEwv/s1; arc=none smtp.client-ip=90.155.50.34 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="uSEwv/s1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=xPO0n8B2n6nloFv0JZaHWBUWZ7CNQc+G/tnspEAUovg=; b=uSEwv/s1MmQf/Na3DYCflZgqDN cucndpjC1NqdjNeOML9YNOKJuoWIASZWrUpvi0Fi0Q29cTdzs5N+TtewnGRYMGipprDwx5AwzG66I JXjnfskPyPJMPCyUdSNPZXv4l54CxvuDa21OLn7ps67YXaJwSh+DDJ3WfhZMKxMwSHyOKUPxdCX2b wNtY8yZmat2m34qmMJZr4O/REXfh9nR98xuM1pHVGqQmjvQgsGfR2XHRXjpB1INeurhOXf5sMnc+Q /sa/WyFYQ/q/f2Dgzgy55rAzlXIpormC0i0GxFlEnYE+bHibJ1Xsz3MHHfRDhy7GDfCAdz2fG1snZ j/uXBVVQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vib3l-0000000GawY-2qEl; Wed, 21 Jan 2026 16:27:57 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id EB134300E7E; Wed, 21 Jan 2026 17:27:55 +0100 (CET) Message-ID: <20260121162508.119040984@infradead.org> User-Agent: quilt/0.68 Date: Wed, 21 Jan 2026 17:20:16 +0100 From: Peter Zijlstra To: tglx@linutronix.de Cc: arnd@arndb.de, anna-maria@linutronix.de, frederic@kernel.org, peterz@infradead.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: [PATCH v2 6/6] sched: Default enable HRTICK References: <20260121162010.647043073@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ... for generic entry architectures. This decouples preemption from CONFIG_HZ, leaving only the periodic load-balancer and various accounting things relying on the tick. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/features.h | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -63,8 +63,13 @@ SCHED_FEAT(DELAY_ZERO, true) */ SCHED_FEAT(WAKEUP_PREEMPTION, true) =20 +#ifdef TIF_HRTIMER_REARM +SCHED_FEAT(HRTICK, true) +SCHED_FEAT(HRTICK_DL, true) +#else SCHED_FEAT(HRTICK, false) SCHED_FEAT(HRTICK_DL, false) +#endif =20 /* * Decrement CPU capacity based on time not spent running tasks