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=1795007737; b=CT6ONhbPw/UjO/juTWM4TG9c17Xska0flul22rGVB275AUpm3AILYLl9WT4HkRLVfpfI jTtUSyegctfrjlR0ZY0I1V1MRjPgz+zmjpLVkEGDN/+nRBGIGxhmINv0Y/P1j6WsJi49/ 2dTEJ9ckFgAfPz8LOCjxyI8svDKFsqktg+xQ1Fy6k9CB1hOm4aMxlTTAnLTiWg1tnJnvv 77KE9fLgEoXaxUSw+3M1MOmhvE4ffr8f981tPBvyDOa13ZXqQelh69RU9tPOUOj7twvfy 1fnFhgYLZr7KjWr6SC7RhXIRFWnhdTJAlrAm1U/i+iZG52UjN0yXkkLoSH2VqfFqxIQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795007737; 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=GDBgSBwB9SZv912xAYmFSFm0+XZuKPzPjOZZNdWEPXQ=; b=k01nXQ5jux+5KhjuHth5OvME2FVcmNPZ2/gkXi3q1231x2FqW9Ok80YQ4T2rqmHkqiwx U2+/4bja8p41FypEMVWPUgZ91V7wJLCaNeqyaBhKWpTYO5Tac1mGzaye0ihPdezSvvmDk TGIVyz5X8VjGAaZWFRxQO9CaeyeuXpCh9Ui6rusKPr6RTJ1be53HQhzF3uu5jNCL6qRsm ybG4bsWz/PKdAJWxG45oyN6bbRUtUAHTuZ8bRe7mEG9TJr5d5C3XLKYCCpIgpKu8THbH9 VaWq1/P67djN1JDE3sVnfxmUdCnH+0VZ6Ck07v/0cC3hg3pWQNM3CKr79dU2SE6dsvg== 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=dw2tFieo; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=aZ71aw2n; 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 9C15D606A32F for ; Wed, 18 Nov 2026 13:15:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C15D606A32F 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=dw2tFieo; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=aZ71aw2n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795007735; 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=GDBgSBwB9SZv912xAYmFSFm0+XZuKPzPjOZZNdWEPXQ=; b=dw2tFieoV2fUktIlo0TDK4I8UddhaWCMjQ0RpJmBwGRrUxLeTyC9lJV2MMZi1yZ2WLP5dN pYIHMhX/LR1ysEbldW1KdHlw3RLwaNPw0TzqV/TIiPnEsZUkO+pvdhAz3n0nYk9jaOC8r7 gfhq3iKct+gLMo+hhnQF3t0piot4PT8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-388-J9Eik7G6PXKiYnodd98ClQ-1; Wed, 18 Nov 2026 08:15:34 -0500 X-MC-Unique: J9Eik7G6PXKiYnodd98ClQ-1 X-Mimecast-MFC-AGG-ID: J9Eik7G6PXKiYnodd98ClQ_1795007733 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4a7c864000eso314187f8f.0 for ; Wed, 18 Nov 2026 05:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795007733; x=1795612533; 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=GDBgSBwB9SZv912xAYmFSFm0+XZuKPzPjOZZNdWEPXQ=; b=aZ71aw2n8oHteORzK1U/UStkmYdaD98yxYzrW+hkEZQEEtPaFjB1Y6q4hV4xCJpCwx cnsqw71jhW44xU/UIWFXJtPXRLw4bJe7KtTVNGUFrYhkQnPGngKWt/+mC5OstdzU++IZ 3esEFjloz3o/Os0RkoqXLx1TvuAQaBu/u2lN74HCh7hgrmNG/xNaJqA9FbFy0HgdA7nK z7CBcJCq1Ij9WGdnNevbF+o45xuwfsprrcxTiqlKYd1kwpeDIUB1wezCjoL3DRNyTmcS zbFa1C2XKYOstvughcn84NKIzTZKoeQ3bIV7C7lTMtIuXJRm1gWKJiRRKp8JxjYdbzRS PNkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795007733; x=1795612533; 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=GDBgSBwB9SZv912xAYmFSFm0+XZuKPzPjOZZNdWEPXQ=; b=QM8WaHRigEc5z/qXD4PiGJajtlWNuvWgB1CeTFAQaOv5LS6Q4OH+bBC+Q8JHlfAYso sQ/wboB+c++buLH3fQwe99bL5Y1VipuCq/8S3vA5ahH2ssOcrp2lRaoh9qJvENeXJFbx k0f6QL5tBpPLPlNRZ/QR6BBIGygPFVFB0sPbiMhYZKP2xXD3wfhd55Q6DkCV4qUWe6wd Xxl1ouTMyL5N0AwKr6giIDOTONWjhGnbX9kKT9ZEOBJJ5tRTyj4Z4ekkABQexM1cn2W3 aequtLW1PWsBTmUMXUNH+Eq4MFovAlFTp2zoUxuD9CS501fCKnicOo/xW72CUslqPsyR V1pA== X-Forwarded-Encrypted: i=1; AL+hErE/CbT1SrMEuqwk1s5IqTbNthc5b2QxYkPy6M84eHhxTqSmNPruqSA2E/6JroWsVmx5R5lVUdm0CtsDsiU=@vger.kernel.org X-Gm-Message-State: APuU4Z9n6CfMbhuUA+8yzVC+aSor4Rf3CZGdG1jxjGAIW/bnOY7ibEGL bAqCMSlnrFMj8Rt1JQQyGhYXSHU4rV4isFvknzMIgMiJHr+maBooqQ4voX5EIy405uN6uGfZO1k +Hl46+P/HHK00YABhcSjbpSkaatPr2KEBOvEMy60FvbFsalyH4C7zmSfxgBzzY7nN0Q== X-Gm-Gg: AZFdTZfAD9XXV/oAOvHRgHRYDMl/zik15RFo7UmDXGQj9RTABvADMJV8Sg6f1sQfVZI bSWYmcKVM9E9EjOASAmwNSSuB6mN+tQpTpMqaIDzL02c/xpEKA6PizmwE5BG9OGf/qY9UbkURMS jQgA/H/XyHgQPkiNnBB4WFLgIVi30wR1nGbQ/J8PAoO0E6CQtF5Pgx2xTuygvsfD+YLsPWFyq+O z2I7YCDzMQADma0aRFjAfG8h6Hh1NU411NpxbNJ8zAfJSXIurhJQZ64+iBXGb19Ps1gbpzB7n+J oqZwKOe+u3HOfQnbojoRfot+UI1gptMs91Fk/3K7K2uJrTEc+B9gKpzx7pd0s5fKxj+EyS1uggl PKsoe2Ef6NtMXmqN6zK/sogNR0Wqok1Ptsi0WWadLRCckpox8y1S50QDRrT/svByRfKEe1NM7iE Adqn4= X-Received: by 2002:a05:6000:1889:b0:4a8:714:7ad4 with SMTP id ffacd0b85a97d-4a807147c78mr1864897f8f.32.1795007733067; Wed, 18 Nov 2026 05:15:33 -0800 (PST) X-Received: by 2002:a05:6000:1889:b0:4a8:714:7ad4 with SMTP id ffacd0b85a97d-4a807147c78mr1864799f8f.32.1795007732558; Wed, 18 Nov 2026 05:15:32 -0800 (PST) Received: from jlelli-thinkpadt14gen4.remote.csb ([151.29.158.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a64b60940csm4651876f8f.0.2026.11.18.05.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 05:15:31 -0800 (PST) Date: Wed, 18 Nov 2026 14:15:28 +0100 From: Juri Lelli To: Mathieu Desnoyers Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.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, 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, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH v7 08/40] sched/deadline: Do not replenish a boost from cleared parameters Message-ID: References: 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: Hello, On 17/11/26 09:10, Mathieu Desnoyers wrote: > When a SCHED_DEADLINE waiter boosts the owner of an rt_mutex, the owner > runs on the waiter's parameters, through dl.pi_se. Commit 2d3d891d3344 > ("sched/deadline: Add SCHED_DEADLINE inheritance logic") calls this a > temporary solution. The owner is never throttled. When its runtime runs > out, replenish_dl_entity() refills it at once from the waiter's > dl_runtime. > > The waiter can leave SCHED_DEADLINE before the chain walk deboosts the > owner. Its parameters can be cleared in between, at its 0-lag time. > replenish_dl_entity() then loops forever on a dl_runtime of 0. It > holds the rq lock with interrupts off, so the owner's CPU locks up. > > O is a SCHED_OTHER task that holds the rt_mutex L. W is a SCHED_DEADLINE > task. T is any other task: > > CPU 0 (O) CPU 1 (W) CPU 2 (T) > > locks L > blocks on L > rt_mutex_setprio(O, W) > O->dl.pi_se = &W->dl > sleeps > task_non_contending() > arms W's inactive timer > sched_setscheduler(W) > W leaves SCHED_DEADLINE > task_rq_unlock(W) > > inactive_task_timer() > __dl_clear_params() > W->dl.dl_runtime = 0 > > update_curr_dl_se() > enqueue_task_dl() > replenish_dl_entity() > runtime += W->dl.dl_runtime > loops forever > rt_mutex_adjust_pi(W) > rt_mutex_setprio(O, W) > spins on O's rq lock > > Fix this by reading the inherited runtime, deadline and period once, and > by not refilling from cleared ones. They are cleared under the waiter's > rq lock, not the owner's. So test all three. The owner stays runnable. > It gets no runtime. A negative runtime is reset to 0: the owner's own > reservation does not pay for the boost. An owner with no parameters of > its own gets a deadline of now. A deadline of 0 would mark its dl_rq as > empty. The wakeup of a boosted task already gives that deadline when its > donor is cleared. The owner runs until the chain walk deboosts it, or > until it releases the lock. That also covers sysrq-n: > normalize_rt_tasks() changes the waiter without a chain walk. The > warning stays for an entity that is not boosted. The above paragraph is a bit hard to decipher. :) Maybe something like the below? --- Fix this by not refilling from cleared parameters. The donor's parameters are cleared under the donor's rq lock, not the owner's, so replenish_dl_entity() can see them change under it. Read dl_runtime, dl_deadline and dl_period once, and bail out if any of them is 0. On bailing out, the owner gets no new runtime, but stays runnable and unthrottled. It runs until the chain walk deboosts it, or until it releases the lock. Keeping it runnable also covers sysrq-n: normalize_rt_tasks() changes the waiter without a chain walk, so a throttled owner might never get to release the lock. The bandwidth the owner consumed while boosted belongs to the donor, so a negative runtime is reset to 0 rather than charged to the owner's own reservation. An owner with no parameters of its own gets a deadline of now. Its deadline must not stay 0: the dl_rq uses an earliest deadline of 0 to mean that no deadline entity is queued (see inc_dl_deadline()). Until the deboost (which should happen "soon enough"), such an owner sorts first on its CPU's dl_rq and runs ahead of the other deadline tasks there. The warning is kept for an entity that is not boosted. --- > The reset bounds the overrun. But a runtime of 0 still counts as > exceeded. So until the deboost, update_curr_dl_se() still requeues the > owner at each update. An owner with SCHED_FLAG_DL_OVERRUN still gets > SIGXCPU. > > With a 300ms debug delay before rt_mutex_adjust_pi(), v7.4-rc2 locks > up in 8-CPU VMs. A kernel with this patch does not. > > The Sashiko AI review of the third posting found the lockup. Juri Lelli > suggested this fix in place of a larger one. Also for other changelogs, I am not sure this kind of info adds much, as I fear it will be hard to track down in history anyway. > Fixes: a5e7be3b28a2 ("sched/deadline: Clear dl_entity params when setscheduling to different class") > Suggested-by: Juri Lelli > Signed-off-by: Mathieu Desnoyers > Cc: stable@vger.kernel.org > Link: https://lore.kernel.org/all/avL8oOtjKqVNR7-l@jlelli-thinkpadt14gen4.remote.csb/ > --- For the implementation, Reviewed-by: Juri Lelli Thanks, Juri