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 B2D2B29CA; Mon, 12 Aug 2024 16:21:15 +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=1723479675; cv=none; b=N2dF4kfcDvABeWprNZT3B2jvqJBsMocif+2lyrx0aRUYeReb9m0svntBH3EffwyR1bfZEX0n7QkCx0Dzv8yV1B9wdkvEDjbKCkCV96fwMcd6RSdGS1h5AC13qPQO1+x+nCnshVriU0zVUINM0BN5EiAJPjIWcMu1ECYSRhin4BQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723479675; c=relaxed/simple; bh=SDEwyiaEOZAHy+t1JwJFR47Ss64PEooQFSJAJPlUa0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uE+jMQoilDSgWx8e8vj/WOXbJt+8AkeadthNQEbbnHHYT3uTW5EUVCubEVRhFp52GVnm/Bm1yZDuS5rbBp4ZzKjM92lkJcmA7xmoBzdrRiDEOzoUNg6FyQVwY0yATUzPhD6eEo94Taw2svjkWh6ugamF1tbxevre5OT7SRrwzas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MmTvhMoN; 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="MmTvhMoN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23ECAC32782; Mon, 12 Aug 2024 16:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723479675; bh=SDEwyiaEOZAHy+t1JwJFR47Ss64PEooQFSJAJPlUa0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmTvhMoNZNNq+5w+dsYZ3y5ftmSUt9WnBN+2TVQ/358d2vIlWsNZxxbzEUNzSj64S k6TTtw8oCNDd/J+UfQvNsrmsP16uODJTzoVyRqmuWkFSBqKE430XCOJeCgAcYKUSLo on0J0WN5nq+mdcziuh4D709e+tN3gTvWFweQlZGU= 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.6 157/189] sched/smt: Introduce sched_smt_present_inc/dec() helper Date: Mon, 12 Aug 2024 18:03:33 +0200 Message-ID: <20240812160138.185470620@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240812160132.135168257@linuxfoundation.org> References: <20240812160132.135168257@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yang Yingliang commit 31b164e2e4af84d08d2498083676e7eeaa102493 upstream. Introduce sched_smt_present_inc/dec() 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-2-yangyingliang@huaweicloud.com Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9646,6 +9646,22 @@ static int cpuset_cpu_inactive(unsigned return 0; } +static inline void sched_smt_present_inc(int cpu) +{ +#ifdef CONFIG_SCHED_SMT + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) + static_branch_inc_cpuslocked(&sched_smt_present); +#endif +} + +static inline void sched_smt_present_dec(int cpu) +{ +#ifdef CONFIG_SCHED_SMT + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) + static_branch_dec_cpuslocked(&sched_smt_present); +#endif +} + int sched_cpu_activate(unsigned int cpu) { struct rq *rq = cpu_rq(cpu); @@ -9657,13 +9673,10 @@ int sched_cpu_activate(unsigned int cpu) */ balance_push_set(cpu, false); -#ifdef CONFIG_SCHED_SMT /* * When going up, increment the number of cores with SMT present. */ - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) - static_branch_inc_cpuslocked(&sched_smt_present); -#endif + sched_smt_present_inc(cpu); set_cpu_active(cpu, true); if (sched_smp_initialized) { @@ -9732,13 +9745,12 @@ int sched_cpu_deactivate(unsigned int cp } rq_unlock_irqrestore(rq, &rf); -#ifdef CONFIG_SCHED_SMT /* * When going down, decrement the number of cores with SMT present. */ - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) - static_branch_dec_cpuslocked(&sched_smt_present); + sched_smt_present_dec(cpu); +#ifdef CONFIG_SCHED_SMT sched_core_cpu_deactivate(cpu); #endif