From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 79AFB259C82 for ; Mon, 8 Jun 2026 12:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780922847; cv=none; b=ll7/SNuf1cCCv5EEz+Vs7XEHgn1AlMtNjc4NmH19XeXXzfM34Np3uz3AWQEOQIyzjoZRquJTiQzZjY3cB9LDZjDkiLTGap7puMdhMiL3/wq4k8ySFMX9vY+rrcFuz0d7tiynQaGzKQ9vgliwbt57OLNA2fVTzSJYyzISdT1Iff8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780922847; c=relaxed/simple; bh=0OJPyCwJgXTPDPaVObwgq4Blszz/85fmSrMQsJ1gBpQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DlWvFTXMxCua5QlBZLM4NJyDMJRnPXdIlQjQtFXSHCHzWaHzb/paA9uS3tq31el83QePjYQi652mTroPwrhBMoIa4D0PEiUM/UwE4MbIg6ScRCytFqZymZEqzefaKOSggvlJ1xQ0CVulkqH6gaPf0/hp3abw0CwzURKlOXDeJEM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nzV/uSvy; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nzV/uSvy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780922840; x=1812458840; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=0OJPyCwJgXTPDPaVObwgq4Blszz/85fmSrMQsJ1gBpQ=; b=nzV/uSvyuGzOh37YsnOFbdMqqCCoHqT9qVdmydSrS9WJ9U49iSXV/bGK PP1c1hymGD5yYrWOcO/k4GWqcBPllt+/p/cNt1CKVvaa3P0zJ91lLhSJK qqK8NlQ1JfzTu/xKozGkbg8xOMsihbQC+hffYwQLAnj4cMJleCgU7VtrO aVsr6IbR1W2Z/mw/d0h0IqrkjggD3c/qibKsWcCvsKUt6mrN4/SOlRrfc T8dCVVoD0JWysFN0+6xFeLn8/K/ViZv6WVPaPmlCfSLOAGGLbeZ1aWdmk 4z0+RkhZZhAZYXXngJfpzDXqTsoESNRjoIYmE2BaZYTNUhHdNoOVHVkZp Q==; X-CSE-ConnectionGUID: ebk8pKygS16/zd+aTz9s9A== X-CSE-MsgGUID: gs+u3C+XQwqrtsWft3rdlQ== X-IronPort-AV: E=McAfee;i="6800,10657,11810"; a="85281937" X-IronPort-AV: E=Sophos;i="6.24,194,1774335600"; d="scan'208";a="85281937" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2026 05:47:15 -0700 X-CSE-ConnectionGUID: ZbMgKTkaRIKMIbKPsKZF5Q== X-CSE-MsgGUID: bXyvIGIUR1aS02lyJ5vg1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,194,1774335600"; d="scan'208";a="247409320" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by fmviesa004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2026 05:47:15 -0700 From: Ricardo Neri Date: Mon, 08 Jun 2026 05:57:15 -0700 Subject: [PATCH v4 5/6] sched/fair: Allow load balancing between CPUs of identical capacity Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260608-rneri-fix-cas-clusters-v4-5-1526711c944c@linux.intel.com> References: <20260608-rneri-fix-cas-clusters-v4-0-1526711c944c@linux.intel.com> In-Reply-To: <20260608-rneri-fix-cas-clusters-v4-0-1526711c944c@linux.intel.com> To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Tim C Chen , Chen Yu , Christian Loehle , Barry Song Cc: "Rafael J. Wysocki" , Andrea Righi , K Prateek Nayak , Len Brown , ricardo.neri@intel.com, linux-kernel@vger.kernel.org, Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780923493; l=2687; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=0OJPyCwJgXTPDPaVObwgq4Blszz/85fmSrMQsJ1gBpQ=; b=DpiAN2TfktJuo6HgO7xiirCrGSVN/8flc96oYGK9WeNErZSoBvYz54VQOpzx2sPyYzJ48YefI Mabx24dcan+D76+jx53a8qrJ/uD2l3YD5CM6o0sSolVkAqrH2zvu6I2 X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= sched_balance_find_src_rq() avoids selecting a runqueue with a single running task as busiest if doing so results in migrating the task to a CPU with less than ~5% of extra capacity. It also unintentionally prevents migrations between CPUs of identical capacity. When CONFIG_SCHED_CLUSTER is enabled, load should be balanced across clusters of CPUs with the same capacity. Allowing migration between CPUs of identical capacity is necessary to meet this goal. Use arch_scale_cpu_capacity() to reflect architectural capacity, excluding runtime reductions due to side activity or thermal pressure. Guard this check with the sched_cluster_active static key so that systems without cluster topology are unaffected. Signed-off-by: Ricardo Neri --- Changes in v4: * Implemented the check for cluster with a local variable for improved readability. Changes in v3: * Reverted the inverted capacity check; the inverted form incorrectly allows migrations to CPUs of slightly less capacity. * Guarded the check for architectural capacity with the sched_cluster_active static key. Changes in v2: * Used arch_scale_cpu_capacity() instead of capacity_of() to ignore runtime variability. * Inverted the check for runtime capacity. (Christian) * Reworded patch description for clarity. --- kernel/sched/fair.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 77554d7410ff..74b9669d149b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12939,6 +12939,9 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env, int i; for_each_cpu_and(i, sched_group_span(group), env->cpus) { + bool same_arch_cluster = static_branch_unlikely(&sched_cluster_active) && + (arch_scale_cpu_capacity(env->dst_cpu) == + arch_scale_cpu_capacity(i)); bool smt_degraded_cap = sched_smt_active() && !is_core_idle(i); unsigned long capacity, load, util; unsigned int nr_running; @@ -12983,9 +12986,13 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env, * * Busy SMT siblings reduce the capacity of CPU i. Do not skip * it in this case. + * + * CONFIG_SCHED_CLUSTER requires balancing load across clusters + * of identical capacity. Use architectural capacity to ignore + * runtime variability. */ if (env->sd->flags & SD_ASYM_CPUCAPACITY && - !smt_degraded_cap && + !smt_degraded_cap && !same_arch_cluster && !capacity_greater(capacity_of(env->dst_cpu), capacity) && nr_running == 1) continue; -- 2.43.0