From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796183577; b=djxonq58FvM9sfvFJErBvfLEaWEK8o5sy5kcczyvcvjThhB9ACgeb0bx2Z4eJ3Gyn1zD U3w4YPJrqJMb1tqPyBmw8+coiBCIZ1z6GkUzcBt5GUV7pv5HCuYC6SPT/M46uSsybZgjO 05aM0Ul+2+TivGBJ+Ih7s0wGxNGzPX4PX35aPH6RTBR8/uGRHJhbHt/dJQYP8EZhCpCcf StYASkN19xFwV9RWJ+dSo/Ta1LRw526a68kSkeKATJQeRZvLULPEYAwPUwB10a/dWW5ws Ghr7AylXbkxuW23hS/rtM3VB8zsEfhExg5H0rCyhLO3hJxBMwjbhGz+N8AokRPxq1Qw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183577; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=EhPe4NhW4CiHuFJAYVfSyJ/C8mubg3AbMehIs3SAK5Y=; b=k/jg/lxzeJfgTdrJnXM09RU2QM5oIn0Fy7xBCyEF45VsdnLZFc0JokD/+mkT7UfGrXDm vegk212cKjcdZrwS9eLG99/KpkFQzybCUGG020oroFyDwkimjYSIVX9l828DUwzee9DQb WD9M6moT4X0fqZw18FzJq4TyVrfTYWz3UxwWTEJl2Lv1aS57i8DbvwUWCsPkYUybdsYI5 ZkegIj6BubUPg214/5pQESjKhXeaRZP5NdQRjF14/XUE9kLixBKKVeg4FYuXuH4jN4Ugo Ogj3fWaHHZUNOYhDEl0RIbdOfTMaAdWAAzabLZrNDDGW9cBBMWdz8SN9AvhiHcLwZHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=i8EL3xLN; arc=none smtp.remote-ip=209.85.210.197 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31981606A685 for ; Wed, 2 Dec 2026 03:52:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 31981606A685 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=i8EL3xLN Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-8b852fdd55aso5027178b3a.0 for ; Tue, 01 Dec 2026 19:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796183576; x=1796788376; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EhPe4NhW4CiHuFJAYVfSyJ/C8mubg3AbMehIs3SAK5Y=; b=i8EL3xLNo2z4uhJeEtbVVJ3+Kz8eNT0HbbdmlhJiOtbQw3LTnH2tHCq6Aa8D+Z7Hyx xT1mD+prg6dEy0Z5VtFEz5rcsz/C6r3sIIHkRaV/yjZO1lWQIEYcljkXOzknbM9vEQ/7 ZDyBH3YUu9TYqN18PsGBqrsq0NjeqCFnYNXDAw/Fn0grdNGf5V/E2QxZvVTK5IcD6LUV WPnGCC70KP0xaOkqWX15BCYz2aJFlWlWJhB/+2iWeOtn5JvPyVPIlrc4jdQRmBrtikQC EahhL1Ny9i1FI7ES/rzfU2nCcXJ0PPtLFIQ/29kA32jnMtkHaWassS5iIgz0szGKwZ7V 8Ing== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796183576; x=1796788376; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EhPe4NhW4CiHuFJAYVfSyJ/C8mubg3AbMehIs3SAK5Y=; b=tzU3lpeAr7WZBS5MSWlnQxj4L6V3NgOZh/7pNi/wq1gngGJL8Tr9YfTXLnFleRXrqc rimp8k69c7pmdALWy6n+iMzWSBILpJOT+1z3Spf2m06WTdBS2BCJrD/GdRv1QR2dwl1j 7Psp3fcFZ8QAwN8vajeC7YFJqIkyzncYV/IYOx17JZ4JMWIh4Au+jACzlcD0IHRi/xgr fae7CveOpqGKqkJcb6WGYfGgk+uH6TnvTSm/9MaTy+l4wi8B0NoLQcQ+flmBD8xamgpm TMjMIxkIFFVLOTR0FU69qjOhacfxMp3iAkSI4zHlwxBd3vb8nqqndNDW+gZyKqLiMYvd 6z5g== X-Gm-Message-State: APuU4Z/N8O2E19Yu6wOGohly/1nPNc3m0j6CFXrDMHx+T1qOjA+fvtu2 dNKnbWcT2q2gkHMSe7Wu75qHK3AzVygdf1APBy0Lfp0QWgWv8jJrcdLkJJTvLdpm5lSWiASpscq G5M0pihYV+IqNvPBo1jjPkddYJQx2spFbWlXf2dd3Pa9okC97sf7LP3IFl+5qwilxsU6tI4zVL4 XLxSUzmd6/0f4qoTWX9WRY38T0iwwVRXbg/7ldeRro6pogpQlf X-Received: from pfbff3.prod.google.com ([2002:a05:6a00:2f43:b0:899:1f5b:5265]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:f94:b0:890:a995:1f4f with SMTP id d2e1a72fcca58-8c87b4f42e2mr38267174b3a.20.1796183576012; Tue, 01 Dec 2026 19:52:56 -0800 (PST) Date: Wed, 2 Dec 2026 03:52:36 +0000 In-Reply-To: <20261202035248.1210026-1-jstultz@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202035248.1210026-1-jstultz@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202035248.1210026-9-jstultz@google.com> Subject: [PATCH v34 08/14] sched/proxy: Invoke migrate_task_rq() on proxy-migration From: John Stultz To: LKML Cc: Yu-Ting Tseng , John Stultz , Peter Zijlstra , Ingo Molnar , K Prateek Nayak , Thomas Gleixner , Juri Lelli , Vincent Guittot , Valentin Schneider , Suleiman Souhlal , Andrea Righi , Johannes Weiner , Metin Kaya , Dietmar Eggemann , Steven Rostedt , Zimuzo Ezeozue , Waiman Long , Boqun Feng , "Paul E. McKenney" , Joel Fernandes , Qais Yousef , Xuewen Yan , kuyo chang , hupu , Zhan Xusheng , "zhidao su (Xiaomi)" , Hui Su , "Shubhang Kaushik (Ampere)" , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" From: Yu-Ting Tseng Currently, proxy_set_task_cpu() calls __set_task_cpu(p, cpu) directly without calling p->sched_class->migrate_task_rq(p, cpu). But when proxy_migrate_task() or do_activate_blocked_waiter() moves a blocked fair donor from src_rq to target_rq, p->se.avg.last_update_time remains non-zero, so activate_task(target_rq, p) skips attach_entity_load_avg(). When p subsequently wakes and return-migrates via set_task_cpu(), remove_entity_load_avg() subtracts p's never-attached load_avg/util_avg from target_rq, driving target_rq's root cfs_rq util toward zero and distorting cpufreq/EAS CPU selection. So split out a __do_migrate_task_rq() helper from set_task_cpu(), and then re-use it in proxy_set_task_cpu(). Signed-off-by: Yu-Ting Tseng [jstultz: Rewritten to reduce code duplication] Signed-off-by: John Stultz --- Cc: Peter Zijlstra Cc: Ingo Molnar Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Juri Lelli Cc: Vincent Guittot Cc: Valentin Schneider Cc: Suleiman Souhlal Cc: Andrea Righi Cc: Johannes Weiner Cc: Metin Kaya Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Zimuzo Ezeozue Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Joel Fernandes Cc: Qais Yousef Cc: Xuewen Yan Cc: kuyo chang Cc: hupu Cc: Zhan Xusheng Cc: zhidao su (Xiaomi) Cc: Hui Su Cc: Shubhang Kaushik (Ampere) Cc: kernel-team@android.com --- kernel/sched/core.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6a9fec7a26f67..863f4e3a2051f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3444,6 +3444,16 @@ void relax_compatible_cpus_allowed_ptr(struct task_struct *p) #ifdef CONFIG_SMP +static void __do_migrate_task_rq(struct task_struct *p, unsigned int new_cpu) +{ + if (task_cpu(p) != new_cpu) { + if (p->sched_class->migrate_task_rq) + p->sched_class->migrate_task_rq(p, new_cpu); + p->se.nr_migrations++; + perf_event_task_migrate(p); + } +} + void set_task_cpu(struct task_struct *p, unsigned int new_cpu) { unsigned int state = READ_ONCE(p->__state); @@ -3493,15 +3503,11 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) trace_sched_migrate_task(p, new_cpu); - if (task_cpu(p) != new_cpu) { - if (p->sched_class->migrate_task_rq) - p->sched_class->migrate_task_rq(p, new_cpu); - p->se.nr_migrations++; - perf_event_task_migrate(p); - } - + __do_migrate_task_rq(p, new_cpu); __set_task_cpu(p, new_cpu); } +#else /* CONFIG_SMP */ +static inline void __do_migrate_task_rq(struct task_struct *p, unsigned int new_cpu) {} #endif /* CONFIG_SMP */ #ifdef CONFIG_NUMA_BALANCING @@ -6929,6 +6935,7 @@ static inline void proxy_set_task_cpu(struct task_struct *p, int cpu) * was previously runnable. */ wake_cpu = p->wake_cpu; + __do_migrate_task_rq(p, cpu); __set_task_cpu(p, cpu); p->wake_cpu = wake_cpu; } -- 2.56.1.911.g883d8bcb20-goog