From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 6BA4B3B7776 for ; Wed, 1 Jul 2026 21:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782942395; cv=none; b=t3fWV3CxHzFxPe+WGvD1XU+PLKhrMAAfbSpG/Ormq1QkYt3ThjWbaRBkQ1k3WLyHQBtdVEGEr5OLWxXlcuTHmZgzFCvIst2HRhGR48CqeFfSQIKT208qu8bVXpMQYUEo3CvMoA0OSSiP8VTlkmjTnbLJGHvrswfujxOywUsNIJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782942395; c=relaxed/simple; bh=qBKuXRtcCjjHsQJCXlSyjn4PW6GrCDBgf4dBWhx4Yqk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gYFcTcNBuYbZ2N+2nZak2xnRLyBXuN6zE6iWEII+KPMhPwG4P4932wrq3LmNkbDSfNXZBGur2l6vJwAHyoGj1sT2LNb1Y6l9Jzmn6utlooqYzd+9l1m6jgLwsDzO7MstzMWaprBCQvFO/afYoWV9QeHg1mW6Ry2c3dih2qPN/g0= 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=WAsb+t4B; arc=none smtp.client-ip=209.85.210.201 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="WAsb+t4B" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-8478ff5d801so1321207b3a.2 for ; Wed, 01 Jul 2026 14:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782942383; x=1783547183; 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=8zfkhx3qD4UB8ZBAJwHjl7iwLjA3ut3qhSrzCMCufLY=; b=WAsb+t4BhNvY6y/+SFbfJeyAm+UauKWMQHIcywysjeweFMfLWwYM+jS8GC+VAFhDVl JJJ5ej7j+g18OT7kq4WKrS63QJQZSDTqHMO4ZiiEPLqoJueBGIBc//1wnbQpIGgGpfg7 nUX7ToGbKFMZbyEpwLed2X7DZ3EHOhef0tcCptagmjYTi8fZBo4E7urVrNjPI4uSMn3K eWeTOqSoUHYrBv2cFeId9tiNJrTl4m+KTClkX7skCVqDBCFdVVGanGEGGlpVBqS0WfHV 9iPaoqJYgKl2+W9bf0yP9lvQgSjfEXSEFjSz9jz1XfO01/71dNqTMMEodk7cQCAO/2f5 cxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782942383; x=1783547183; 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=8zfkhx3qD4UB8ZBAJwHjl7iwLjA3ut3qhSrzCMCufLY=; b=sbGK9qU1XFCkgD4/5Gqzt01Ow5mM3IQXiVPjBpeVB2Tt1DhY1uSL91OG9KJWfEA7hg T5t7d0QiUoOQEZJbbya5quyJt6nCMQRCk29X5EVKZu0bjxLWoNd4dLn7JrflwxWVCupF XfkKKaURMlX+24VNZfLRZgHxUA3KkW2hcqLVQ33jJ1JmqTNnACE/3izc8W91J87cZd4n sCH2qBIpNcqUflh918GSF9TtQuxeS2fQ8FTIOov68wFM3DlJsLWjUzUkeeKroIbz0QIY 8433K6s0bpILPvz7w0x2Ocx3HBj/hESdInHKR5Um8Ura79TEeRht3HxLW5Geak3PJcy+ ADqg== X-Gm-Message-State: AOJu0YxTyOC8AnqjtB/A0Am/0fZD6r7WXSijFaMiM92l/GKSKorZoOeZ XDbAAVmhNcPvSTcA2C86G1UyT/nDEzxHyEqj9j15oGV1NFtLhNlcWOaAvNrtn9LAnlMdpHWPTbN gTQzPm0NY5FqKXtNvLFJ9O8bQg1XIMPLj7zqVo1RQPW+tk0E6LeWQUw65CCsOJsRxFL7VsEWe3t 2aG+qstoFn6nf14tNTVTCr2n+OBQRDB7OFfCSEUQ2WcCUCDDA7 X-Received: from pfuw2.prod.google.com ([2002:a05:6a00:14c2:b0:847:7ffd:ce5e]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3397:b0:847:8f8a:a05d with SMTP id d2e1a72fcca58-847c0878285mr3177525b3a.29.1782942382950; Wed, 01 Jul 2026 14:46:22 -0700 (PDT) Date: Wed, 1 Jul 2026 21:46:01 +0000 In-Reply-To: <20260701214615.3773339-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: <20260701214615.3773339-1-jstultz@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260701214615.3773339-7-jstultz@google.com> Subject: [PATCH v30 6/7] 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 , Vasily Gorbik , 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: Vasily Gorbik 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 564762ed36f2d..1bf60d78c9208 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6819,9 +6819,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 @@ -6834,13 +6834,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.55.0.rc0.799.gd6f94ed593-goog