From nobody Mon Apr 6 10:45:02 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 4E38126A0DD for ; Fri, 20 Mar 2026 06:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987619; cv=none; b=pQmNv8s8aMv9aXd3reXyeeq9gOelPFxT+JsLu/7FIcXOGz4iIBKKwhpkPhMlF+hGNmV0Q2QSYmeb6czdL0Vm0wSTCmxSUNbwpjbO7KC/S5r2Fz5BDLCMo92w8NZoPhTjMuAyXP5ofuUNrnknJGj4FdG8CDqf0lZdz0ZOOjIgExM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987619; c=relaxed/simple; bh=Cnm8A/BqIJEz+2j9M/P1O+jZt3GWP2m3BzbjMsdqybc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kAUt1NOMc4mclIDXBfab9zr4jeAZjuyL4iiyedWCAuZh4Ss+CloZM8Wzuuq/MLK02L+lYF/TRMyR8xPOHsCTyt98zklz846rpXYIOLkFxqHwPqkFO9FNBIt1B1A0bbThbCqYA68E83hjvoHGGGF79Wx/JMR8KNYnWro372qngS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=hD2dDJcf; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="hD2dDJcf" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=yLtrl0kzFYeduf5CMC+JoJgfXCbR3aasb8lPYKojXg0=; b=hD2dDJcf6MRwaYAIAdVQdJUSvL9Ezx5f4gIwpQxbjDG8yUt3BXyxhzBMpW0VE519Y2No9Y0MZ y8IrlG7xEr3GarfVUe/lb9sgyDHXQkinIB7jerXJUDWJzyQ10NqkNMan2Uj6HgvupOEhLo5Z99A wCkUJeETh57aWoggx3T4NKw= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fcXNb6Y0fzKm4l; Fri, 20 Mar 2026 14:15:11 +0800 (CST) Received: from kwepemr500016.china.huawei.com (unknown [7.202.195.68]) by mail.maildlp.com (Postfix) with ESMTPS id 3E92440561; Fri, 20 Mar 2026 14:20:13 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemr500016.china.huawei.com (7.202.195.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 20 Mar 2026 14:20:12 +0800 From: Chen Jinghuang To: , , , , CC: , , , , , , , Subject: [RFC PATCH v5 7/9] sched/fair: Provide can_migrate_task_llc Date: Fri, 20 Mar 2026 05:59:18 +0000 Message-ID: <20260320055920.2518389-8-chenjinghuang2@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260320055920.2518389-1-chenjinghuang2@huawei.com> References: <20260320055920.2518389-1-chenjinghuang2@huawei.com> 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 X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemr500016.china.huawei.com (7.202.195.68) Content-Type: text/plain; charset="utf-8" From: Steve Sistare Define a simpler version of can_migrate_task called can_migrate_task_llc which does not require a struct lb_env argument, and judges whether a migration from one CPU to another within the same LLC should be allowed. Signed-off-by: Steve Sistare Signed-off-by: Chen Jinghuang --- changes from v4 to v5: Skip tasks with the sched_delayed flag during overload detection. --- kernel/sched/fair.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ebb13108dabe..0bf6d18dac05 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9582,6 +9582,34 @@ int can_migrate_task(struct task_struct *p, struct l= b_env *env) return 0; } =20 +/* + * Return true if task @p can migrate from @rq to @dst_rq in the same LLC. + * No need to test for co-locality, and no need to test task_hot(), as sha= ring + * LLC provides cache warmth at that level. + */ +static bool +can_migrate_task_llc(struct task_struct *p, struct rq *rq, struct rq *dst_= rq) +{ + int dst_cpu =3D dst_rq->cpu; + + lockdep_assert_rq_held(rq); + + if (!cpumask_test_cpu(dst_cpu, p->cpus_ptr)) { + schedstat_inc(p->stats.nr_failed_migrations_affine); + return false; + } + + if (task_on_cpu(rq, p)) { + schedstat_inc(p->stats.nr_failed_migrations_running); + return false; + } + + if (p->se.sched_delayed) + return false; + + return true; +} + /* * detach_task() -- detach the task for the migration specified in env */ --=20 2.34.1