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 8FF56379996 for ; Tue, 12 May 2026 02:56:47 +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=1778554609; cv=none; b=YIhrcVR3kMgjPj70yP7mO4q8HGokNuWJIIU9je7aCjUp77zBEDd1+6X9f7pq/IUtnEK14vKsw8GEcqPEiTXNbaX2P4r70WgAfyvELMdl2PlIyinYAn+c4sbEwCGsg8KToMKkfyWKvEIfagk3oPIarv1ydnAyzavOrG6Lvttkc6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554609; c=relaxed/simple; bh=nMS8FFMFPSZuQNBXYW+W8F+WJHNfGQxOicZS4FFiInQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NpUlUwUoHEGtOR/WMUh4LGnU7VgnRJG90PJmJ99PlnWKGjGNsZw7GhbIQEX8ENYH8lN+NhDUWyDs195K7f8fvVJEAU9HHkAmYNSp7BVQlsSL33VMscwIw9M/W/+HCn0o3hnJ6sU7V8hCkTIR5hVnRhCNcb7p/6MM8PWoJ5P0VII= 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=u+MY5m6n; 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="u+MY5m6n" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-8353df9bc7eso4776750b3a.2 for ; Mon, 11 May 2026 19:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778554607; x=1779159407; 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=ea9lHDZ5Wm2cbsLyseN3u9E7vph0SkqBcOjuJpOzgU8=; b=u+MY5m6n1JlEAzLbOeHv3Bm/Cs8dBm1kUbxFn0JW9BY+WU6Y+tZcSC8KPAHVkSEccJ aE1Y2vn/wY0H/GGhj0eCl72exHa3DC2sQYZJlpUTJFhdQb7RrWlZMMgbShviN/R3Mffe e4h7Aw2jYJpkbeinG5+eEeKSrSkrjtqR2rUZ3CN1pAapf9eItBCHQuyu8e9gX8QVgDEd +bfq00RdnwOtHFW34HRlUd86eTCeDWR2FGsCdQiPy/gCsfNPlMfJ1cOsi254GpIdkXfw qpQSd+HSUKLD03GMLgGaQq1/gvYlPbEX93cv7UIuR7B5xjFJerbkZLQTSDOFVXmx9r77 ewcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778554607; x=1779159407; 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=ea9lHDZ5Wm2cbsLyseN3u9E7vph0SkqBcOjuJpOzgU8=; b=Mg4h1+Tk/9A8Tx6jy/zx7/fFE1nMDBik2kNvkMN7qYnX71fQHYdWQULLg9ePG0VEln 7y0e3vKiz0617aX3xcfVBoPAj5+dx7NMJNjnG2q3ziMAISjV8qZB2ey8+D+1d8DA8owT 3pWnuiL9ahsRCrY2il5Qg+YS7ULo/Wp3rXhaAiTAw62SugAjKUAqMsDIoU6YlWIDASXd GSrPA89qyPHQFKTYj1EghZk++MwzUh/Phh9d0tEYSQHlFi4twJoUpacePTONaY3/ltnQ CWI3TXv+/JfTeKOa+zbzmGKnwoPqcMBfvFcveoMhGsKQKEeXkFLH6fshWGeUxff81jIz 7WPw== X-Gm-Message-State: AOJu0YwPj6RNlo7s018+Cs0fLMrCA8OF8PwYadtyp+m0o+IGj3r+fq68 w2n3hwWBNkYjZUz7SdWgf+6/bue1hpV31vLkd1QvS7fhk5ZsOvkwgz/rN11QQv/wHhNS6/vAY/J W8imrPzDBMy8MsDxlsHNxBoaJ60SipGI88fUnZBxnC2twiLHqBEavEWlNzVlzx1b/tIFoINXjq1 FGoB7uGOWwTOiZTpme+MQSuMSSL4vuJFaiW+1Be0LQXVZPaBXq X-Received: from pfbeq3.prod.google.com ([2002:a05:6a00:37c3:b0:82f:ad57:40bb]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:aa7:98c6:0:b0:83b:c487:43d2 with SMTP id d2e1a72fcca58-83bc4874759mr15893533b3a.36.1778554606324; Mon, 11 May 2026 19:56:46 -0700 (PDT) Date: Tue, 12 May 2026 02:56:13 +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-4-jstultz@google.com> Subject: [PATCH v29 3/9] 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 4aec446cd900c..2033b58d3c741 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) && !dl_se->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.563.g4f69b47b94-goog