From mboxrd@z Thu Jan 1 00:00:00 1970 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 145F0263F5E; Tue, 30 Jun 2026 09:03:48 +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=1782810242; cv=none; b=a+23WgDTg8bge72fFCI58KrCJV4Gkl7HOELmGIn9FmfO1VzUA19JF/3gA2fyg+iMte5eFL9TenCG6xWo1xYH1GQP1570BMmqextEeoxt6ns64ZKeg/hMQm433XU85fFRoa0hzSb0NyXDv0NIjgjX7zsGmRKrmGw+3KAKd6brw1c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810242; c=relaxed/simple; bh=3JurhS8X9Jqpg6UfQs916yEbSrTIAxECgA22BM5umUQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=JsAy03L0C6whDc0Lhz6r2exmsDGrGNr7eqeYfJdgA33gQTa6bESfJmSlz10lDgcFI9QcXikYn5mxsbT3aATiiUKq0wtlpjGmIr8XabAqqMVDX5wkiZb9G0Mp9rllqwlVfQmoJcxSjAThl3H+EaxW4lRIZ9l47xGvcJtu6XSBFgM= 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=fKwG7wkP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=h2hil0dO; 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="fKwG7wkP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="h2hil0dO" Date: Tue, 30 Jun 2026 09:03:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782810227; 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=Bt+bXyP9hzVqB8pWAY+FHZqR9g2/5mVFqnDtLEMsalE=; b=fKwG7wkP8N/tmVkBBn6FPJ/U4ZOjx/h13RjIRTM4HIqdshQ33Fs+nAd/z15G+SLDPU8iFM E/nT0kSPZ3FhMtNXaaBGG7Zf3tikKBPX+mUw92D42CRtEmZVFYPq2yc+R1vov2RjKtNmjB kxNToJ9zFwOdnyJguYDioD2FrI4CSIrc7EG0wZ23zzqFbjvDE6Ez9CQgz/pYG54wSKyaFv Z/jgcSuyobOKXJZ50h7xioK8xvy538QmobHS68luBaTPsX5pTCgsWRfYVvxQYigTHbZ03w X2u2HcUTl66IRxvNSQ7dr3EIZGcRmCiUiOIu5GhqO9Avw1ytyAnDwmNdggVGcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782810227; 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=Bt+bXyP9hzVqB8pWAY+FHZqR9g2/5mVFqnDtLEMsalE=; b=h2hil0dOrRYgiE+x7xb4zlPl3uSJMwdZEc1u7oE8v+FWD50QRgtjGzFk6Qim5fjnkqtzqN 3VGGuU97mEuj5JAQ== 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/core] sched/fair: Set next buddy for preempt short Cc: Vincent Guittot , "Peter Zijlstra (Intel)" , K Prateek Nayak , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260624151229.1710703-2-vincent.guittot@linaro.org> References: <20260624151229.1710703-2-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: <178281022631.3843924.15673295909496337278.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/core branch of tip: Commit-ID: 8f97b627ff1c9b0f2eba71b326ac09326bf6b4ea Gitweb: https://git.kernel.org/tip/8f97b627ff1c9b0f2eba71b326ac09326bf= 6b4ea Author: Vincent Guittot AuthorDate: Wed, 24 Jun 2026 17:12:24 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Jun 2026 10:56:54 +02:00 sched/fair: Set next buddy for preempt short If a shorter slice task can preempt current at wakeup, we make sure that the decision will not be overwritten in between by setting the task as the next buddy. This still implies that the waking task remains eligible when the scheduler will actually pick the next task to run. Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Tested-by: K Prateek Nayak Link: https://patch.msgid.link/20260624151229.1710703-2-vincent.guittot@linar= o.org --- kernel/sched/fair.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 90d7f83..976cc3c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9757,6 +9757,15 @@ static inline bool set_preempt_buddy(struct cfs_rq *cf= s_rq, struct sched_entity=20 return true; } =20 +static inline bool set_short_buddy(struct cfs_rq *cfs_rq, struct sched_entit= y *pse) +{ + if (cfs_rq->next && cfs_rq->next->slice < pse->slice) + return false; + + set_next_buddy(cfs_rq, pse); + return true; +} + /* * WF_SYNC|WF_TTWU indicates the waker expects to sleep but it is not * strictly enforced because the hint is either misunderstood or @@ -9931,7 +9940,7 @@ pick: preempt: if (preempt_action =3D=3D PREEMPT_WAKEUP_SHORT) { cancel_protect_slice(se); - clear_buddies(cfs_rq, se); + set_short_buddy(cfs_rq, pse); } =20 resched_curr_lazy(rq);