Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796223356; b=vjtbrudGLFW09ymJJsnKJzx78A26a8CJr60WEsi8W+HIYv221f/+dQqwgkCPf1gX+6KW HBt82whpJa9TZErVU4mPMxlq0D/t2f4Y/w4ofqJKedDJcT41pQ6kU8zv7YH0JqYBZP20k 00W1SRFc8QFDga9/7+HNPMDKV/GzeSMMpfqN/U+da+BNCuvX75WCssxMxrWLTxu5EE27c PDKuM+g6IbYpnfvadylv6IRK4i+Gv/HxZLCdGordP6GPSIp2qkMxCItydv9nMcoSuIfiH 5DeLh90gZGPunYwo92CDYMI+/XE2kMryM5mc6bI45pXYsQBLQnHzvvAvP8/wn/DY+Jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796223356; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=tYvM4GTqBOyk4VesOzaURMIi9BPaOPfWvhoWexHpYPg=; b=c60rQD4DmiWwM8cb+KhYMim0lrMkR5E5tiuaT0D1x5GvujQs/Wy0cHZB9f21VJou44pE g0fFmn4MoD7hsYaI39JgTq5uTDy/jUgLuqafjOGIIkZ00UZA1ov5K8H+sf80Vt1Sn5ubG 3kdURNsJUkDfQydsLgtoYZZRQ06sy/TqGu6AocNnX5hpnbZrQ+E1/Qn8iIy4eGwwLJMHO rm1a/WTyZqMDc+qxlnOucfykCq/iGQjN0kotkat333ACcxoAolEYLU4MyBZWfo1WOHgGr hf6jBpgJTZP9TpPZY3vAPwHtpfPCoWczJgGBZR9KdguFMIECvCVkiA7ggrXUgltwDHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=il2JXPnI; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=djt0RH8v; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FD7E606A32C for ; Wed, 2 Dec 2026 14:55:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2FD7E606A32C 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.a=rsa-sha256 header.s=mimecast20190719 header.b=il2JXPnI; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=djt0RH8v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796223355; 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=tYvM4GTqBOyk4VesOzaURMIi9BPaOPfWvhoWexHpYPg=; b=il2JXPnIKfHCIp1ATyFAtRJd+7OvWoO6LVXZli84JDIrX7a0Vd2FR3K8mcg2HlhZPs6AOG RLWWPWGUAA85RC2J9HB3Z3QJGsq/ouc1iwcQ1ZLWkiOgcdXX+6plx1TtftXg6ypebhnfXl Jvj0ApsozA0ckrub1VcrPzG28htEMDk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-D_Yde2EvN7ayWW2G4tSCFw-1; Wed, 2 Dec 2026 14:55:53 +0000 X-MC-Unique: D_Yde2EvN7ayWW2G4tSCFw-1 X-Mimecast-MFC-AGG-ID: D_Yde2EvN7ayWW2G4tSCFw_1796223352 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a009f82bedso94089275e9.0 for ; Wed, 02 Dec 2026 06:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796223352; x=1796828152; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=tYvM4GTqBOyk4VesOzaURMIi9BPaOPfWvhoWexHpYPg=; b=djt0RH8v+mHeRpfudeGjOPDC2NDiP8jguEMcUz9eq0fTc/LCQbGFV5UGp7v0EG3hat HMUVH3QmlYeU2Cjve7LRR/AoRIn8YlhoyxfaLN7Qp9qYZM6T40GAkxND0lLTnLuRc3F8 fxIqaTeNyAvqR3q74FF9DZQIi2RNbHJvCyGwSOlLURWCy7NR5rKXqGvYEGqY27xZyXkj uzVjwhJKs1TWFXWOknrIbj5CoKkmQi3M9E71myvmXKDHgG5+EWz6oqCLJAZRczjz0KqF rIzgu+lDFdlWFUjcmxSLXsXtzVoYfOl1km3+8EsxsaFVNrY783hz7XfgxOmyorlBIft7 VTyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796223352; x=1796828152; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=t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IkOR5z+6LeOmplVRNfC2JfhKpy95vhE BfcEx8W43hFGZv6yuIPny/XeZBwgZDWYWGdMLfHQX62Rf+tzubAgt9EMr4VjLKOhfQeyYShDwcW KDM8E= X-Received: by 2002:a05:600c:64c7:b0:4bb:872a:f500 with SMTP id 5b1f17b1804b1-4bb887c2697mr789294305e9.3.1796223352278; Wed, 02 Dec 2026 06:55:52 -0800 (PST) X-Received: by 2002:a05:600c:64c7:b0:4bb:872a:f500 with SMTP id 5b1f17b1804b1-4bb887c2697mr789293875e9.3.1796223351830; Wed, 02 Dec 2026 06:55:51 -0800 (PST) Received: from jlelli-thinkpadt14gen4.remote.csb ([151.29.146.153]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bb989e3sm79882767f8f.52.2026.12.02.06.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 06:55:51 -0800 (PST) Date: Wed, 2 Dec 2026 15:55:48 +0100 From: Juri Lelli To: Mathieu Desnoyers Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, tglx@kernel.org, will@kernel.org, boqun@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, luca.abeni@santannapisa.it, tommaso.cucinotta@gmail.com, mathieu.poirier@linaro.org, longman@redhat.com, ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org, parri.andrea@gmail.com, m.szyprowski@samsung.com, kayracizmeci@gmail.com, weihengqiuu@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev, oleg@redhat.com, brauner@kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v13 05/36] sched/deadline: Keep a departing constrained task until its next period Message-ID: References: <835511935d961be832cbaf24e902762d1926e611.1796146461.git.mathieu.desnoyers@efficios.com> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <835511935d961be832cbaf24e902762d1926e611.1796146461.git.mathieu.desnoyers@efficios.com> Hello, On 01/12/26 12:43, Mathieu Desnoyers wrote: ... > Fix this by keeping the bandwidth and the deadline of a constrained > task that leaves the class until its next period. task_non_contending() > and inactive_task_timer() wait for the later of the 0-lag time and the > next period. I went through the patch and I don't seem to have a correctness complaint about the code. But I find the patch somewhat hard to digest: about 100 lines, half of them comments, and a 120 line changelog :). While thinking about it I ended up with two fixes we seem to need anyway, and a question about the approach. The fixes first; neither is new with this series. 1. check_dl_overrun() clears dl_overrun with a plain store, without the rq lock. On x86 that is a load and store of the whole DL bitfield word, so it can write back stale dl_throttled, dl_non_contending, dl_bw_oncpu, ... values. On !RT the window is a few instructions against another CPU holding the task's rq lock (sched_setattr(), rt_mutex_setprio()). On PREEMPT_RT the task work runs with interrupts on under an rtmutex siglock, so the task can be preempted between load and store and the stale value can stay in a register for a long time. Clearing it under task_rq_lock() should do (siglock -> pi_lock -> rq lock is already a valid order, from signal_wake_up_state()). Fixes: 34be39305a77 ("sched/deadline: Implement "runtime overrun signal" support") This is also the reason dl_inactive_pending is a bool at the end of the struct (8 bytes more per task at this point of the series)? With dl_overrun fixed, it can be a bit like the others. 2. sched_dl_overflow() admits a task coming back to SCHED_DEADLINE before its 0-lag time with old_bw = 0: if (dl_policy(policy) && !task_has_dl_policy(p) && !__dl_overflow(dl_b, cap, 0, new_bw)) { if (hrtimer_active(&p->dl.inactive_timer)) __dl_sub(dl_b, p->dl.dl_bw, cpus); so the new bandwidth has to fit on top of the old one it still holds, and a round trip with the same parameters can fail with -EBUSY in a full root domain. The in-class branch just below does discount p->dl.dl_bw. Discounting it when the timer is active (and, after your patch 6, when the recorded root domain is this dl_b) would make the two consistent, and would also close the window where patch 6 counts both. Fixes: 387e31300b57 ("sched/deadline: Fix the update of the total -deadline utilization") Could you add these two as separate patches ahead of this one (or I can send them, if you prefer)? Now the approach. IIUC, the only thing a returning constrained task needs is its deadline. A constrained task that sleeps in the class and wakes after its 0-lag time never gets a new period before its next one: before its deadline update_dl_revised_wakeup() keeps the deadline and scales the runtime down, and between the deadline and the next period dl_check_constrained_dl() throttles it. The 0-lag time only drops running_bw. A departed task loses this only because, with patches 9 and 11 of the first series, the release at the 0-lag time also clears the deadline. So, what about keeping the release at the 0-lag time as it is now, and, for constrained tasks only, clearing the runtime but keeping the deadline when we release? Something like: /* in the two release paths, instead of __dl_clear_params() */ u64 deadline = dl_se->deadline; bool constrained = !dl_is_implicit(dl_se); __dl_clear_params(dl_se); if (constrained) dl_se->deadline = deadline; /* runtime stays 0 */ A task coming back then goes through the in-class rules: - after the next period: new period, as now; - between the deadline and the next period: dl_check_constrained_dl() throttles it until the next period, for a wakeup and for a runnable return (it runs before the ENQUEUE_MOVE/setup_new_dl_entity() path); - between the 0-lag time and the deadline: runtime 0, so nothing left to spend from the period it gave back. The bandwidth goes back at the 0-lag time as today, so admission of the returning task is a normal check (plus fix 2 for an earlier return). Implicit tasks are unchanged: for them a new period after the 0-lag time is what CBS does in the class too, so clearing the deadline is right. If this works, the timer restart and dl_inactive_pending shouldn't be needed, departed tasks wouldn't stay around longer than today (one less thing for patch 6 and the rebuild to deal with), and the change looks like a handful of lines. What do you think? If you see something that breaks with it, I'd still suggest splitting the current version: the bail in inactive_task_timer() for a task back in the class looks like a standalone fix (exit race, already on v7.4-rc2), then dl_inactive_pending on its own, then the rule. Reading the state once in task_non_contending() (it is read up to four times now) would also help. Thanks, Juri