From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA05332C8B for ; Wed, 6 May 2026 10:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778063919; cv=none; b=LJxONOf6lEFbmY7XFiEuA741TAwPzb9TaOHzo73WO6K/FIjBui5hcFZ6Z5Lcej/0DT/xEh0f2G3dbjiUJbiqs66QF+1voR0/uQMRRlW818mEg8cnobUfZtAJEs4EU+5J/QqemKMBrvgONTUPJBA02Wz+M5V79nsL7xsHxN0gSQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778063919; c=relaxed/simple; bh=f8y998Zk9+UZDJj4AAyesAgJypMpG05orZEU9umldIo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jFzY90SlIq7bWkTAilBy5Z9TNVme2wOJpuHlc1IPkNGojLVZlm+naZSquSlefPS4S9hYekA8YWqbP0KMs00vYaVelkaqxiubR68MEmOGJ212JauNBWbqWUhV6qTttmhEG3DJ4Znoz4QMG+PBMVJ/UZy49lVWwApUIqd04hc74zA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=YaabEkzg; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="YaabEkzg" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C60153319; Wed, 6 May 2026 03:38:31 -0700 (PDT) Received: from [10.57.92.61] (unknown [10.57.92.61]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7395A3F836; Wed, 6 May 2026 03:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778063917; bh=f8y998Zk9+UZDJj4AAyesAgJypMpG05orZEU9umldIo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YaabEkzgU98sKWXUBVZu1R6v5M3iEtGv0SqtNGYKAoM1vzhPySGWm7go/Y3AqJhHd cfl7XIM3OUVtSZYAkHQmq9//F2Ev70Be1WnFC/f2wSYb5Qgcb6VG0QajFmETSGhSl7 Yclk2SluwV/Ym5K2jtyM/CfrzDWfxVIdcEZsut/s= Message-ID: <099ca076-18b3-40af-9488-1fd0f4cdbac4@arm.com> Date: Wed, 6 May 2026 11:38:31 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] sched/fair: Check CPU capacity before comparing group types during load balance To: Ricardo Neri , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Tim C Chen , Chen Yu , Barry Song Cc: "Rafael J. Wysocki" , Len Brown , ricardo.neri@intel.com, linux-kernel@vger.kernel.org, Andrea Righi References: <20260429-rneri-fix-cas-clusters-v2-0-cd787de35cc6@linux.intel.com> <20260429-rneri-fix-cas-clusters-v2-1-cd787de35cc6@linux.intel.com> Content-Language: en-US From: Christian Loehle In-Reply-To: <20260429-rneri-fix-cas-clusters-v2-1-cd787de35cc6@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/29/26 22:19, Ricardo Neri wrote: > update_sd_pick_busiest() may incorrectly select a fully_busy group as the > busiest group when its per-CPU capacity exceeds that of the destination > CPU. This happens because the type of busiest group is initialized to > group_has_spare and allows the fully_busy group to win the type comparison. > > update_sd_pick_busiest() should not choose a candidate scheduling group > with at most one runnable task if its per-CPU capacity is greater than that > of the destination CPU. Such a check already exists, but it is done too > late: after the type comparison, preventing a subsequent fully_busy group > of equal per-CPU capacity from being correctly selected. > > Move this check to occur before comparing group types. > > Signed-off-by: Ricardo Neri > --- > Changes since v1: > * Added a note clarifying that SMT and SD_ASYM_CPUCAPACITY are mutually > exclusive. (Tim) > * Kept parentheses around bitwise operators for clarity. > * Rewrote patch description for clarity. > --- > kernel/sched/fair.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 728965851842..0dbed82aa63f 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10788,6 +10788,20 @@ static bool update_sd_pick_busiest(struct lb_env *env, > sds->local_stat.group_type != group_has_spare)) > return false; > > + /* > + * Candidate sg has no more than one task per CPU and has higher > + * per-CPU capacity. Migrating tasks to less capable CPUs may harm > + * throughput. Maximize throughput, power/energy consequences are not > + * considered. > + * > + * Systems with SMT are unaffected, as asymmetric capacity is not set > + * in such case. > + */ > + if ((env->sd->flags & SD_ASYM_CPUCAPACITY) && > + (sgs->group_type <= group_fully_busy) && > + (capacity_greater(sg->sgc->min_capacity, capacity_of(env->dst_cpu)))) > + return false; > + > if (sgs->group_type > busiest->group_type) > return true; > > @@ -10890,17 +10904,6 @@ static bool update_sd_pick_busiest(struct lb_env *env, > break; > } > > - /* > - * Candidate sg has no more than one task per CPU and has higher > - * per-CPU capacity. Migrating tasks to less capable CPUs may harm > - * throughput. Maximize throughput, power/energy consequences are not > - * considered. > - */ > - if ((env->sd->flags & SD_ASYM_CPUCAPACITY) && > - (sgs->group_type <= group_fully_busy) && > - (capacity_greater(sg->sgc->min_capacity, capacity_of(env->dst_cpu)))) > - return false; > - > return true; > } > > I think it deserves a Fixes, but nonetheless: Reviewed-by: Christian Loehle I've CCed Andrea, just because of this SMT -> !SD_ASYM_CPUCAPACITY currently being up for debate...