From nobody Mon Jun 8 15:38:17 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 81C713AFD0B; Thu, 28 May 2026 09:42:05 +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=1779961327; cv=none; b=SwDCbio+0LgUZwksrJ/HZrPmVodG30DoVoqMeiwWoxQ0Za8i1L9f84+yVjxgp6c/IU70/F221BalYlzYOdjYeMvZoozzDIUGHypDDyww1BpEBsvEEiHaTIKZu0IebPZeXRw2mpvmxVUW6uAgu6o06W0e5rmYvGUiaejW/TJ8xQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779961327; c=relaxed/simple; bh=XDbLOWdk/XGsY7gTPHJe/iK5g+ePJWA85rYLrOAlXtM=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=keoUOe54b5McKTzVRU02vm5gXiHXDFVShU8IdkEmcb/ftuuvvMJpkjB0gzNTKUyxDRIw/FHosiGYp9jG/jsTl3m5e9MguC65Fnm3XZ/vMrIskIBNTJvepI5vb/EYvUn5Z608JQF9pP8zlJyho1jM0dtA+rTDVaKa5ks3O5FEkjo= 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=wj4GjLlR; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aN3L3YyQ; 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="wj4GjLlR"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aN3L3YyQ" Date: Thu, 28 May 2026 09:42:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779961323; 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=7i5Y1I2bUibZyinOJ7ISM30g+SvCvfPZwMvArhfIo4E=; b=wj4GjLlRUP+0K6sCaa7X/0ODPdPgf4/V5dFUoPg22RO+y5soADA5+Zzz+Z/lhRiBz7b9gW /2Tf6gdpKrBD2j6DT+G+pAHvhOkfaFemLwbdH9ijOiKLZHoYNvoWMWkj8Z1pOdTTrwol7Z 2A3j6VVbP2Z832t0swrJmzexiVu8ROUmfmhdkdEhXsWghi0+pzisG4XBuuWAp8R5HLGO3p UnzGL6xXuGmVxAnfOx+zc0iRkfZg5N6Go0b5P13yLvXmmVgcNzWBkzFrwwrbQO5+oeWnzk 5Kaz7fMGW20PPw+nZ0X9odEVMYJpMBs0MX9JGqDWGQJO2IdPFCrCE7n0RSH3Hw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779961323; 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=7i5Y1I2bUibZyinOJ7ISM30g+SvCvfPZwMvArhfIo4E=; b=aN3L3YyQFBHztwMnmUescRBjc5q70MxFjeElqHGAi9qrm44hQVlxqXev+Sx5emYnYodG7A zojgFmd9WEY5TQBA== From: "tip-bot2 for Peter Zijlstra" 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: Add newidle balance to pick_task_fair() Cc: "Peter Zijlstra (Intel)" , Vincent Guittot , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260511120627.944705718@infradead.org> References: <20260511120627.944705718@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177996132208.1039918.216868859369015344.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: b3a2dfa8b42e5b97dd144aa59374f4e045725cac Gitweb: https://git.kernel.org/tip/b3a2dfa8b42e5b97dd144aa59374f4e04= 5725cac Author: Peter Zijlstra AuthorDate: Mon, 11 May 2026 13:31:12 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 26 May 2026 13:53:13 +02:00 sched/fair: Add newidle balance to pick_task_fair() With commit 50653216e4ff ("sched: Add support to pick functions to take rf") removing the balance callback, the pick_task() callback is in charge of newidle balancing. This means pick_task_fair() should do so too. This hasn't been a problem in practise because pick_next_task_fair() is used. However, since we'll be removing that one shortly, make sure pick_next_task() is up to scratch. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Vincent Guittot Link: https://patch.msgid.link/20260511120627.944705718@infradead.org --- kernel/sched/fair.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8e858ca..5f48af7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9863,16 +9863,18 @@ preempt: } =20 static struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *= rf) + __must_hold(__rq_lockp(rq)) { struct sched_entity *se; struct cfs_rq *cfs_rq; struct task_struct *p; bool throttled; + int new_tasks; =20 again: cfs_rq =3D &rq->cfs; if (!cfs_rq->nr_queued) - return NULL; + goto idle; =20 throttled =3D false; =20 @@ -9893,6 +9895,14 @@ again: if (unlikely(throttled)) task_throttle_setup_work(p); return p; + +idle: + new_tasks =3D sched_balance_newidle(rq, rf); + if (new_tasks < 0) + return RETRY_TASK; + if (new_tasks > 0) + goto again; + return NULL; } =20 static void __set_next_task_fair(struct rq *rq, struct task_struct *p, boo= l first); @@ -9904,12 +9914,12 @@ pick_next_task_fair(struct rq *rq, struct task_stru= ct *prev, struct rq_flags *rf { struct sched_entity *se; struct task_struct *p; - int new_tasks; =20 -again: p =3D pick_task_fair(rq, rf); + if (unlikely(p =3D=3D RETRY_TASK)) + return p; if (!p) - goto idle; + return p; se =3D &p->se; =20 #ifdef CONFIG_FAIR_GROUP_SCHED @@ -9959,29 +9969,11 @@ simple: #endif /* CONFIG_FAIR_GROUP_SCHED */ put_prev_set_next_task(rq, prev, p); return p; - -idle: - if (rf) { - new_tasks =3D sched_balance_newidle(rq, rf); - - /* - * Because sched_balance_newidle() releases (and re-acquires) - * rq->lock, it is possible for any higher priority task to - * appear. In that case we must re-start the pick_next_entity() - * loop. - */ - if (new_tasks < 0) - return RETRY_TASK; - - if (new_tasks > 0) - goto again; - } - - return NULL; } =20 static struct task_struct * fair_server_pick_task(struct sched_dl_entity *dl_se, struct rq_flags *rf) + __must_hold(__rq_lockp(dl_se->rq)) { return pick_task_fair(dl_se->rq, rf); }