From nobody Sun Apr 12 21:03:05 2026 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 BEF6135DA5B for ; Wed, 1 Apr 2026 21:46:59 +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=1775080029; cv=none; b=UQV0D2eArJFzfpOAng51MgyJ29GWzb227zj4AGL7Cd/GbACYF7tJfs5DLjkLIk91mA5220VyopFenZjNAPhxjLFPRMEATDVorfE8vayuuQ5Y3IuWtlucKkSmWjIQ2CpWg3daOQXzdwLhF7R6PQ4NazwmgODQi9QFV0sfURz94bI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775080029; c=relaxed/simple; bh=pjeUStCXY/yPC4LhBHsq2mJPVCqLSpWLa8E2e+YWAuo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JiizGN9Az8GskGWB96pFuvPa31hjEONeIcNoK/LAlxCX3SMDrqpwb/b7FgtyGqq6YR66Sz5nKhCcFZi2+y0HQq9AD1wtB2wWyy2DNtNlHsqHReEC17Rp8AGmAbzGvZR6YvgWm3qVOy6+RL3CCIkOcrCnaYkfbdWD2eshJr+9ztI= 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=g2lN/2Dp; 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="g2lN/2Dp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775080020; x=1806616020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pjeUStCXY/yPC4LhBHsq2mJPVCqLSpWLa8E2e+YWAuo=; b=g2lN/2DpYAHP1FJOp5+3Pz87hRu11LdJstlZ9N8XGtnXIi26+Y2LSemK 4kBtZaOCGlTMxDmbg7WmCDPa8U+pXTfq+vxKH4Gxqd/FQeaETGe+ewTsr knmTsaNUiPaVsHkztw5nC/YpN2mTg0ulwQayWD/kxlwmh5Vwp6Xd+VEYz ZAShzFzxZYI3ZlAvvz3wZhVKYNXvJL5AR6bTJnsqmt7fNK6FDz6nDcZGs QsSjSroqx0lNM7Wz6FnsqvjTCNyjtqrVYxcc3cp/vn9p4NS765f5qDfdy j9Q/mcZz7WsyOIq7Z9dh5GwLwrPgD7u8oOxcd+xfpCO3pO8CJv8BO0vQR w==; X-CSE-ConnectionGUID: +xgdKEN6QmGOvMznwEM+hg== X-CSE-MsgGUID: gZLYScM0S+esGlmLisi0Sg== X-IronPort-AV: E=McAfee;i="6800,10657,11746"; a="79739926" X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="79739926" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2026 14:47:00 -0700 X-CSE-ConnectionGUID: nr6G3979S864xSdTIe/BTw== X-CSE-MsgGUID: bOXj0JeBQQyW4H0uUA3hMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,153,1770624000"; d="scan'208";a="249842451" Received: from b04f130c83f2.jf.intel.com ([10.165.154.98]) by fmviesa002.fm.intel.com with ESMTP; 01 Apr 2026 14:46:58 -0700 From: Tim Chen To: Peter Zijlstra , Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot Cc: Tim Chen , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: [Patch v4 11/22] sched/cache: Check local_group only once in update_sg_lb_stats() Date: Wed, 1 Apr 2026 14:52:23 -0700 Message-Id: <99a57865c8ae1847087a5c00e92d24351cf3e5a8.1775065312.git.tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no need to check the local group twice for both group_asym_packing and group_smt_balance. Adjust the code to facilitate future checks for group types (cache-aware load balancing) as well. No functional changes are expected. Suggested-by: Peter Zijlstra (Intel) Co-developed-by: Chen Yu Signed-off-by: Chen Yu Signed-off-by: Tim Chen --- Notes: v3->v4: No change. kernel/sched/fair.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 62a628a1594c..4ed84086244c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11228,14 +11228,16 @@ static inline void update_sg_lb_stats(struct lb_e= nv *env, =20 sgs->group_weight =3D group->group_weight; =20 - /* Check if dst CPU is idle and preferred to this group */ - if (!local_group && env->idle && sgs->sum_h_nr_running && - sched_group_asym(env, sgs, group)) - sgs->group_asym_packing =3D 1; - - /* Check for loaded SMT group to be balanced to dst CPU */ - if (!local_group && smt_balance(env, sgs, group)) - sgs->group_smt_balance =3D 1; + if (!local_group) { + /* Check if dst CPU is idle and preferred to this group */ + if (env->idle && sgs->sum_h_nr_running && + sched_group_asym(env, sgs, group)) + sgs->group_asym_packing =3D 1; + + /* Check for loaded SMT group to be balanced to dst CPU */ + if (smt_balance(env, sgs, group)) + sgs->group_smt_balance =3D 1; + } =20 sgs->group_type =3D group_classify(env->sd->imbalance_pct, group, sgs); =20 --=20 2.32.0