From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 928E539C005 for ; Wed, 22 Apr 2026 23:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776899233; cv=none; b=j5Ddc2+vykR6m7Cqg/SYa+yJOuLikKT7xeAm+0v6q2U6hbS8p+d34WlNJbifZ2CaQcVC/ZiuKimDS5OZ60k60rL26HujJJt8v8daBQAIVVecoVes+y/cDhLop11/DzNcGPIpSU97yVgO5C9fkt5JOFQbpWZX+CpevkCeTIPF2EM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776899233; c=relaxed/simple; bh=ycivuRo1T5jW2YQ9L0yq7POovtAqlpPgLPZzt7RQY+E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KTSHKzQ9RX/Rrhmtis8EvaUAF2LVONWzlvV+f6BYc2yjm38lHItyU+LjUJfTZU9/PvTAHUoGfJL2p2dcn3tlRMGNdp6cajJLBXfgf/SN5ai6tOFmUZUG0P1A2rOdoOMfhdYn0OZV3n7y9Y3b1e3ZYnoKAmWJrSz4FldnX6ZYHVY= 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=He751+qH; arc=none smtp.client-ip=209.85.216.74 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="He751+qH" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-354c0234c1fso6510607a91.2 for ; Wed, 22 Apr 2026 16:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776899231; x=1777504031; 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=lAboLaNdfEg5ZaKcXWXhV1PkcwhTcJXf/EXqaZs21hM=; b=He751+qHa7fBiNcHMQNGq7I3yDYXyEX7meEH6wSyowH2T41Wc2/RukSBHCWlaaLbnQ bD4pD33oJeFoi/0IC8trZKeKvtD7a1U30mVa57Bt9OjpiUA8Kt0RQQVr2Uacudr5qfWy PAK+pL/NGWgg3+3eo5Kr4mIraJqPZk3ES0+G2jcL9As6JaCBLxVKR75xSNqhlM5aVfIh B2/K0iH+MuMr7W5lsmRIOR+x8IYSXcD72kRHN1pxAZMoBHD/45x/L5IPDxAyf4i8SbtN tDJsj4O7qwmzXAOav+9tbcXJpTpL/U4O9E0ds2/ON+79DbVglWbMitESsYArdzedGsMY DnuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776899231; x=1777504031; 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=lAboLaNdfEg5ZaKcXWXhV1PkcwhTcJXf/EXqaZs21hM=; b=cMcVpY4akp5oa1PTqQ4ThHjEJeqXu+lYdjXrVjwpPYZRNLwBKXWlfZyUf2DB5hgSuH Shq8SPf16H5FJs+NfGdlX+gnOqIPt7ox/BdaT0IVb+GDMIVetUT39xdfyIVcexVbJteP ZaC/XFXnsIKTMhu/XH013qbF+Pr4jwIwEoIe+XpN6OS21wE3fgJL572v8mIxCYkqF1Kf XVbNkh2LrPO01i1zuqpCgGi9J4kjJ+OB4b0SSch4YyD5K5wSbaCc0aD0MPba26J2bsYz XYxMIaRaNZSg7bpu/9n8VqdGcc1k/o7gClubmjqm1soH9YzslHAGy7Afyi4SioehZyL8 YmwQ== X-Gm-Message-State: AOJu0YxjK0fKNuqqgfcsNlj0kxQYI1zTHL0mys9m7kD/XG9ltllIQ6Dz 0kh5KfziErnTTZFSlEH99Ljq6AzBxR+fojIzew9HGTo6Z5WjWJbfrIsayE4a/cAFb+CRKEq9VML fpmCacCbkaYRCkqbfOtop5Pch7sWyzV4gHWU97ujNkcXslY/TQofN2NOd7odbjoRSgncWg/HDSk AHCz8FEqSZyXLQLfbK0s1BWD3brcoOt1S/ohjTyaXcCrZctaHA X-Received: from pjvc17.prod.google.com ([2002:a17:90a:d911:b0:35d:9ed4:368c]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:e704:b0:35d:9f7c:142c with SMTP id 98e67ed59e1d1-361404a7d14mr23099475a91.26.1776899230549; Wed, 22 Apr 2026 16:07:10 -0700 (PDT) Date: Wed, 22 Apr 2026 23:06:44 +0000 In-Reply-To: <20260422230659.903191-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: <20260422230659.903191-1-jstultz@google.com> X-Mailer: git-send-email 2.54.0.rc2.533.g4f5dca5207-goog Message-ID: <20260422230659.903191-4-jstultz@google.com> Subject: [PATCH v28 3/8] sched: deadline: Add dl_rq->curr pointer to address issues with Proxy Exec From: John Stultz To: LKML Cc: John Stultz , Peter Zijlstra , Joel Fernandes , Qais Yousef , Ingo Molnar , 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" The DL scheduler keeps the current task in the rbtree, since the deadline value isn't usually chagned while the task is runnable. This results in set_next_task() and put_prev_task() being simpler, but unfortunately this causes complexity elsewhere. Specifically when update_curr_dl() updates the deadline, it has to dequeue and then enqueue the task. >From put_prev_task_dl(), we first call update_curr_dl(), and then call enqueue_pushable_dl_task(). However, with Proxy Exec this goes awry. Since when a mutex is released, we might wake the waiting rq->donor. This will cause put_prev_task() to be called on the donor to take it off the cpu for return migration. At that point, from put_prev_task_dl() the update_curr_dl() logic will dequeue & enqueue the task, and the enqueue function will call enqueue_pushable_dl_task() (since the task_current() check won't prevent it). Then back up the callstack in put_prev_task_dl() we'll end up calling enqueue_pushable_dl_task() again, tripping the !RB_EMPTY_NODE(&p->pushable_dl_tasks) warning. So to avoid this, use Peter's suggested[1] approach, and add a dl_rq->curr pointer that is set/cleared from set_next_task()/ put_prev_task(), which effectively tracks the rq->donor. We can then use this to avoid adding the active donor to the pushable list from enqueue_task_dl(). [1]: https://lore.kernel.org/lkml/20260304095123.GP606826@noisy.programming.kicks-ass.net/ Suggested-by: Peter Zijlstra Signed-off-by: John Stultz --- 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/deadline.c | 13 +++++++++++++ kernel/sched/sched.h | 1 + 2 files changed, 14 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4ff3e164d9880..df56406b12766 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2349,6 +2349,9 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) if (task_is_blocked(p)) return; + if (dl_rq->curr == dl_se) + return; + if (!task_current(rq, p) && !p->dl.dl_throttled && p->nr_cpus_allowed > 1) enqueue_pushable_dl_task(rq, p); } @@ -2571,6 +2574,10 @@ static void start_hrtick_dl(struct rq *rq, struct sched_dl_entity *dl_se) } #endif /* !CONFIG_SCHED_HRTICK */ +/* + * DL keeps current in tree, because ->deadline is not typically changed while + * a task is runnable. + */ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first) { struct sched_dl_entity *dl_se = &p->dl; @@ -2583,6 +2590,9 @@ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first) /* You can't push away the running task */ dequeue_pushable_dl_task(rq, p); + WARN_ON_ONCE(dl_rq->curr); + dl_rq->curr = dl_se; + if (!first) return; @@ -2653,6 +2663,9 @@ static void put_prev_task_dl(struct rq *rq, struct task_struct *p, struct task_s update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 1); + WARN_ON_ONCE(dl_rq->curr != dl_se); + dl_rq->curr = NULL; + if (task_is_blocked(p)) return; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 2b3a97735efeb..d0f3e164a61d2 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -889,6 +889,7 @@ struct dl_rq { bool overloaded; + struct sched_dl_entity *curr; /* * Tasks on this rq that can be pushed away. They are kept in * an rb-tree, ordered by tasks' deadlines, with caching -- 2.54.0.rc2.533.g4f5dca5207-goog