From nobody Mon Dec 1 21:30:55 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E148A23FC41 for ; Thu, 27 Nov 2025 15:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764258934; cv=none; b=n/3dNXAqoMqvIszU5WmTAwxA6ju3BYIHnSntemI+mR7fgtcGBimREVftsPOYSh197GFnkr7IisVxidTF/oIBngXezC8JLXsBKoNkB0GSYAL+aKkmfYqkJ/vXe4bULuw/LRqeHyxn4Ypb4yzKB/vet59BFtpJ63n6QgoGofuZq8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764258934; c=relaxed/simple; bh=AMPcAeuACAsaFjzbU2GMtQ+wDtHJWGFmj8KgJc2nqy8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=oibEjYEJxISf6ZWeswQKvnMslyE7HvV0JRG2Sc+rhzkW6SdB9rLqo+QGso4faYp+NXO9fON687fEgSXAiOXWO7B07WdMZIfK+fsS/pxC6mEHGFSYHcbB6GFQ4mzdqhfpxq3fZXOG2P9jPVFwjzC5eQEGwZiMzNgl8juYygM6pbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=G6Kbo3zB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EcFS9y2/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="G6Kbo3zB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EcFS9y2/" Date: Thu, 27 Nov 2025 16:55:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764258931; 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: content-transfer-encoding:content-transfer-encoding; bh=y04LpGKghmf4xW2++iw/KoG9qle7C2LZQ8U9k1hQJw8=; b=G6Kbo3zBXS6B6bCI4YttG9XRuqzHRNuT52VI91+GjcaBQRLfYKaqzIHhTpGCdMAI2uCioS 7X7D5CLCKylcjhdNhHpz5t3XUoFq/9c1jJG55oWaAVxgkcvd4YQRUKi1PjjUwmZFFINFI1 IHzHXgBjTeBX6I8A6GcEa0/0Iso5/OYzk/IHVIRt8ZbojicNpY9A3fhQL3q8cVDJ8jtNNW t6S+scSL1Q2pkCaiepnf8bW3+cXAUs857J0p4z+YvVwdx7baJJg4HJZAMvy7AnJ1P9wFil AeVAVHhEDGiRfIB0SZfuG6YCIeTn/Fm/94mHgs1ZPnhEVZgzA5HRgRCcg0i2GQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764258931; 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: content-transfer-encoding:content-transfer-encoding; bh=y04LpGKghmf4xW2++iw/KoG9qle7C2LZQ8U9k1hQJw8=; b=EcFS9y2/qsiG/twYQDX0GiNGIZDFqiVj6zFN98jnhuEGvlE7k/bqnrsZKpFOhPm1ZQJsJY 8B7ixGMy17+cEFAw== From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Subject: [PATCH v3 REPOST] sched: Remove a preempt-disable section in rt_mutex_setprio() Message-ID: <20251127155529.t_sTatE4@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" rt_mutex_setprio() has only one caller: rt_mutex_adjust_prio(). It expects that task_struct::pi_lock and rt_mutex_base::wait_lock are held. Both locks are raw_spinlock_t and are acquired with disabled interrupts. Nevertheless rt_mutex_setprio() disables preemption while invoking __balance_callbacks() and raw_spin_rq_unlock(). Even if one of the balance callbacks unlocks the rq then it must not enable interrupts because rt_mutex_base::wait_lock is still locked. Therefore interrupts should remain disabled and disabling preemption is not needed. Commit 4c9a4bc89a9cc ("sched: Allow balance callbacks for check_class_chang= ed()") adds a preempt-disable section to rt_mutex_setprio() and __sched_setscheduler(). In __sched_setscheduler() the preemption is disabled before rq is unlocked and interrupts enabled but I don't see why it makes a difference in rt_mutex_setprio(). Remove the preempt_disable() section from rt_mutex_setprio(). Signed-off-by: Sebastian Andrzej Siewior --- v2=E2=80=A6v3: https://lore.kernel.org/all/20250610144700.uBK6RS95@linutron= ix.de/ - Add a comment why IRQs are still disabled. v1=E2=80=A6v2: https://lore.kernel.org/all/20250513142954.ZM5QSQNc@linutron= ix.de/ - Repost without RFC kernel/sched/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f754a60de8484..61c3297b43756 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7440,14 +7440,11 @@ void rt_mutex_setprio(struct task_struct *p, struct= task_struct *pi_task) =20 check_class_changed(rq, p, prev_class, oldprio); out_unlock: - /* Avoid rq from going away on us: */ - preempt_disable(); + /* Caller holds task_struct::pi_lock, IRQs are still disabled */ =20 rq_unpin_lock(rq, &rf); __balance_callbacks(rq); raw_spin_rq_unlock(rq); - - preempt_enable(); } #endif /* CONFIG_RT_MUTEXES */ =20 --=20 2.51.0