From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 9FEFD3542F8 for ; Fri, 23 Jan 2026 07:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769152304; cv=none; b=Ml/HWsj5yOKBdNYy5uCuUHFb8jrUmAFC4RczQbfX69mWS54u48mWJZTxIwvZOaGkh+X4eqqX5wv8Ds+pd6cWfScIgTSBV9rRZjI+BvBZRfh3IbTP+tJRMIVE9i5JAVoR4wzo0CxS/YgqSp8QCNlOLFwvbch6MrGlonSCDRWk3/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769152304; c=relaxed/simple; bh=R7Bm5PZ8wiVGLs8ZuDcwaTr7E9iru1NkzD4OuDHVvH4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SWs/5dH8G0Y87DU55oE0jNMXy0ohk1l0SiHM6QL9KnXP0JHFciQ/t8yoAxwu8AkL16m9R8ph9uE9eZA28gAcB1W+HBmxb16Gk76sZ7Uzam8DNvdI18lGUvI8NAmQH1sSJxcR91ruGRcF0K7UUwLD1YpnYQwRxOlZCVVaTXkCBrQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Lz//zExV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=GdvAWpzd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lz//zExV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="GdvAWpzd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769152301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n6b1cjawk6zPGklti7vHmLYuyCRZ99pwdI/+iQMQVqg=; b=Lz//zExVc+++8lI6OObAnC3jElQwHgjdcT8mzi+Lq+UOM0jP2eIzA8evQdfcopRJaQ6knz zopWF+Ya8HGNZzZk2ArfZPov8nk/UNMieIrXK80hOuKiMKq5LAsSwlZEu2z3o5P22BuT5Q qKifXYI7JMzNMCKby7a9FBoLbw55VUE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-5YrJLvIhNRuJKYWRIoTvtg-1; Fri, 23 Jan 2026 02:11:39 -0500 X-MC-Unique: 5YrJLvIhNRuJKYWRIoTvtg-1 X-Mimecast-MFC-AGG-ID: 5YrJLvIhNRuJKYWRIoTvtg_1769152298 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-43284f60a8aso1333770f8f.3 for ; Thu, 22 Jan 2026 23:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1769152298; x=1769757098; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=n6b1cjawk6zPGklti7vHmLYuyCRZ99pwdI/+iQMQVqg=; b=GdvAWpzdq6JefrmHXbQSr4Rod4RaeXVfPQJOUu19P7q1VIxewktu17cnc7SgwZdd/W rK5Xq4I+PwzHNm/kuE6C0vi6+s2z3FmMuO0EWgX2/NL4guSahwPcgj4CBlIajJ3Za0Kz xftYapb/FzMaJ435pHSprAwBb58z22HEsARgMbeitQZ8mFFtiOKQO/AIY+waDPEu2I8e CoGsKtCzMkSyBlgvv6rsKp7QCp/EbJ6Inoy2x0D+ILS64V4RdyKMXUQkCyKRfMYkWbBv Z7rwV6c58VRCJPGvCIx3rjwqAKJidKxvcwdoFUweqdOnzvRtH3NR217xdatw+Dgo+ulO H2RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769152298; x=1769757098; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n6b1cjawk6zPGklti7vHmLYuyCRZ99pwdI/+iQMQVqg=; b=kvMOxVNyG5zaaiEjY8+abr0nkDiGRdd9Sbwlp0zsXSCVIYRzO1+STh5sN10bbTnum9 vxM9USMAwYVinOLejvC9UdBzRfQu5Js3ClbU2RXvtKMbOzSBhVgP45JhYJLTsxDKMwTy umaajWBRzdn89z/EblsCUjarsn6SQkPcTkaGs1eRJWvtHIyn6UJYMdjBXLbrjE6yGp8+ EGpEVnWby3bCusu5z4+KBsvwXqJecMsEPum3BmDn4r/UZlasR3EdjTctRkwOtILyIzKJ Kfkqw26gN/Ay52DnrZUzo+3ib9Zm3iNLOV2F8T/azj1MxBxDzu+6GPdnKcvGhALjGace 3sKg== X-Forwarded-Encrypted: i=1; AJvYcCWjj3GF4Q4NZDqE8zFTv31Bgr54JIhRn1b11DqAUR6HJPU5LY5kUAXQ2VfLHEx8qoTiRzdChtmBOcgPRJw=@vger.kernel.org X-Gm-Message-State: AOJu0YxYob+eTBWzru95gyDcp7OoPtNJNsrDcT4Nm8hPLWgK8aH+RtGg TNvb8XAjoGSKrCmM8oY92tmjYmwX+auPX5jj3UwJrXcu1UHf64/PMVcX10fXnmQcL2Hm3IYkOdC 7KUsdo6jM6WTaV/dMVXtTf+4Ast8aYfGUypcRa5ve9EBOU2Os3mHZnYKFYBSEJ3Flqg== X-Gm-Gg: AZuq6aKw9Lv+kZXo8F806Wq8Vcp45GEz6ieiMFkJFeMk6wc9pedWpaFR5nLd0hqFDK4 awDvDbJ0iSw+fkbvrLCPB8XmGtZur6NH2on/3VksQRXehMmUXKTAIuANZUFOXoxCv3lfYdCrt+s MW/qUn6NnX3RsQ8JWJ9jwf4H02nuTsCy+f6iEfJLD6LttwGvrKvVmh7zzJy2Q29j+llwoPeN7Nr zktoAPuhd85xBAZ/UuJPKH5UIaiGxhg/fRDdlb566+vrK5H7ARH5Lbl4d6zHrCkK2VeaTSpGOWr M0ncu3ZuXQwC/PpnNYjkSxyw8NfO5kTt0w9ixWnCH7nViMUtLYU7zYze+L2y/Uxue/WFMgxbsB6 KAMk9iuOHcOkkOnSGiBiQwNgREq+PX6q3SaqIrveT X-Received: by 2002:a05:6000:2c01:b0:430:f62e:d948 with SMTP id ffacd0b85a97d-435b158a313mr3012467f8f.9.1769152298429; Thu, 22 Jan 2026 23:11:38 -0800 (PST) X-Received: by 2002:a05:6000:2c01:b0:430:f62e:d948 with SMTP id ffacd0b85a97d-435b158a313mr3012432f8f.9.1769152297985; Thu, 22 Jan 2026 23:11:37 -0800 (PST) Received: from jlelli-thinkpadt14gen4.remote.csb ([151.29.129.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1c30293sm4719683f8f.19.2026.01.22.23.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 23:11:37 -0800 (PST) Date: Fri, 23 Jan 2026 08:11:35 +0100 From: Juri Lelli To: Andrea Righi Cc: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Tejun Heo , Joel Fernandes , David Vernet , Changwoo Min , Daniel Hodges , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/deadline: Reset dl_server execution state on stop Message-ID: References: <20260122140833.1655020-1-arighi@nvidia.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: <20260122140833.1655020-1-arighi@nvidia.com> Hello, On 22/01/26 15:08, Andrea Righi wrote: > dl_server_stop() can leave a deadline server in an inconsistent internal > state across stop/start transitions, causing it to bypass its required > deferral phase when restarted. This breaks the scheduler invariant that > a restarted server must re-establish eligibility before being allowed to > execute. > > When the server is stopped (e.g., because the associated task blocks), > it's expected to transition back to an inactive, initial state. However, > dl_server_stop() does not fully reset the execution state. As a result, > the server can be logically inactive while still appearing as if it was > still running. > > When the server is restarted via dl_server_start(), the following > sequence occurs: > 1. dl_server_start() calls enqueue_dl_entity(ENQUEUE_WAKEUP), > 2. enqueue_dl_entity() calls update_dl_entity(), > 3. update_dl_entity() checks (!dl_se->dl_defer_running) to decide > whether to arm the deferral mechanism, > 4. because dl_defer_running is stale, the check fails, > 5. dl_defer_armed and dl_throttled are not set, > 6. enqueue_dl_entity() skips start_dl_timer(), because > dl_throttled == 0, > 7. the server is enqueued via __enqueue_dl_entity(), > 8. the scheduler picks the server to run, > 9. update_curr_dl_se() detects that the server has exhausted its > runtime (or has negative runtime), as it wasn't properly > replenished/deferred, > 10. the server is throttled (dl_throttled set to 1) and dequeued, > 11. the server repeatedly cycles through wakeup and throttling, > effectively receiving no usable CPU bandwidth. > > This results in starvation of the tasks serviced by the deadline server > in the presence of competing RT workloads. > > This issue can be confirmed adding debugging traces, which show that the > server skips the deferral timer and is immediately throttled upon > execution with negative runtime: > > DEBUG: dl_server_start: dl_defer_running=1 active=0 > DEBUG: enqueue_dl_entity: flags=1 dl_throttled=0 dl_defer=1 > DEBUG: update_dl_entity: dl_defer_running=1 > DEBUG: enqueue_dl_entity: SKIPPING start_dl_timer! dl_throttled=0 > ... > DEBUG: update_curr_dl_se: THROTTLED runtime=-954758 > > Fix this by properly resetting dl_defer_running in dl_server_stop(), > ensuring the server correctly enters the defer phase upon restart. > > This issue is quite difficult to observe when only the fair server > is present, as the required stop/start patterns are relatively rare. > However, it becomes easier to trigger with an additional deadline server > with more frequent server lifecycle transitions (such as a sched_ext > deadline server). > > This change is a prerequisite for introducing a sched_ext deadline > server, as it ensures correct and predictable behavior across server > stop/start cycles. > > Link: https://lore.kernel.org/all/aXEMat4IoNnGYgxw@gpd4/ > Signed-off-by: Andrea Righi > --- > kernel/sched/deadline.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index c509f2e7d69de..214fe62a59723 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -1813,6 +1813,7 @@ void dl_server_stop(struct sched_dl_entity *dl_se) > hrtimer_try_to_cancel(&dl_se->dl_timer); > dl_se->dl_defer_armed = 0; > dl_se->dl_throttled = 0; > + dl_se->dl_defer_running = 0; > dl_se->dl_defer_idle = 0; > dl_se->dl_server_active = 0; > } The fix looks good to me, thanks! State machine above dl_server_start() might need updating, though. Don't we want to add dl_defer_running = 0 under dl_server_stop() for case [4] D->A? Also for '[A] - init', dl_defer_running = 0 (remove /1)? Best, Juri