From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 064363F39CA for ; Fri, 24 Jul 2026 18:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784916774; cv=none; b=UDLRgrsGPJInFluO3bOuSlmRAmDE6odrQ/cfnebZM16FS0IPsorXOx6SdMK5gq21uNdwtFnDFhvonO0IxxRIp62/JFgI4TtSuwPFcy0Vor+IZBadM96adhjdxxclEGrS0c6O/JuwuP1y8TEI6PE8zN5gwSkAnJBi/Yw9mQEchGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784916774; c=relaxed/simple; bh=XuZeRBFbPHtq6svLOO6eZbyEBdkxv6YoZQTCKQVEngU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CaTJGpC4QdKXzuAK+mQZ52v8RB4RC0GOfIC2wppSgEqMR49sAB5Pqzxh20Zl9i1tgyUh/Btr94JxCdOhsyE8F7mCw4dbUzz0xXzAlxKguHJSN3QKc/lmOOvCVbH0e+z8HHwVbs3v2wmFmLTyQWVAtUFtGemJwxyXGLCIPV9KgDc= 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=BPsUfOMv; arc=none smtp.client-ip=209.85.215.198 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="BPsUfOMv" Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cb835525b10so768931a12.2 for ; Fri, 24 Jul 2026 11:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784916768; x=1785521568; 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=p/WuSLcSEfa3FwxJ8MnqaqaH4ucTQMrCIvVbyMRplsw=; b=BPsUfOMv90rypHhtOy+77tfI3U2UziAoMZ45/x8F1BklEF9ObRH7ERfkOo6u4t9APL MpVn7nVq2j7/sI0ZsqL8sHfx7+6mtQw3W4EGRDDiXly6zcJ2eTXp4MGXPCLVs52qWg9u PmPnRxUEfrdGGKnFB1mmCS9evNZxuEYgYNMbvigZEKP32SoPnfUZ6SjL3tLCkCKxLpNU 2QYPbTLl4A4YFdwjyxI/L5X08gaEwwA7Yk1qnQ4R1jk2u0hqsv02csaBEFXVWWez0+NY hFZ4TZsX89JiFWR5hDySEmKuh/UT0DHFlkyTTXdvmvYZ9ySkyq0W4l7d+IIa3OpyDtRX TnTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784916768; x=1785521568; 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=p/WuSLcSEfa3FwxJ8MnqaqaH4ucTQMrCIvVbyMRplsw=; b=QGZwbOn21fp64wks8UD21wG6bkY2scBt95WPJPoStG7lTKlJXh61zt+eXD7UbqH7Gg kHzOwcfXgHNq53JwTRvexcOYeZcvo4gZiBe0yREYjFfzLu/oDge8brSXZ3c+2bN0DN/U pSiZtcWGkw01omZAWESWq/5F83Y0Jci5ERyR4yxYzdFhCUGrSQ1a+iUrm/OhxXWiyfHq VzRDYUO82ajwqlTj877dAsqbQRfCTYceIx8PgQyIEc4yodju4IYaeO3H15CKJcpcQPd8 CPZHoq4SVDGbS66gfoQpaMv2D7Cs3WN5VprKZg9CsBTwJDiDtTLbC8B1aiKYPNzSIYZN Lw5A== X-Gm-Message-State: AOJu0YxTmO5+IZDktQpDzCeisDIc+8r2Bp7gPvodJVLpKyVO3CmzkalU vQr7H5W8gNEVhAX+Dp0Z8C9YMIurSSR+/nx8f2jv8H6QddFSCAwE79u+mNrAr5G8hHrRd/85ndd 96hILbudJxtnQmLJ7Db6if5P2/ewi3BDBjyl84MIK5fOf9cTByCDUrxNkYyqunRQs82oStG31Su GqfFoW4wedoLpp/BvByY70wFG6DkKVTX8RXnVvYcvhrE2G96Rg X-Received: from pgc10.prod.google.com ([2002:a05:6a02:2f8a:b0:c80:1fe6:ac57]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:4cc1:b0:3c3:8255:8c4a with SMTP id adf61e73a8af0-3c44aff5387mr9732228637.17.1784916768087; Fri, 24 Jul 2026 11:12:48 -0700 (PDT) Date: Fri, 24 Jul 2026 18:12:21 +0000 In-Reply-To: <20260724181238.3445275-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: <20260724181238.3445275-1-jstultz@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260724181238.3445275-8-jstultz@google.com> Subject: [PATCH v31 7/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 , Andrea Righi , 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: Andrea Righi 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 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.229.g6434b31f56-goog