From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796223357; b=GjbaCY0lkqCTo1iIKFU5LznPod4f4kYji1omGPPBHtOHefzbWSOk0lecRbflEgBjoION nR9SXRX/FjxJIwIcUlpJe4rrRJpx3LYGqxkh7XPPfK+cFZvPYb4JmxbX1/Su6XPCbMdcj KTJd0DGZn7uhYzjVvE+QiGMcyOM/V9ruBtqh7Ee1wPP2qy1lA3iUax52TqYnpdII+nQY/ 4U4uIZs4jIsmxBF6uO3+o1t5/F3r7a85WTsb9Hp9vhCu63GLw8EiTCtVrVOJI+neYFVIo og8gG1s/RFyxxiZL0Z+3luk2JGJ/BqX6tsJrplEZnc/c9SUV81KLVFP0TSLdj+wemng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796223357; 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=IylZmATch86kz7NhVSpeUAMLQCnXcdk5BsH+dN9befXrmKuvBANGUujldPlztrzBpNKj 1hyFgLgeAAhM6r6fSAKeoq7S4TDF7t7wEybLGMPJD0wXyJ5I8uA8QlUR33IA4uvRd23dE GCezR9rVeHRlCr9Zddcoqs1wAWT+lcwWmxnbpRZedKFf6W4K9F4i4j8xdPk6uVpeSmfBc 6ZKTSJhnm1kc+gqfGkRmLweIwwsTjq2kBNC5obCuuGU/3fi7HpNjReZ7CtkrPgl7sMbnd F881VLfyczlxI0C2zMF55KN2apnGwp+NtcZxk1hllJfpVJ26OVt+dT+HjZfTXFI3Pyw== 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=GwSDAadZ; 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.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 72BC9606A330 for ; Wed, 2 Dec 2026 14:55:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72BC9606A330 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=GwSDAadZ; 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=1796223356; 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=GwSDAadZ9jvtOshYdjfxro137X20yVuHSdLAQwELnVn7/FtclAJ/YsKQfeIDvNbG4Ebkyc BTSNgWBDcg1wddVhDM6h+R1hBx2HQVAFk9dJo6nxnmjMsjD4dXuTCLiUGU3+sTMKK1aRGr zviIvYiQfuJtlZzvlzgeIPmwIna3KEU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-nbcfikiBP_W3xKcXu3UrMg-1; Wed, 2 Dec 2026 14:55:53 +0000 X-MC-Unique: nbcfikiBP_W3xKcXu3UrMg-1 X-Mimecast-MFC-AGG-ID: nbcfikiBP_W3xKcXu3UrMg_1796223352 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4bba856092dso54465795e9.1 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=tYvM4GTqBOyk4VesOzaURMIi9BPaOPfWvhoWexHpYPg=; b=kIzKmglgKIg4RkIGKnmY/qPtVf/BGUvxhrfuqsRXEnI+b3iv5822zOc8svf3QLWbbr eBoic62NpT7FaYeQy3V+s+aTyRnf8Ir98zNHZD5P6A/hyWPzBLSNlrWKzrzI8Vj0nySd 3X2CxPkbBcLx5NPo0U+zos1Vw6V2F+3q2T36EMUJKgUHPDL75XM+NZXHhKe7DhrNNOoQ v7NZ/Bq0P1i0AsR5rNCm8UAmHJYNb1pJQqSiLxEpDk4YoVn/gbXemNSJRo44yqDhkcRp iashRPXTM4nqrS63OlBlejLRyXvzV72bRzBjKhukdkCzpiJPLQlUgxp+EC38PBbiMOeY vukQ== X-Forwarded-Encrypted: i=1; AL+hErH0bw75CCp7ccHY4sgjJ+XRaZU42TI3v5E3hfVbLj3iUUI1cyDwwr0F1BXoc3Fp2BD/N7/FFZYfPwzYhCU=@vger.kernel.org X-Gm-Message-State: APuU4Z+nitjPRwH6xl5FU2wOY3U+sPMJHmY5eCIkZpBQ5JLUQmvqxtIb uluGSBt9rwi/bVxj7a/OTShG7vOW9mWpBnuIaIAU/TsV6LoDVz9xoKlAGo/XFNpyr04Vkq4JyZI pcNuBNJBgldLipLjiOZBxs2rxyyl9vM5SFy1lcypFdYGRR0vkPKRgWOW5QVhi8bLhdQ== X-Gm-Gg: AZFdTZcKs8CQCS04gsaWJtyhoQPtC1HbqLJewMcWiYOBrRPOXVIiuSmr92LLiMarBV2 hOwZoN/BC1HMClParluXZo6vZ3j0erej1f/If2ZBty8YRKm0CRdW6sAxQqtM3/3ablUHdn5G31c vwRUgIriei00SwuXY+WJ5UYxiAGd/vN2z57aOWt/NIIJAlL6nDWlylXHeZFxja5kVk3YclsAkLe yFqlvU5YfRWNYfGSj446avaNUacn3PbvRfEKzciUErbCcUsdkwHkDiG8wEeCYExBiO0M/M6uCs5 D9JwPYuCdZCD9bXl5PWeuJrc73srhlaqQCXYSTIln8klrsV4zja234VAet50xIGuWnYwxPuZcKc grQBZPqQk4kkynJaHcw2fVnpSEupkgNE3RzRljDO+GbxMJj79veooUaE/kkL0WgaD+TdKwGgmhx YeymU= X-Received: by 2002:a05:600c:64c7:b0:4bb:872a:f500 with SMTP id 5b1f17b1804b1-4bb887c2697mr789294365e9.3.1796223352298; 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-kernel@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