From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796312684; b=awuPjuXWRzAG6Rk0b8tydrvHLe9v7XIbVpleJp39NlahD06PPV6Z+SLg5QMMvmEVs0F1 f9yPXmqv3kK7c4TayNAyr/viVUm1hoStUbiiOrbHUjsaFO0R3ehVf3Say2GJbUSya1P3L y20pWbv0gtG4YriqCrLGvhMxDHMFOlPJwFR7P03NmT3/016A3EOecqgsW7eIaVlEkY++d qU3vLW0vC2qsaMavXpeDgsdaGB6QQDYxPdExhPwVVN5p1GRIlkGHe8458mbE99Len5Xuq cBYTrxIv8LTKwOoaIctgFvIBd/PGKGMdq/yFIUxuLByOuWOBQxw7evS0rXNHn4HnvSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312684; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=6zGxRjBqN/L7FBmiwv6SP+aL6Pzri8rbW9/AapjqQr0=; b=WGAwsnrAbew7/08R4iPAxiRwOxY8ABEftE3wwSqF5+1dJxAMoS0jVkwqFesaArW6gaQu t9YJmb6loZOXWjprX2up2+SrNZ2gDofhoxL3HKT4QywTeTuAcrvhh2skJob5Yey8hRS0h bJQRapVBlhAW678vkQM9psyREKJeqNetnUGPCoGhjS3DmCSYUEBAeWm1E4z3yfDR0ul5o kNFeLNOTa3f2TXBA7x4cfzGMQb8vPtQF3gyKtn5cQbBdp25mnv3H8OAZF1/VKBLDI99Wf bW+ggex7G+U9d4odSYeQJoT0bi7vC+21qS9I1b6MuRJHU/cvBgjbkdqa1hHXclzHidw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FtsmC6sL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5251E606A322; Thu, 3 Dec 2026 15:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FtsmC6sL Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2D511F000C1; Thu, 3 Dec 2026 15:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796312684; bh=6zGxRjBqN/L7FBmiwv6SP+aL6Pzri8rbW9/AapjqQr0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FtsmC6sL9Cv+njSPFF5cLQoVVH6EYVDHfr5O7O1MlL7mZYH8OMkwhiHvT0IilTCM9 uZe2b8zlrxxT1bHVA1gQTNSHme/HFyLIZUWBTpLgeY4KkW5IYqoGnoJewGr/vMWYdP xGLhh3c+HLroT/Z3E8eKs63qgkem3Zp7skAG2AnFVcJyis1+n4T7dcsmM9oN+8B1tW ZZTRdh1YeBlAEJLtryL+Xqcz1rbnDPAbsLOI0ir5KDdavQEVny3iwvh7yucJpWzt23 k99wNAvILJXZWJrV3Bip8pmvpmWtBnQ/eMscrVIDqMrwdGXWP05gR5K8jYQXiJ5LmP FcNXuIwRjsTAQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 01/39] sched/deadline: Hold a reference on the deadline donor of a boosted task Reply-To: sashiko-reviews@lists.linux.dev To: "Mathieu Desnoyers" Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, linux-kernel@vger.kernel.org In-Reply-To: <22d46c764dc269349e9d1cbb90c880d349974d2a.1796296313.git.mathieu.desnoyers@efficios.com> References: <22d46c764dc269349e9d1cbb90c880d349974d2a.1796296313.git.mathieu.desnoyers@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 15:44:43 +0000 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] sched/deadline: recursive rq lock via put_task_struct() in dl_replace_donor() -- commit 74640640e887acf19101fa00448dad6b61bef633 Author: Mathieu Desnoyers sched/deadline: Hold a reference on the deadline donor of a boosted task This commit holds a task_struct reference on the deadline donor stored in dl.pi_se for boosted tasks, updating it via dl_set_donor() and dl_clear_donor() so an exited donor is not freed while still referenced. > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 20ad13f388cb2..4a73661b62b13 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -356,6 +356,82 @@ extern int sched_dl_global_validate(void); > extern void sched_dl_do_global(void); > extern int sched_dl_overflow(struct task_struct *p, int policy, const s= truct sched_attr *attr); > extern void __setparam_dl(struct task_struct *p, const struct sched_attr= *attr); > +#ifdef CONFIG_RT_MUTEXES > +/* > + * Make @pi_se the deadline donor of @dl_se. The caller holds a reference > + * on the task of @pi_se, unless @pi_se is @dl_se. Put the reference on > + * the old donor. > + */ > +static inline void dl_replace_donor(struct sched_dl_entity *dl_se, > + struct sched_dl_entity *pi_se) > +{ > + struct sched_dl_entity *old =3D dl_se->pi_se; > + > + WRITE_ONCE(dl_se->pi_se, pi_se); > + if (old !=3D dl_se) > + put_task_struct(container_of(old, struct task_struct, dl)); > +} [Severity: Medium] Can calling put_task_struct() here recursively acquire rq->__lock? dl_replace_donor() runs with rq->__lock held and lockdep-pinned. On a CONFIG_TINY_RCU=3Dy kernel with CONFIG_RCU_DEFER=3Dn (or older stable kerne= ls without CONFIG_RCU_DEFER), a SysRq-N interrupt arriving while CPU 0 is idle can drop the last reference on an already-exited donor via: sysrq_handle_unrt() -> normalize_rt_tasks() -> __sched_setscheduler() -> __setscheduler_dl_pi() -> dl_clear_donor() -> dl_replace_donor() -> put_task_struct() -> call_rcu() -> rcu_resched_if_idle() -> resched_cpu(0) -> raw_spin_rq_lock_irqsave() That recursively acquires and prematurely unlocks cpu_rq(0)->__lock while __sched_setscheduler() still holds and pins it, triggering lockdep recursive-locking and pinned-lock warnings or CONFIG_DEBUG_SPINLOCK recursion bugs. Returning the old donor task_struct from dl_replace_donor(), dl_set_donor(), and dl_clear_donor() and calling put_task_struct() after releasing rq->__lock (as dl_task_timer() does) would avoid invoking call_rcu() under the runqueue lock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796296313.gi= t.mathieu.desnoyers@efficios.com?part=3D1