From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 596C8165F16 for ; Wed, 6 May 2026 23:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778110627; cv=none; b=Dzk2gjc5ynaqIHV2y2tVNMfgl5fWomWoPAM3ctVOm8LbR3PH5BjWRzti0gi1+YtyL89JZ6o/upB7yi0uUnC++JEj4lH0y/NHFGkyhjrdtB0u3ns0li5Sdw3eGIZAQ4p6H3GFjrs1qe2OKBKoJI4rGNeRPfZkiGyBtzqY4LWioHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778110627; c=relaxed/simple; bh=Tko4uJCVJzpDmNxNm/PrElWx1rZWhphkPOgX60TE6Q0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LN9udW0Scm7t1j50xBzQZ5azNV+HlI7AcQr40n4cM5xfHCoay7w/nHcCpkt5fKRicG++xYSit4UFC0gYh38rM8ZsFYERB8oAxkIBIfQ514i9nMWwwTNU/SVOgz7LLTXtDEZyGKMUDv88jqRGQTfop+Pji0k03wjS8yK5yDHKIG8= 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=nqNiaf9I; arc=none smtp.client-ip=192.198.163.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="nqNiaf9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778110625; x=1809646625; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Tko4uJCVJzpDmNxNm/PrElWx1rZWhphkPOgX60TE6Q0=; b=nqNiaf9I2PxSCLH36p/igQ8UaYSMAw748mX8pMUNXxV0ZXFpgu1s6M3+ qWolBFSFRJSfzzfXThkbphK3PRsXa3reVODS0jtE16+f0dPPQ+4DYwA3j Vyj+iUDZAlz0/Y1QX6XiMk8aHCFP5C8/hrwcs/C305U66T9nu5F4GQNSz TeUP120VTWxRhgu8KRIpif7EVXY0mE5cmIf01nPxJBQl6Bxio53EfoIRB s5ZfBbOmd4Cg1TUa+z/edp+RYvfvyhYDu2XPK6NYXMtFOuz2UxKn+zbPC rPc+J+FldH2hq7Ev6iwsS/SFblFCQHKmW1BdNvLvAgZX4zkn7JX7KgFL1 w==; X-CSE-ConnectionGUID: n1j02lcKS+SYXNrNNHPiBA== X-CSE-MsgGUID: 3kIhcv5SQ3qInL5RZWPlhQ== X-IronPort-AV: E=McAfee;i="6800,10657,11778"; a="79164344" X-IronPort-AV: E=Sophos;i="6.23,220,1770624000"; d="scan'208";a="79164344" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 16:37:04 -0700 X-CSE-ConnectionGUID: wgYgh5eOSXKQsvN1FlE4gA== X-CSE-MsgGUID: /3QdPdttSPWp5rzi8xm8Ag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,220,1770624000"; d="scan'208";a="240285316" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orviesa003.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 16:37:04 -0700 Date: Wed, 6 May 2026 16:45:45 -0700 From: Ricardo Neri To: Christian Loehle Cc: 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 , "Rafael J. Wysocki" , Len Brown , ricardo.neri@intel.com, linux-kernel@vger.kernel.org, Andrea Righi Subject: Re: [PATCH v2 1/4] sched/fair: Check CPU capacity before comparing group types during load balance Message-ID: <20260506234545.GA4402@ranerica-svr.sc.intel.com> References: <20260429-rneri-fix-cas-clusters-v2-0-cd787de35cc6@linux.intel.com> <20260429-rneri-fix-cas-clusters-v2-1-cd787de35cc6@linux.intel.com> <099ca076-18b3-40af-9488-1fd0f4cdbac4@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <099ca076-18b3-40af-9488-1fd0f4cdbac4@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) On Wed, May 06, 2026 at 11:38:31AM +0100, Christian Loehle wrote: > 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: I will add this tag. > Reviewed-by: Christian Loehle Thank you! > > I've CCed Andrea, just because of this SMT -> !SD_ASYM_CPUCAPACITY currently > being up for debate... Ah, I missed that patchset. I will take a look. For now I will leave the comment. It can always be updated later.