From nobody Mon Feb 9 23:00:55 2026 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (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 7B52E154C08 for ; Sun, 26 Jan 2025 10:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737886602; cv=none; b=n1r9WZ7CExC81mpnncGaKBcsVJ1q1lGNJ+nTvaut3DADKxkf5pbTr7U6/rSAmTBJKrkVT2gmnb+jYacFCv+KBstyXkyTS/Ttw39Zs6IHMZB943JQvqIEON0X49bdQXjBeg4Cc4GMBNcSjvNRKrArNRFtXql829BI7i3k7kH9g6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737886602; c=relaxed/simple; bh=uL/HlqVUlbYGnkpKOGPui3ph5x4rrtkI8EiNtGBqRTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ji9Fxa2/6gf8P5R/uXq9OKMvXynxmEUoSiRa8Kq5Jy+x0ybShlBHOa+NgzVVoHlvkZgcdwoaVVYN7/E48IoF/+Y1nTRNFxkatSKMBBz9o1OX4UyLzpfn5use8xl1/e9ybAmejLqlYu6JPOE3GBpvvIdaIXINx6EFpOJmP1T4cxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=U5WM6Ivj; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="U5WM6Ivj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=8xwt3cnHOZGh9d64Z5XegGyfq5lcdIzONy9hfckbFns=; b=U5WM6IvjY2/HG2U1D4oCJ00na7 SYlFXd/W1LDlYu7hVo3nzASun0exEaWmlYIP4FjPZhHRD/N9dk/XrSRgXqadUlZ2yccoWngOfEuid 73+FgnQFuLCFrTjVLXHx9I88YNDiDq69ZRgaO7XM2lJF2YBeM+idHHwjo8mrSnkKBvq82ou4y1vHo v9DfSNBfV2mOniO2g6Rebmh4XLm4WXzomDUNzDhuZJJM3dyrjjiPmU/9XDBUGs3wtEPJon24VYxdk 1fKnHADV0dAmHgfhdm1qouMhTJ9Y5mLiiypfhSfEqZD7Z73gMM4rEN5TUQqHGrd5HWyX8BpkRioPG V+ZV3jgw==; Received: from [58.29.143.236] (helo=localhost) by fanzine2.igalia.com with utf8esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tbzgp-002liy-TK; Sun, 26 Jan 2025 11:16:28 +0100 From: Changwoo Min To: tj@kernel.org, void@manifault.com, arighi@nvidia.com Cc: kernel-dev@igalia.com, linux-kernel@vger.kernel.org, Changwoo Min Subject: [PATCH v2 02/11] sched: Move is_cpu_allowed() to the header Date: Sun, 26 Jan 2025 19:16:05 +0900 Message-ID: <20250126101614.232388-3-changwoo@igalia.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250126101614.232388-1-changwoo@igalia.com> References: <20250126101614.232388-1-changwoo@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" is_cpu_allowed() can be used to specific scheduling policies (e.g., sched_ext), so move it to the header. Signed-off-by: Changwoo Min --- kernel/sched/core.c | 30 ------------------------------ kernel/sched/sched.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 901170708e2a..eaaee182999c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2427,36 +2427,6 @@ static inline bool rq_has_pinned_tasks(struct rq *rq) return rq->nr_pinned; } =20 -/* - * Per-CPU kthreads are allowed to run on !active && online CPUs, see - * __set_cpus_allowed_ptr() and select_fallback_rq(). - */ -static inline bool is_cpu_allowed(struct task_struct *p, int cpu) -{ - /* When not in the task's cpumask, no point in looking further. */ - if (!task_allowed_on_cpu(p, cpu)) - return false; - - /* migrate_disabled() must be allowed to finish. */ - if (is_migration_disabled(p)) - return cpu_online(cpu); - - /* Non kernel threads are not allowed during either online or offline. */ - if (!(p->flags & PF_KTHREAD)) - return cpu_active(cpu); - - /* KTHREAD_IS_PER_CPU is always allowed. */ - if (kthread_is_per_cpu(p)) - return cpu_online(cpu); - - /* Regular kernel threads don't get to stay during offline. */ - if (cpu_dying(cpu)) - return false; - - /* But are allowed during online. */ - return cpu_online(cpu); -} - /* * This is how migration works: * diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 38e0e323dda2..30c401d940f4 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2675,6 +2675,36 @@ static inline cpumask_t *alloc_user_cpus_ptr(int nod= e) =20 #endif /* !CONFIG_SMP */ =20 +/* + * Per-CPU kthreads are allowed to run on !active && online CPUs, see + * __set_cpus_allowed_ptr() and select_fallback_rq(). + */ +static inline bool is_cpu_allowed(struct task_struct *p, int cpu) +{ + /* When not in the task's cpumask, no point in looking further. */ + if (!task_allowed_on_cpu(p, cpu)) + return false; + + /* migrate_disabled() must be allowed to finish. */ + if (is_migration_disabled(p)) + return cpu_online(cpu); + + /* Non kernel threads are not allowed during either online or offline. */ + if (!(p->flags & PF_KTHREAD)) + return cpu_active(cpu); + + /* KTHREAD_IS_PER_CPU is always allowed. */ + if (kthread_is_per_cpu(p)) + return cpu_online(cpu); + + /* Regular kernel threads don't get to stay during offline. */ + if (cpu_dying(cpu)) + return false; + + /* But are allowed during online. */ + return cpu_online(cpu); +} + #ifdef CONFIG_CPU_IDLE =20 static inline void idle_set_state(struct rq *rq, --=20 2.48.1