From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 7616B401A33 for ; Tue, 21 Jul 2026 02:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784601214; cv=none; b=CsGxdLPYlW7sEozorxsZ5/9YGxK3yjVjtVLtZByZn1XDLp9cjNYF+pUHv45Zcy1WKSlzB9EUQ78yFyiE4dc3L0QsNgd1JaqExb7hAu3CcCma3xqTO/S3efMJ1gBTzehx0siYcDxvddps8kiTikBXd3i7QaKfNDCzBPb6KlSogqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784601214; c=relaxed/simple; bh=jvZf4EC9qkymG2egqu7JR/C8hUMi4y2Ooveld4Tw2Ys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DXSLoUQkb8c2LF5/Uxpa7N1NtDJrruz+Aaw23un3Xb9r02UaOvXCfASXdyGZy2gMPyvlYs+9+Ui8kuIoQ7Yx/DD/hKFLjy7lF/W99GLb7T0Vs3rrhfGSVsu1AwLKAz/mVWdFCVzykPYEZH51psLttn95lHHUgocKQel/5HD5zhE= 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=IM4fU3oM; arc=none smtp.client-ip=192.198.163.11 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="IM4fU3oM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784601204; x=1816137204; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=jvZf4EC9qkymG2egqu7JR/C8hUMi4y2Ooveld4Tw2Ys=; b=IM4fU3oMNcrz8Eu7VW6TrNAY1Bf+BZ7fteftrrAQcLuJQy8kNtefaRvk D1ZSTNbd7hrzjLN+nLyVDQElnYRlDH/OXS5bBs5eqC1+JmgEBAJF0GRGo L/hw0iXFfUVY7Mx0nTPF4l06QydICvYlly96ISR5e0IqjNVRPhvtVVWty iQX5pkxd2sBupZb9V0GOm6UmnWPqtO3XS+18NSxFKupQgDysQWT22Ybf8 TvPjhMy9Gajb6HCDJg9aeK7CK60g6AOK6+hpjGbCMpzjfJdw1AyLP693t EWl3bMAG9Tywkzm4epet9ZjjuTaZK/FmnRZgbEp/YpNnjXuBkSjeDetlC Q==; X-CSE-ConnectionGUID: Oo+gte9fRACkEcoBaZlPUw== X-CSE-MsgGUID: Co7X+9+GRua9d/hUXsJdFw== X-IronPort-AV: E=McAfee;i="6800,10657,11852"; a="95785729" X-IronPort-AV: E=Sophos;i="6.25,175,1779174000"; d="scan'208";a="95785729" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2026 19:33:20 -0700 X-CSE-ConnectionGUID: I/Q5a6eKSFGJD54DZMA9cA== X-CSE-MsgGUID: K9/6RSFIS9a0xttlX6O9wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,175,1779174000"; d="scan'208";a="257682279" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2026 19:33:19 -0700 From: Ricardo Neri Date: Mon, 20 Jul 2026 19:43:21 -0700 Subject: [PATCH v6 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: <20260720-rneri-fix-cas-clusters-v6-5-bb500bf4afd4@linux.intel.com> References: <20260720-rneri-fix-cas-clusters-v6-0-bb500bf4afd4@linux.intel.com> In-Reply-To: <20260720-rneri-fix-cas-clusters-v6-0-bb500bf4afd4@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 , K Prateek Nayak , Andrea Righi , Barry Song Cc: "Rafael J. Wysocki" , 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=1784601848; l=3061; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=jvZf4EC9qkymG2egqu7JR/C8hUMi4y2Ooveld4Tw2Ys=; b=NCsKhy9+Uu1+fZK3SJRHOxjuuIWjvECL168sMtc76UJWDdnoEm8M32eEwRRauRgj8uPlKv1o0 ABwxmE4fgDwCkOUkqOoqcT2i+BwN+aWRL8NS/sR+cRmdIks3x537/lB 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 get_actual_cpu_capacity() to reflect architectural capacity as well as diminished capacity due to hardware or cpufreq pressure. Guard this check with the sched_cluster_active static key so that systems without cluster topology are unaffected. Tested-by: Christian Loehle Tested-by: Andrea Righi Signed-off-by: Ricardo Neri --- Changes in v6: * Switched to use get_actual_cpu_capacity() instead of arch_scale_cpu_capacity(). The former considers rq->avg_hw.load_avg and cpufreq_pressure and their impact on CPU capacity. (Vincent) * Renamed the variable same_arch_cluster as cluster_equal_cap for clarity. (Andrea) * Added Tested-by tag from Andrea. Thanks! Changes in v5: * Optimized logic to identify same-arch clusters only when needed. * Added Tested-by tag from Christian. Thanks! 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 feea47e6abea..de4189b562ac 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -13104,13 +13104,20 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env, */ if (env->sd->flags & SD_ASYM_CPUCAPACITY && nr_running == 1) { + bool cluster_equal_cap = static_branch_unlikely(&sched_cluster_active) && + (get_actual_cpu_capacity(env->dst_cpu) == + get_actual_cpu_capacity(i)); bool smt_degraded_cap = sched_smt_active() && !is_core_idle(i); /* * 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, accounting for + * hardware and cpufreq pressure. */ - if (!smt_degraded_cap && + if (!smt_degraded_cap && !cluster_equal_cap && !capacity_greater(capacity_of(env->dst_cpu), capacity)) continue; } -- 2.43.0