From nobody Wed Jun 17 04:16:06 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 55A703D669F; Tue, 28 Apr 2026 07:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777361167; cv=none; b=TvR8WRa47lwmUP89eUk6pWUkbIGQNsxkbfKst9nQaQNClUiizvZl8EEVupD1wXZWXXtZltg2/22JJP8+lPEAB4F64W3LQ3Nsz6DfT6iIy30qDRIRFDVQAE8SW9M2ziwmcqidtkT5nF1T6/JvSX22ZjxJsDiQnh+Wz26H+2IcNK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777361167; c=relaxed/simple; bh=YWRUd4heg5IXUUK1KP4BqTTd/UwrKs+7Ndtm4/Y7y5k=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=mVqBTIWJai161y0YGBC9OWEaaHfGR29kdKxnYx8WFXM8W7bS2bHsLOb48oG51HuLknaFbFTUw261TF2WGBlHrFQ0SYRaJ9pcdQZJlAkopDYaTGduiZskOW6XdIAR3oWMSqapbXaM5Ig3SZkd2oLEOiByMTOIu6y93Vl8FQzkI1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ege1towQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=inrSRtlj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ege1towQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="inrSRtlj" Date: Tue, 28 Apr 2026 07:26:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777361164; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ltu7BnxHA46I9MqGFRDAlDjfuibbM+P8lpm5H2fDUks=; b=Ege1towQXS7QnaKsSlvVd3E74FuCLGY5LGlW5Y8CEQHRC/tWgtMRYhYcAKXFqL1tU6F2eM Jm3aBDxgqaoEiDgf59uL92eORp3GTZl2xuXiGIUaBIC/mPRJoTEAsrvFmwChUCqCLOYwJu 0ir25i8aElusSCZeddyUydI3xW4rcAbD7Rlv5gczPu2lMZp9kWbHqcmhx1CHaBX4toFRKm TUrIYD+H/A++lrBAYA4TsHyvOwTpQawrBZSsJF2On+IfIQGeT/BzvMdrCr2lSTLMnalqJL 1/Hly4z7o4L2a3e/EP6SKyv53O6BVM+Rq5rVGQ2ZTDgCqm7mCvdMzSN6keSPhg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777361164; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ltu7BnxHA46I9MqGFRDAlDjfuibbM+P8lpm5H2fDUks=; b=inrSRtljK+wFnMv6T89udgr4MfiC/AevdIqMy7RB7DQ5Szfdekm27NIGGZT1Z22ziDeB91 hilsdUBL7vDKCoDg== From: "tip-bot2 for Vincent Guittot" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix wakeup_preempt_fair() vs delayed dequeue Cc: Vincent Guittot , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260422093400.319251-1-vincent.guittot@linaro.org> References: <20260422093400.319251-1-vincent.guittot@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177736116339.3521451.16868557879769343251.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/urgent branch of tip: Commit-ID: ac8e69e693631689d74d8f1ebee6f84f737f797f Gitweb: https://git.kernel.org/tip/ac8e69e693631689d74d8f1ebee6f84f7= 37f797f Author: Vincent Guittot AuthorDate: Wed, 22 Apr 2026 11:34:00 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 28 Apr 2026 09:19:54 +02:00 sched/fair: Fix wakeup_preempt_fair() vs delayed dequeue Similar to how pick_next_entity() must dequeue delayed entities, so too must wakeup_preempt_fair(). Any delayed task being found means it is eligible and hence past the 0-lag point, ready for removal. Worse, by not removing delayed entities from consideration, it can skew the preemption decision, with the end result that a short slice wakeup will not result in a preemption. tip/sched/core tip/sched/core +this patch cyclictest slice (ms) (default)2.8 8 8 hackbench slice (ms) (default)2.8 20 20 Total Samples | 22559 22595 22683 Average (us) | 157 64( 59%) 59( 8%) Median (P50) (us) | 57 57( 0%) 58(- 2%) 90th Percentile (us) | 64 60( 6%) 60( 0%) 99th Percentile (us) | 2407 67( 97%) 67( 0%) 99.9th Percentile (us) | 3400 2288( 33%) 727( 68%) Maximum (us) | 5037 9252(-84%) 7461( 19%) Fixes: f12e148892ed ("sched/fair: Prepare pick_next_task() for delayed dequ= eue") Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260422093400.319251-1-vincent.guittot@lina= ro.org --- kernel/sched/fair.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 615861d..7289658 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1104,7 +1104,7 @@ static inline void cancel_protect_slice(struct sched_= entity *se) * * Which allows tree pruning through eligibility. */ -static struct sched_entity *__pick_eevdf(struct cfs_rq *cfs_rq, bool prote= ct) +static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq, bool protect) { struct rb_node *node =3D cfs_rq->tasks_timeline.rb_root.rb_node; struct sched_entity *se =3D __pick_first_entity(cfs_rq); @@ -1175,11 +1175,6 @@ found: return best; } =20 -static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq) -{ - return __pick_eevdf(cfs_rq, true); -} - struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) { struct rb_node *last =3D rb_last(&cfs_rq->tasks_timeline.rb_root); @@ -5754,11 +5749,11 @@ static int dequeue_entities(struct rq *rq, struct s= ched_entity *se, int flags); * 4) do not run the "skip" process, if something else is available */ static struct sched_entity * -pick_next_entity(struct rq *rq, struct cfs_rq *cfs_rq) +pick_next_entity(struct rq *rq, struct cfs_rq *cfs_rq, bool protect) { struct sched_entity *se; =20 - se =3D pick_eevdf(cfs_rq); + se =3D pick_eevdf(cfs_rq, protect); if (se->sched_delayed) { dequeue_entities(rq, se, DEQUEUE_SLEEP | DEQUEUE_DELAYED); /* @@ -9032,7 +9027,7 @@ static void wakeup_preempt_fair(struct rq *rq, struct= task_struct *p, int wake_f { enum preempt_wakeup_action preempt_action =3D PREEMPT_WAKEUP_PICK; struct task_struct *donor =3D rq->donor; - struct sched_entity *se =3D &donor->se, *pse =3D &p->se; + struct sched_entity *nse, *se =3D &donor->se, *pse =3D &p->se; struct cfs_rq *cfs_rq =3D task_cfs_rq(donor); int cse_is_idle, pse_is_idle; =20 @@ -9143,11 +9138,17 @@ static void wakeup_preempt_fair(struct rq *rq, stru= ct task_struct *p, int wake_f } =20 pick: + nse =3D pick_next_entity(rq, cfs_rq, preempt_action !=3D PREEMPT_WAKEUP_S= HORT); + /* If @p has become the most eligible task, force preemption */ + if (nse =3D=3D pse) + goto preempt; + /* - * If @p has become the most eligible task, force preemption. + * Because p is enqueued, nse being null can only mean that we + * dequeued a delayed task. */ - if (__pick_eevdf(cfs_rq, preempt_action !=3D PREEMPT_WAKEUP_SHORT) =3D=3D= pse) - goto preempt; + if (!nse) + goto pick; =20 if (sched_feat(RUN_TO_PARITY)) update_protect_slice(cfs_rq, se); @@ -9184,7 +9185,7 @@ again: =20 throttled |=3D check_cfs_rq_runtime(cfs_rq); =20 - se =3D pick_next_entity(rq, cfs_rq); + se =3D pick_next_entity(rq, cfs_rq, true); if (!se) goto again; cfs_rq =3D group_cfs_rq(se);