From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 7F00E3A1A35 for ; Thu, 14 May 2026 18:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778783054; cv=none; b=BuJBPTXZhGBzsq0ip/7JSfJoVPTDfAZHE1D2wZO6Wrjb0sPFf1EBvQRF101kB0zpMxSdFvJZK1QcAIiUsc3bS5eQQC6aKhGzQ6fbFmBDrbLf1EBXSTp+pophzZPq5pGTwPQ4LRfN8/c9WQQcRu6sazOUhMD3OCXey2O6FbihhAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778783054; c=relaxed/simple; bh=Y5BzhH7DNlJSh12M1xMRKWnp/u0MEradRqFK7fJVqKg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p2lW31qtFggF1CydNPuyu128JBH/qZsI5U0Obrcom4xDZutVan2ZP6wjmdwdGQww6qkBGmkkoQcyGULzcAwyRwwg5eHPKu19n6OS3452XgZ8cwIwc5xgOzuMg4+XiOPXmtEERWeIh7Yxq2qEQmVcRFeY0Xs1s7w+MdZD4CZaikU= 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=VjTWBuZU; arc=none smtp.client-ip=192.198.163.13 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="VjTWBuZU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778783053; x=1810319053; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Y5BzhH7DNlJSh12M1xMRKWnp/u0MEradRqFK7fJVqKg=; b=VjTWBuZUl225ho9IWwM/vbc4bAUOqWStnkz55aN2qOQ+45AcrvYwdxQd XJX1ThVAYvXQXDtE+8SZ33YeOUF5l99HCeiQ38WAznCj/mxGTmrEHDg4H 9tN7yO8PE1BaiIEgXZ0H4ft+6XkhYZ7AnR5ILaqjFBmme6HfpBEWd6dRx R7JZ+MxU98+2XM3i3Y3Y+BN5yse2wNCV+b+afhEP4Ro0860EeNNhTeF2H BIWKjRz1bgg2BAGoo4m5UjErKHyYSv5l7m2zJ0O0uZ/a9AsSIV4AXycEV 5ApTJKXkILoEpfVGg0WoLWHymKq7KyoUkXk0u8w9UxccIybwlzZcOm9P/ A==; X-CSE-ConnectionGUID: xDx9vMfGS+++WeBnRQXRJw== X-CSE-MsgGUID: 9lA6nFc0Qn+nOVf9H69+6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11786"; a="82303143" X-IronPort-AV: E=Sophos;i="6.23,235,1770624000"; d="scan'208";a="82303143" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2026 11:24:09 -0700 X-CSE-ConnectionGUID: 6bZiSnNMQ2+Z8fg9LNN8tg== X-CSE-MsgGUID: 0i4B5locQ3K/mKKVKiPvvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,235,1770624000"; d="scan'208";a="234181048" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by fmviesa010.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2026 11:24:08 -0700 From: Ricardo Neri Date: Thu, 14 May 2026 11:34:39 -0700 Subject: [PATCH v3 3/4] 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: <20260514-rneri-fix-cas-clusters-v3-3-0037869554bd@linux.intel.com> References: <20260514-rneri-fix-cas-clusters-v3-0-0037869554bd@linux.intel.com> In-Reply-To: <20260514-rneri-fix-cas-clusters-v3-0-0037869554bd@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" , 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=1778783711; l=2208; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=Y5BzhH7DNlJSh12M1xMRKWnp/u0MEradRqFK7fJVqKg=; b=R8a84tVqE5g7KOGM0O+w2u20SFjZhmAc+HycMcd4ebl1XxJPRfR/N4LOXZ8nJx03r/Xp20eZc P9Vz0o3YVCDDcS+ozvVQxrOI106POSitw4rssMS7P0h4arko8zAEyBB 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 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index dcc02ceb44b5..d2a4c529f67f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11846,8 +11846,14 @@ static struct rq *sched_balance_find_src_rq(struct lb_env *env, * eventually lead to active_balancing high->low capacity. * Higher per-CPU capacity is considered better than balancing * average load. + * + * 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 && + (!static_branch_unlikely(&sched_cluster_active) || + arch_scale_cpu_capacity(env->dst_cpu) != arch_scale_cpu_capacity(i)) && !capacity_greater(capacity_of(env->dst_cpu), capacity) && nr_running == 1) continue; -- 2.43.0