From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 29AF5183CD4; Mon, 12 Aug 2024 16:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723480584; cv=none; b=NuYZOnOH8OSosKnheWenjgCRWmU+Nth86UZtghqUJC4MzvXRq6yl3XGSrT642Re5Zx8VNNUlIG27zi2nTwGWkr6citJVArDyBl7sCyl9+4s0ZcSPwupOdqZQBt4zdWOn5DADxKCjqCl7+5KtOS9JZIfYFqj/9Yzy26IeK3YIgic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723480584; c=relaxed/simple; bh=YLbBv7kKyR6NWr2I6H0tlrHdk8KSFA4dBdd1kw3FGVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=txQekCz9+qqiYOUS5DGdjLbJmuCaeSYB5pyzlpA/WfElvaHTki1068XC5y2hQPCXJsISsj0m0VvA7gGNSJd9TpVXLQ8sjzHQ2YTXStxyZW4KaRsthK5laStJihe5bsaPePiYgm52dGb42ollnyeAybtUAD7ReUc9T+xoG6cT+rs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HtwIL38h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HtwIL38h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86521C32782; Mon, 12 Aug 2024 16:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723480584; bh=YLbBv7kKyR6NWr2I6H0tlrHdk8KSFA4dBdd1kw3FGVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HtwIL38hiKF0DfAM1XpZxfY8uIOzpmfLsyVwC6AXK6nFTyMbM2ONM23WllClFSIux ewv+jg5FT8mgrv+ysLi7ySTpr1Bn8dlfo5+jyqtN73joO4bq3KGtdc3AFt+cP2SScO +bocjlQOC9HT78EJ5OeJ+KY4iE2SNWd1LrQSMCUk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Yang Yingliang , "Peter Zijlstra (Intel)" Subject: [PATCH 6.10 240/263] sched/core: Introduce sched_set_rq_on/offline() helper Date: Mon, 12 Aug 2024 18:04:01 +0200 Message-ID: <20240812160155.722750958@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812160146.517184156@linuxfoundation.org> References: <20240812160146.517184156@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yang Yingliang commit 2f027354122f58ee846468a6f6b48672fff92e9b upstream. Introduce sched_set_rq_on/offline() helper, so it can be called in normal or error path simply. No functional changed. Cc: stable@kernel.org Signed-off-by: Yang Yingliang Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20240703031610.587047-4-yangyingliang@huaweicloud.com Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9604,6 +9604,30 @@ void set_rq_offline(struct rq *rq) } } +static inline void sched_set_rq_online(struct rq *rq, int cpu) +{ + struct rq_flags rf; + + rq_lock_irqsave(rq, &rf); + if (rq->rd) { + BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); + set_rq_online(rq); + } + rq_unlock_irqrestore(rq, &rf); +} + +static inline void sched_set_rq_offline(struct rq *rq, int cpu) +{ + struct rq_flags rf; + + rq_lock_irqsave(rq, &rf); + if (rq->rd) { + BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); + set_rq_offline(rq); + } + rq_unlock_irqrestore(rq, &rf); +} + /* * used to mark begin/end of suspend/resume: */ @@ -9673,7 +9697,6 @@ static inline void sched_smt_present_dec int sched_cpu_activate(unsigned int cpu) { struct rq *rq = cpu_rq(cpu); - struct rq_flags rf; /* * Clear the balance_push callback and prepare to schedule @@ -9702,12 +9725,7 @@ int sched_cpu_activate(unsigned int cpu) * 2) At runtime, if cpuset_cpu_active() fails to rebuild the * domains. */ - rq_lock_irqsave(rq, &rf); - if (rq->rd) { - BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); - set_rq_online(rq); - } - rq_unlock_irqrestore(rq, &rf); + sched_set_rq_online(rq, cpu); return 0; } @@ -9715,7 +9733,6 @@ int sched_cpu_activate(unsigned int cpu) int sched_cpu_deactivate(unsigned int cpu) { struct rq *rq = cpu_rq(cpu); - struct rq_flags rf; int ret; /* @@ -9746,12 +9763,7 @@ int sched_cpu_deactivate(unsigned int cp */ synchronize_rcu(); - rq_lock_irqsave(rq, &rf); - if (rq->rd) { - BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); - set_rq_offline(rq); - } - rq_unlock_irqrestore(rq, &rf); + sched_set_rq_offline(rq, cpu); /* * When going down, decrement the number of cores with SMT present.