From nobody Thu Apr 2 15:36:27 2026 Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) (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 B89D029ACDB for ; Fri, 27 Mar 2026 19:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774639258; cv=none; b=LBlOHLfP0lYXECUj+Mz9HRALSNMlAUuRDcnXVx2b3QrGcCGz/IFSZlkhEhauschy5sBVU0TI3hUDFU/ew+LZg/XMkoSv874tI7MZidL6SbllB3p0KaSef49pNk1rCKgC/H4oFnO3CND+6O234d7nqU9YJLDyuQ5M87z9uPoJLaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774639258; c=relaxed/simple; bh=DGz7/kPl0CAS8K8lqSEJhDMY2y1eVyEH80+1PJjIbkA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=RqbcwxVNu5Aef/82lKx+93Rzr2yA5+XpY8CvilDqYEY9fAm6TSBEhaxTDnkhHPFQe0bE8IKZpX1r0/ejnhXUSjkWoVU2J9vvbUStJVMyDI+qpccehMivEQurMaS0uD12vlZ2WfgA3fYGQKe78SOsr/QXPG/RUbcSQPI8tXsTC6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DCA621608B3; Fri, 27 Mar 2026 19:20:49 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf09.hostedemail.com (Postfix) with ESMTPA id 6023A20034; Fri, 27 Mar 2026 19:20:48 +0000 (UTC) Date: Fri, 27 Mar 2026 15:21:37 -0400 From: Steven Rostedt To: LKML Cc: Masami Hiramatsu , Mathieu Desnoyers , Luo Haiyang Subject: [for-linus][PATCH] tracing: Fix potential deadlock in cpu hotplug with osnoise Message-ID: <20260327152137.2ecc5960@gandalf.local.home> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 6023A20034 X-Rspamd-Server: rspamout06 X-Stat-Signature: 4uc5n18iw55z1pcgadbfn5h4sn737mec X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX18PMq+BNk3T8Su/ReoBmRCANbMqVlJ20Ss= X-HE-Tag: 1774639248-91662 X-HE-Meta: U2FsdGVkX19bjk9OEVNM8pJziIGGYMCp4XglKnznSju07fDg5bClcBrCF+8bSCSLk9G+tD1zYRnj2iPDZaJELE5ENN0E1oALgv3NEciwwTzilYOs6HZV2+HT1MOWiDmr5c92Bcnlh/BnAoHk/Og8XpUhhD5CNoRSuYqBpMO7V76YbkRST//qzrEyUiIGXYHMZUyMjrrPZFQESnq3qUnbOmZywwRvU1jizUj6dWHYM6ZnzYQt5LllUQXLy7+PxXVse9lkvfgKVXQY9oxYRuWwhi4aQzFI1orhjW2bLv0GGMPzAg9SzoEvlXxsA2dIJGBIM5ywXxMzVQ3P4Xhw9jzzWdCsk5RsoCSh6xktx6vcVuoudiSnmR6vTnRONzn/SV2WN0HhUBDH72UC1UfxcQz1isCoGEmSjWeRf06C05VRAhFoSDZhrsZiS/PFNHGyWLmd3luW9Pmt91ADoRTr6aAS4zv2s5t6EURcF7GyOigjOFIjcKsKQkjZ9Wz5GrI4fwqvpcdf4C3YGNvJjD+IiF1SeP8z7VmtDyG6G0YeHiGrYVcgoOV50fTTVqlZMAIk0rAYJaqPDcI9ORC/rRvD54Kb928UjfzRNc8be9XRCMhfc+tdA/Y/n0I/poVm/fGiFPz7ad6tjcwGLG8nDNAO/Usffg== Content-Type: text/plain; charset="utf-8" tracing fixes for 7.0: - Fix potential deadlock in osnoise and hotplug The interface_lock can be called by a osnoise thread and the CPU shutdown logic of osnoise can wait for this thread to finish. But cpus_read_lock() can also be taken while holding the interface_lock. This produces a circular lock dependency and can cause a deadlock. Swap the ordering of cpus_read_lock() and the interface_lock to have interface_lock taken within the cpus_read_lock() context to prevent this circular dependency. git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace/fixes Head SHA1: 1f9885732248d22f788e4992c739a98c88ab8a55 Luo Haiyang (1): tracing: Fix potential deadlock in cpu hotplug with osnoise ---- kernel/trace/trace_osnoise.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --------------------------- commit 1f9885732248d22f788e4992c739a98c88ab8a55 Author: Luo Haiyang Date: Thu Mar 26 14:19:53 2026 +0800 tracing: Fix potential deadlock in cpu hotplug with osnoise =20 The following sequence may leads deadlock in cpu hotplug: =20 task1 task2 task3 ----- ----- ----- =20 mutex_lock(&interface_lock) =20 [CPU GOING OFFLINE] =20 cpus_write_lock(); osnoise_cpu_die(); kthread_stop(task3); wait_for_completion(); =20 osnoise_sleep(); mutex_lock(&interface_lock); =20 cpus_read_lock(); =20 [DEAD LOCK] =20 Fix by swap the order of cpus_read_lock() and mutex_lock(&interface_loc= k). =20 Cc: stable@vger.kernel.org Cc: Cc: Cc: Cc: Fixes: bce29ac9ce0bb ("trace: Add osnoise tracer") Link: https://patch.msgid.link/20260326141953414bVSj33dAYktqp9Oiyizq8@z= te.com.cn Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Luo Haiyang Signed-off-by: Steven Rostedt (Google) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index dee610e465b9..be6cf0bb3c03 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -2073,8 +2073,8 @@ static void osnoise_hotplug_workfn(struct work_struct= *dummy) if (!osnoise_has_registered_instances()) return; =20 - guard(mutex)(&interface_lock); guard(cpus_read_lock)(); + guard(mutex)(&interface_lock); =20 if (!cpu_online(cpu)) return; @@ -2237,11 +2237,11 @@ static ssize_t osnoise_options_write(struct file *f= ilp, const char __user *ubuf, if (running) stop_per_cpu_kthreads(); =20 - mutex_lock(&interface_lock); /* * avoid CPU hotplug operations that might read options. */ cpus_read_lock(); + mutex_lock(&interface_lock); =20 retval =3D cnt; =20 @@ -2257,8 +2257,8 @@ static ssize_t osnoise_options_write(struct file *fil= p, const char __user *ubuf, clear_bit(option, &osnoise_options); } =20 - cpus_read_unlock(); mutex_unlock(&interface_lock); + cpus_read_unlock(); =20 if (running) start_per_cpu_kthreads(); @@ -2345,16 +2345,16 @@ osnoise_cpus_write(struct file *filp, const char __= user *ubuf, size_t count, if (running) stop_per_cpu_kthreads(); =20 - mutex_lock(&interface_lock); /* * osnoise_cpumask is read by CPU hotplug operations. */ cpus_read_lock(); + mutex_lock(&interface_lock); =20 cpumask_copy(&osnoise_cpumask, osnoise_cpumask_new); =20 - cpus_read_unlock(); mutex_unlock(&interface_lock); + cpus_read_unlock(); =20 if (running) start_per_cpu_kthreads();