From nobody Sun Jun 14 15:53:28 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 69CCF389114; Fri, 3 Apr 2026 12:30:11 +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=1775219412; cv=none; b=uUHiYjhx2bBOmalQ17xz6TqkH2NUhXoNdAsVs5QgY3R/L8NkK/XLQ33KT5TXojZWjN1S885ZUnrOkftTH/42dzbgtIi5HT4daAQ24+Rf/pJi4eBaU/NMT//VzbMIcnceTibtXSevVoat32c8PlRkrxbgDdmL5ok/Q5K9r0mh7Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775219412; c=relaxed/simple; bh=MQjGHpkoJb3+1tDsjD8Kf0OdV8UKBEpbkOIlrOGHpT4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=TCDy0y6tx9wdzMPIHG/JzbCej+iDYkSQcgr9m/ILMPDx/o477FtGRgorGfmyqKfLtwXwqn0bdm4U1j7wb2N/hWP++Yy4ZCBEwpg7eOQitIyP3EgBkS7c724yNDoLskEhFlMXrqmedmd8X5PE9+b73e8iH0fzvUJgUtnIEEqKI/k= 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=WBRpGtur; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Z34+y0EK; 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="WBRpGtur"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Z34+y0EK" Date: Fri, 03 Apr 2026 12:30:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1775219410; 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=oQaImLqejC3Lr9Ny/mxKbgc+/bulzIpQixWTrJGhZ1g=; b=WBRpGturq0vwdrXFwzdygjsnobz8+4E+kDHRJqXYH3wOWZlZcSICG1l38A1sMMxPJwpE0x tk83tgeNdtPcJlu2B0muWRgfjuz/n0bMnQ/cPvIRNWwh9AxHj8og00bZcs/NISNY8eeBRZ hnV7SWkBrfkiBcIv9xsW1jZdGvSuHAk6VP1GyiWiHr1aQ7RaTeE0ZT6cAvIAdP1gOZCKiD xAYKQXWTB2gJbLo873AUjtGF1C7y7Q1mFixBMT7um4Djz6utMxhksrOXjll3tK3/hQkWgE 0BaL5q/qWh2As7qu4E0meuCPCVQfqDTKr9qgwmGPOIlh4w17UYN50yCN+5a5NA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1775219410; 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=oQaImLqejC3Lr9Ny/mxKbgc+/bulzIpQixWTrJGhZ1g=; b=Z34+y0EKA7i+W8KyljjL3LTE3bCT4+CsbaNbMFd5rEHSEhFFJq167SCBKb+L3yevTozlDN bsafgOBGdvy0SgBw== From: "tip-bot2 for John Stultz" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Move attach_one_task and attach_task helpers to sched.h Cc: K Prateek Nayak , John Stultz , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260324191337.1841376-10-jstultz@google.com> References: <20260324191337.1841376-10-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177521940831.1647592.1007481998020037335.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: dec9554dc036183c715d02e9cfe48986d453427a Gitweb: https://git.kernel.org/tip/dec9554dc036183c715d02e9cfe48986d= 453427a Author: John Stultz AuthorDate: Tue, 24 Mar 2026 19:13:24=20 Committer: Peter Zijlstra CommitterDate: Fri, 03 Apr 2026 14:23:40 +02:00 sched: Move attach_one_task and attach_task helpers to sched.h The fair scheduler locally introduced attach_one_task() and attach_task() helpers, but these could be generically useful so move this code to sched.h so we can use them elsewhere. One minor tweak made to utilize guard(rq_lock)(rq) to simplifiy the function. Suggested-by: K Prateek Nayak Signed-off-by: John Stultz Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: K Prateek Nayak Link: https://patch.msgid.link/20260324191337.1841376-10-jstultz@google.com --- kernel/sched/fair.c | 26 -------------------------- kernel/sched/sched.h | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7f35dd4..41293d5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9947,32 +9947,6 @@ next: } =20 /* - * attach_task() -- attach the task detached by detach_task() to its new r= q. - */ -static void attach_task(struct rq *rq, struct task_struct *p) -{ - lockdep_assert_rq_held(rq); - - WARN_ON_ONCE(task_rq(p) !=3D rq); - activate_task(rq, p, ENQUEUE_NOCLOCK); - wakeup_preempt(rq, p, 0); -} - -/* - * attach_one_task() -- attaches the task returned from detach_one_task() = to - * its new rq. - */ -static void attach_one_task(struct rq *rq, struct task_struct *p) -{ - struct rq_flags rf; - - rq_lock(rq, &rf); - update_rq_clock(rq); - attach_task(rq, p); - rq_unlock(rq, &rf); -} - -/* * attach_tasks() -- attaches all tasks detached by detach_tasks() to their * new rq. */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index a2629d0..9594355 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3012,6 +3012,29 @@ extern void deactivate_task(struct rq *rq, struct ta= sk_struct *p, int flags); =20 extern void wakeup_preempt(struct rq *rq, struct task_struct *p, int flags= ); =20 +/* + * attach_task() -- attach the task detached by detach_task() to its new r= q. + */ +static inline void attach_task(struct rq *rq, struct task_struct *p) +{ + lockdep_assert_rq_held(rq); + + WARN_ON_ONCE(task_rq(p) !=3D rq); + activate_task(rq, p, ENQUEUE_NOCLOCK); + wakeup_preempt(rq, p, 0); +} + +/* + * attach_one_task() -- attaches the task returned from detach_one_task() = to + * its new rq. + */ +static inline void attach_one_task(struct rq *rq, struct task_struct *p) +{ + guard(rq_lock)(rq); + update_rq_clock(rq); + attach_task(rq, p); +} + #ifdef CONFIG_PREEMPT_RT # define SCHED_NR_MIGRATE_BREAK 8 #else