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 4BAFC358376 for ; Sat, 4 Apr 2026 05:36:58 +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=1775281019; cv=none; b=PMD+r6JxBUXABwZ4WSdsUW9bnH/216eAux1UyJyI7Wix/is7NGQ9erUWcytA1ZFFX7v42uwN9yQgy9KiC3MEDnDam/4d0Rbc0w4u6JyDmZ6jzNgOCp7CNda1/1GMRtSoAFNxE9Kj0N6q1T9ZcwUcXny+mSIuPsdxRfUIy4ngyaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775281019; c=relaxed/simple; bh=pS62swtbY1WzP8+s4ohSpg6RpjgQH9a6cVLQmrMfVzc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=C5TlskjCmHEmCNDvFoXCu9j07na9ysqNaqX32Vxv5EhPkFgFYbPXISUcg0ggHdygeFJaJ3Ngq9RUweFaeoEBlIK2iYRORcxdUWx4i3g1v9KJeip3YGSZcIPRK8pDnWHUSeA4SSA+K8iSYDEhbf2xPv1KaJj1QqcTc/hUlasidXk= 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=E/q+jMbx; 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="E/q+jMbx" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b256ed2cc8so27171865ad.3 for ; Fri, 03 Apr 2026 22:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775281018; x=1775885818; 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=F5iXkOwPiQFobESqRJsKiFf0yXE4Dgq0YFJVQa0OGWU=; b=E/q+jMbxJeR7JEfA5S3ZJ8eWYezufCg+ZgPiB2ctRPWOeu1rsw9hPLI2MV567/sRGy gzPeeuQMwjNUmk75mTCmupDw9xFMF1+j11CJmOorIY/opsWNEzO2xKle7+b2Y7S7T69a N1NyHtckfXjEkF9PyWJD8J4PSpPMu5xY94k07o7IEuWYTb7re5KIcYlg/oOzJ21lDdka OmZIesJFb7OJvwYyzZqLs1/ePIlYZy+CJgRSFEd/9yYDY3+fJa1f8g59VHRsNeHfdIlV dEjJ8gdxv9K/eHSePgQ0OFnT0BDASsXJyj54wrEnJY4ZleH4QQRf8lIaT+P7XD6+X6me yb6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775281018; x=1775885818; 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=F5iXkOwPiQFobESqRJsKiFf0yXE4Dgq0YFJVQa0OGWU=; b=sD4/3CqNhJoY+pzSFoChSS0PP8Q+g2jD8lfSswSqP1zxLwK7Ao2m5Qhx8FhtYlw38B +USn09cYjoTvekttRP0BQy6/DkGfprWPIftsBY3tgcxKZa6T9ytWfQy5cZCR0R3RAKuf k9Lwk6hzmi5zpEoNXsl8hO7yS5z37ysHPUj1M9CcfCy1w4aJ96fwFT8nTIOakmgmHCq6 6O7CI9d7a/Sf9KxZ2/ep1tbCh8iPQZmJggnaY/AE+8sl2cDyg1uK8MsMm41zGRusfqeh iemrnf12jy12gvEwhvHhAAeBQOWe1Pi3Cjf3xQ3wjLM81zfx2Epw7Kuj+RXJJl4NqWQI DhOg== X-Gm-Message-State: AOJu0YxTPKV8TcxgtjuagYS7JcLbn4maQsAwaZ9yEax/qaHQZDYfuIFg wOSNx5WHChTtL8SKVG6DPpSk6J3guc0w4svBnPVh/NspQh5eBPG2lrz1gLiPbDi+NDEoxQUwq3n t9h6AuxooTYzL9Y7rTJPr6de8V5CXCBuirmoqOo+2oSBXh2pk7Opt3fILSDF7YmNL8nXZ/PYC4N KEPG+CqPRBTNm762xMDFZYqDIaD0d88N/xoB0jEv/KspnVjOzP X-Received: from plks18.prod.google.com ([2002:a17:903:2d2:b0:2b2:52a7:1000]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ef4f:b0:2b0:663f:6b53 with SMTP id d9443c01a7336-2b28180e4cfmr51304625ad.13.1775281017067; Fri, 03 Apr 2026 22:36:57 -0700 (PDT) Date: Sat, 4 Apr 2026 05:36:27 +0000 In-Reply-To: <20260404053632.1729280-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: <20260404053632.1729280-1-jstultz@google.com> X-Mailer: git-send-email 2.53.0.1213.gd9a14994de-goog Message-ID: <20260404053632.1729280-11-jstultz@google.com> Subject: [PATCH v27 10/10] 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 , Mel Gorman , 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: Mel Gorman 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 9197b4274de8c..164429de8dc1f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6723,9 +6723,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 @@ -6738,13 +6738,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.53.0.1213.gd9a14994de-goog