From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 162E31EB5FD for ; Tue, 13 Jan 2026 09:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768297034; cv=none; b=Q6ftBkuzuqkraBsfgGGHSjEyMdxc+EjP3mTPn1R+5RIZEhk8zrsqq3rMXlFeI4bGNfEbdtkG00T8wtfT8Sc1ZFCpR8A0a+1UmPKP7CZoOYXHGa8NNYy/dHPCEYtd0dMLp5/36y+0o/PC7nmuuKXkYuadVpI8Pz2aCA5XsZ6Ja5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768297034; c=relaxed/simple; bh=gC/v1z73qLqTHJw7oJjN1bOlEljUJhFNF/XaTAJu7K4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=l5JhKaumKrSbcr/YUqmkmR6pJw5dbBsmn0tBLSAvfsA7XqfM0DEJuQ8VRHh77HPpcwMT8FnAwdy0NlZ2s8DXLzobzJil0KOzQOcfzVfN7ZwHqPAA0fKqKeoHyIHk2X1PSBYGkoGhSueT6Ie3zhGkcS6yanZ4K6GS7/nhztoFBb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=FxOM/W4S; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FxOM/W4S" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Qtny48bcMxpEx+u+RMMHIHTQyZ90qK3C1i7Hm+2k/mM=; b=FxOM/W4Sgv8l/kcDsZgJXbr+Y+ +krw+/DQtG5ndyRWuQB8T1iluFcHi6dfNDYRw2wqTJmDr21hoN+RjhSGK1csPytlmOC7M2H/lzwFk KFWZIU7kKFJrszo4qOFnr8zr/TpC2qqdNg3oWKVbQzEuJbD+21CRA4NvcqoTDRgnttPpFNxivliJ8 aYxVWFjJPgnli2m8LegTBGyebltONbl8dOwP49Tiv9BPR873BOeSYwvIEEr2KhstXLdpsKBx2+GrW 7JQy+UY95t4LW/K0sJQ685J+kCwzL2ScCDmTMKzDsCdi4Xu99rteFxi8XZfyNpDzfcNgPNxTWUST3 vrcaEwvA==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vfapn-00000002Sud-47mF; Tue, 13 Jan 2026 09:37:08 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id D77BF3005AF; Tue, 13 Jan 2026 10:37:06 +0100 (CET) Date: Tue, 13 Jan 2026 10:37:06 +0100 From: Peter Zijlstra To: Gabriele Monaco Cc: juri.lelli@redhat.com, Ingo Molnar , linux-kernel@vger.kernel.org, williams@redhat.com Subject: Re: [PATCH] sched/deadline: Fix server stopping with runnable tasks Message-ID: <20260113093706.GT830755@noisy.programming.kicks-ass.net> References: <20260113085159.114226-3-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260113085159.114226-3-gmonaco@redhat.com> On Tue, Jan 13, 2026 at 09:52:01AM +0100, Gabriele Monaco wrote: > The deadline server can currently stop due to idle although fair tasks > are runnable. This happens essentially when: > > * the server is set to idle, a task wakes up, the server stops > * a task wakes up, the server sets itself to idle and stops right away > > Address both cases by clearing the server idle flag whenever a fair task > wakes up and accounting also for pending tasks in the definition of idle. > > Signed-off-by: Gabriele Monaco > --- > > This is really quick and dirty but seems to fix it according to the > models. I also updated the chart to show what is happening here. > I added the same event (server_resume) to the model. > > kernel/sched/deadline.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 138136742871..1070e93350df 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -1376,7 +1376,7 @@ update_stats_dequeue_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se, int > > static void update_curr_dl_se(struct rq *rq, struct sched_dl_entity *dl_se, s64 delta_exec) > { > - bool idle = rq->curr == rq->idle; > + bool idle = rq->curr == rq->idle && !rq->nr_running && !rq->ttwu_pending; This is idle_cpu(), perhaps we can lift that thing into sched.h or so. > s64 scaled_delta_exec; > > if (unlikely(delta_exec <= 0)) { > @@ -1560,8 +1560,8 @@ void dl_server_update(struct sched_dl_entity *dl_se, s64 delta_exec) > * | 8 | B:zero_laxity-wait | | | > * | | | <---+ | > * | +--------------------------------+ | > - * | | ^ ^ 2 | > - * | | 7 | 2 +--------------------+ > + * | | ^ ^ 2 | > + * | | 7 | 2, 1 +----------------+ > * | v | > * | +-------------+ | > * +-- | C:idle-wait | -+ > @@ -1606,8 +1606,11 @@ void dl_server_update(struct sched_dl_entity *dl_se, s64 delta_exec) > * dl_defer_idle = 0 > * > * > - * [1] A->B, A->D > + * [1] A->B, A->D, C->B > * dl_server_start() > + * dl_defer_idle = 0; > + * if (dl_server_active) > + * return; // [B] > * dl_server_active = 1; > * enqueue_dl_entity() > * update_dl_entity(WAKEUP) > @@ -1741,6 +1744,7 @@ void dl_server_start(struct sched_dl_entity *dl_se) > { > struct rq *rq = dl_se->rq; > > + dl_se->dl_defer_idle = 0; > if (!dl_server(dl_se) || dl_se->dl_server_active) > return; Yeah, this seems sensible. Let me pick it up and do that idle_cpu() thing.