From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E2ECE3A784D for ; Tue, 24 Feb 2026 16:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771950921; cv=none; b=mNmDL2wn9aCdwbtl9kTcHrNwGV1P1gwtRI9lA0SGxrx/qJTdfaV5QgNzsCDNlrZJPbDePUW32vidC+QvMt3i692g2C8PCd8b91IDxy1fKSh9g6BDH6WIsz/ckdv/y2ncqnnTmzvNetNvXTLECb+o/AuGp9iko1doo/3mnerYRb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771950921; c=relaxed/simple; bh=ivti1BQ26HIJUTFrd9/bBB/3cN9Zh/5oIInGVfOpYF8=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ttZqmjy79LSc5hLJnguqnSYVGcBWWRhYDomtXGLJbclnTLg5lk1qcUMWYnlfDuFDBXSLZxcHvhbHp4ZPRbAPK1X4mY99+9rH4mvs1UM0ahHY4/BFHoSWRprAg268OVD9dgJzg74oE9f7aeaWgLjuNOc/NqghTap7e2U8utfPCJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6toPVym; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K6toPVym" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36FFAC19425; Tue, 24 Feb 2026 16:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771950920; bh=ivti1BQ26HIJUTFrd9/bBB/3cN9Zh/5oIInGVfOpYF8=; h=Date:From:To:Cc:Subject:References:From; b=K6toPVymR0gcZ11eJpz9IYwxWTI7jJTRxOBix1bll0fqeBKQMko5ZsQFROrDpOF2i H8VFhiVcKZt+S7x3qFG1u/v63zEwCMe10Gf0ITlXEopwBJMladegxO/JfGZxY9Pajg Idq7yIaA3D3PSJsSFsLyfAUPwhBzHg56RI5CxKJdeGXHrWLNkWKv+1Q2DgYIRyP2y3 HY7A/g2+MTLxjz076ghxJ6uxTYr7yE7QzrB0LFhilRMRGg/1nfCPpARqupEzUoM4ms NCPHc0G3T3ltkIj+HI/dfSz41EELM1Ik7xVlJWlRbQAjEmdFnf+C2pQhQo1FE3NHlZ bclO0RLUlyMGA== Date: Tue, 24 Feb 2026 17:35:17 +0100 Message-ID: <20260224163428.798198874@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , John Stultz , Stephen Boyd , Daniel Lezcano , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , x86@kernel.org, Peter Zijlstra , Frederic Weisbecker , Eric Dumazet Subject: [patch 01/48] sched/eevdf: Fix HRTICK duration References: <20260224163022.795809588@kernel.org> 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=UTF-8 From: Peter Zijlstra 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) Signed-off-by: Thomas Gleixner Reviewed-by: Juri Lelli --- kernel/sched/fair.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6735,21 +6735,37 @@ static inline void sched_fair_update_sto static void hrtick_start_fair(struct rq *rq, struct task_struct *p) { struct sched_entity *se = &p->se; + unsigned long scale = 1024; + unsigned long util = 0; + u64 vdelta; + u64 delta; WARN_ON_ONCE(task_rq(p) != rq); - if (rq->cfs.h_nr_queued > 1) { - u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime; - u64 slice = se->slice; - s64 delta = 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 <= 1) + return; + + /* + * Compute time until virtual deadline + */ + vdelta = se->deadline - se->vruntime; + if ((s64)vdelta < 0) { + if (task_current_donor(rq, p)) + resched_curr(rq); + return; } + delta = (se->load.weight * vdelta) / NICE_0_LOAD; + + /* + * Correct for instantaneous load of other classes. + */ + util += cpu_util_irq(rq); + if (util && util < 1024) { + scale *= 1024; + scale /= (1024 - util); + } + + hrtick_start(rq, (scale * delta) / 1024); } /* @@ -13365,11 +13381,8 @@ static void task_tick_fair(struct rq *rq entity_tick(cfs_rq, se, queued); } - if (queued) { - if (!need_resched()) - hrtick_start_fair(rq, curr); + if (queued) return; - } if (static_branch_unlikely(&sched_numa_balancing)) task_tick_numa(rq, curr);