Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 8C5BE363090 for ; Sat, 15 Aug 2026 11:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786791879; cv=none; b=eYY0Vn5p24tiC1sLhMK8xucoMjRMQqDkoE8EI5DyFKW8Nt0evx+XmV8cPVcQRJJP/5T8a2GhGaIYBA1PIEotILsI56e7wHdQUr0TsfzO+3YBIXOPBlf7p7kj6O22o71NiJinBRAhilf4J+EIuoeppvrWYp/xzmirDwofGkiSNV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786791879; c=relaxed/simple; bh=KsIoKJWnFpTP1QqcLS2ahGyzsxSWbGwq020JU74xWZg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hHx2DK51QWi42SRiPqexneftNj4QJUUwRzu4xjcRPda/pAePndEDanPEQxf4F8K1j2ylWwDLhQmn3d6R4v8iiR1xNVNYT8AGQ4JC0vJF0bTrIhuwvpPt1j5wkFILO0wK9lxFvHsZix/jS1gPjiqwFW2BebxEvKVBC/5vXgnw5w0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=WUlAj4l3; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="WUlAj4l3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=KT QU5wwOgoyx1VpyqCpFm3lgO2ZriMIQJJ0cehW7kzQ=; b=WUlAj4l3IXc62q6mw/ eWPzr0e4lLhdTrNPYtkwdjm3lYijUduwGrFceQKw2TL1UobHDB1wkFXW66N89hs/ HTwIlbY/qza44vAe0swb3TecXs3TSr+oaNsaGhKmJlDMP72pFNPEqz7Ak36eKYTd ferhWw+rfAVx2hdTmG7ckvjo8= Received: from zhaoxin-MS-7E12.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgB3tQRjR4BqOFTVNA--.50445S11; Sat, 15 Aug 2026 19:03:12 +0800 (CST) From: Xin Zhao To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com Cc: linux-kernel@vger.kernel.org, Xin Zhao Subject: [PATCH 09/10] sched/fair: Not goto more_balance if newly idle and has pending task when LBF_NEED_BREAK Date: Sat, 15 Aug 2026 19:02:56 +0800 Message-Id: <20260815110257.124354-10-jackzxcui1989@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260815110257.124354-1-jackzxcui1989@163.com> References: <20260815110257.124354-1-jackzxcui1989@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:PigvCgB3tQRjR4BqOFTVNA--.50445S11 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF43KF4rWF1DWF4rXw4UXFb_yoW8Jw4xpr Wv9F45Za1qq345A39ayF48ur15uw1Sk398uFZrArWfJrn0qFWjvFZYga9xWFWjvFykA3Wr ZF1jg3429340yF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zujgctUUUUU= X-CM-SenderInfo: pmdfy650fxxiqzyzqiywtou0bp/xtbC5xCosmqAR3CLeQAA3C When LBF_NEED_BREAK flag is set in env.flags, no longer unconditionally go to more_balance. Instead, we exclude the case when it is newly idle and there are pending tasks. This helps avoid unnecessary CPU wastage caused by repeatedly going to more_balance when the task load is too high during sched_balance_rq(). In another 'goto more_balance' case when LBF_DST_PINNED flag is set in env.flags, we do not need to add the check. Because LBF_DST_PINNED flag is only set within can_migrate_task(). Before setting LBF_DST_PINNED flag in can_migrate_task(), there is a check to see if it is newly idle. can_migrate_task() will exit without setting the LBF_DST_PINNED flag if it is newly idle. Signed-off-by: Xin Zhao --- kernel/sched/fair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8a1d2763a923..1ae351ea5949 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -13561,7 +13561,9 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq, if (env.flags & LBF_NEED_BREAK) { env.flags &= ~LBF_NEED_BREAK; - goto more_balance; + if (!(env.idle == CPU_NEWLY_IDLE && + (env.dst_rq->nr_running > 0 || env.dst_rq->ttwu_pending))) + goto more_balance; } /* -- 2.34.1