From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 680E6379EF0 for ; Tue, 12 May 2026 02:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554624; cv=none; b=uRCGc9AtiJItXUQiFMZAtmg8uRfo+NHrM/lznKLbWGCVj1Tn8ZwsfxDULL+lp7LOwOeGBEyb6AJMCZ38l9BBJxN+RW65U3zr39WBGorxs818mjQLEY1RMmujS1jefQW0WsJz0O3uj+ev3haz7AnuRuLpPeMoLaQdPAiqBgkmYP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554624; c=relaxed/simple; bh=azOv9/89E3v4TrGojOiyqBhrhyYU2fzayWFE2501nCM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Ax8qOFqYgU1eHU6HfYR2RnUrftT6eUhZoco1o4/7jk63hjm5eXlGO3cR4JZA3uprG52hIc8tIWXH7u3P9U9YAz3kZco/shjHdc1V2kWt9arLpGrQk8kaHqUVWFI8e/5+9uJlgX5i9Y+yNP4Ipp7D+a6NVUuAc6Vbp02ZhCnIAyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GF90TMjm; arc=none smtp.client-ip=209.85.214.202 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.b="GF90TMjm" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ba6fe41283so58651255ad.1 for ; Mon, 11 May 2026 19:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778554612; x=1779159412; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RrDDPlGDQHgcoRDfnNRpPB18PTCHaXCTL4POqtiaWPc=; b=GF90TMjmuicHmGQkxPXzjYNLxaL1Z+DvAbDLhmYfporRGn9QPZeK/GJgyrD1s6lO3U KD6uW/gHOMUy8jMbvtC1WPuELZIgd1R1MIDQxnlnaafcsy7ZQIiouoarYhCYu8qexTvP n3b7jlYv9L9YAkNjQd9AXVFLixAsxstUcxnuS9894dISYNJDXIToyN1qS6X4PPTQdUCM MDGTrPCDtMLdslpNLYG2HTae+wLSvgmhHFBtiWxb0ZWJZGAnZqXfBlTo1jFQSmwZ8cyG yS+1t//Iu2CZptZXYKgBT5OubmsnygZ9dvbR50oc/Ve/FtGq1GglUWmuEfrbXqi5P3zx PNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778554612; x=1779159412; h=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; bh=RrDDPlGDQHgcoRDfnNRpPB18PTCHaXCTL4POqtiaWPc=; b=inu4FaA47t32te0w04oRPmMEpBE5vJR19XHsriudCx2A/PunIL0WjMXsP5CaCVOk+5 I9nj92UEsqYzVv8XXuA1SoMJRpIB3er4JNmqqysT4kWeTqYf6xw+NaUCStVPT5DP2F9r gGIZi/0toLfITg0t2A5xPNueO/eKFddeGWeUHxRWqamfO3J+ovY7rOJozyq9O5Rnjxxn HlMB0cKTEuPYsb1EDJQ+MbtvepdVN5MOr/QSeIXwCzdtmYB4nKXJgwNpP/yn+Aga6pD8 1Y2/1ajpJ659Vjz5mC5kNu0XmdVLvWsDZ9kO9LEclMSZWS4F67B/z3qzf96UpsoHERBm 97wg== X-Gm-Message-State: AOJu0YxHlNGOxZRwgPZ4s+F22CiYMRpuSrpUICVnHPkQwiomuk4bWe+S JHVlqxv5x/im3zHEyafSlRaKZG7dUafZTOEn4cmfsAu+0SvjpCuMQc0U5osbbPjjQ4x2jIEN8GJ acr+gim5oIUHZxVT1fKH3Jr80YTZDYKgmg23DiIpp9+sAAJUpudcwT8nFoB/347XWhsX+qP26XU uWh2QV4eOoAthJ9madARsjozqNoyuGjJRGBiJReBLKrhXFgK0F X-Received: from plsr4.prod.google.com ([2002:a17:902:be04:b0:2b9:fe8d:ccb8]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2b04:b0:2b4:6080:d4d0 with SMTP id d9443c01a7336-2ba798c2f47mr302043655ad.22.1778554611376; Mon, 11 May 2026 19:56:51 -0700 (PDT) Date: Tue, 12 May 2026 02:56:19 +0000 In-Reply-To: <20260512025635.2840817-1-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260512025635.2840817-1-jstultz@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260512025635.2840817-10-jstultz@google.com> Subject: [PATCH v29 9/9] sched: Migrate whole chain in proxy_migrate_task() From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , kuyo chang , hupu , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Instead of migrating one task each time through find_proxy_task(), we can walk up the blocked_donor ptrs and migrate the entire current chain in one go. This was broken out of earlier patches and held back while the series was being stabilized, but I wanted to re-introduce it. Signed-off-by: John Stultz --- v12: * Earlier this was re-using blocked_node, but I hit a race with activating blocked entities, and to avoid it introduced a new migration_node listhead v18: * Add init_task initialization of migration_node as suggested by Suleiman v22: * Move migration_node under CONFIG_SCHED_PROXY_EXEC as suggested by K Prateek v25: * Use se.group_node instead of adding migration_node, as suggsested by K Prateek * Integrated attach_tasks() cleanups suggested by K Prateek Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Metin Kaya Cc: Xuewen Yan Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Suleiman Souhlal Cc: kuyo chang Cc: hupu Cc: kernel-team@android.com --- kernel/sched/core.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2226f594376d6..c6958a20f4758 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6791,9 +6791,9 @@ static void proxy_migrate_task(struct rq *rq, struct rq_flags *rf, __must_hold(__rq_lockp(rq)) { struct rq *target_rq = cpu_rq(target_cpu); + LIST_HEAD(migrate_list); lockdep_assert_rq_held(rq); - WARN_ON(p == rq->curr); /* * Since we are migrating a blocked donor, it could be rq->donor, * and we want to make sure there aren't any references from this @@ -6806,13 +6806,20 @@ static void proxy_migrate_task(struct rq *rq, struct rq_flags *rf, * before we release the lock. */ proxy_resched_idle(rq); - - deactivate_task(rq, p, DEQUEUE_NOCLOCK); - proxy_set_task_cpu(p, target_cpu); - + for (; p; p = p->blocked_donor) { + WARN_ON(p == rq->curr); + deactivate_task(rq, p, DEQUEUE_NOCLOCK); + proxy_set_task_cpu(p, target_cpu); + /* + * We can re-use se.group_node to migrate the thing, + * because @p is deactivated (won't be balanced) and + * we hold the rq_lock. + */ + list_add(&p->se.group_node, &migrate_list); + } proxy_release_rq_lock(rq, rf); - attach_one_task(target_rq, p); + __attach_tasks(target_rq, &migrate_list); proxy_reacquire_rq_lock(rq, rf); } -- 2.54.0.563.g4f69b47b94-goog