From nobody Thu Apr 2 14:20:18 2026 Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) (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 C281A31715C for ; Sat, 28 Mar 2026 15:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774712580; cv=none; b=QIRqGoMSt3E4v1riV7fAd+UQIQRiIHDt03GdOlX6HY7bu4TD/WdFS9UCPmGpScBTHOmdAcNGLEZ470nianliy8XzfG3CQx1QEeJSlCdqJnhvB7r4W+rMKZ14vGP2pPtMFYL8+u+qztMu8BPRmro3zYZxkHJaOkC4T+YjIaXKga8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774712580; c=relaxed/simple; bh=6lR56344bAtpqSMWV2LByFKtiUzo8o+KS1ehubg7zR4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=jMFggAFu7GfWLVsePWJBSIx7H2zUydJWl4BbzfpPvgs4L54kKxjobWnZEedXMEyDnex8gDWleJpx1kttwt37H7HV+rcR8wbGXk8cZ0wYXb+4OEDSk8dXYXObfHijSa2623OLvXJq8yR3KwdDIGq82+XgZr6SdS+uE0znpWJXgxA= 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.17 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 omf08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8301F1402EF; Sat, 28 Mar 2026 15:42:51 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf08.hostedemail.com (Postfix) with ESMTPA id C518320027; Sat, 28 Mar 2026 15:42:49 +0000 (UTC) Date: Sat, 28 Mar 2026 11:42:48 -0400 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers , Luo Haiyang , Wesley Atwell Subject: [GIT PULL] tracing: Fixes for v7.0 Message-ID: <20260328114248.7ae69675@robin> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-redhat-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-Stat-Signature: oe8taj6bsco9y794a9uiqn6uo3yq711f X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: C518320027 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/X5U/nhkREctKKUUy5AMqqhvldRUaUYGw= X-HE-Tag: 1774712569-297044 X-HE-Meta: U2FsdGVkX193xij/v9kx/uPR6sy2rBHNXTEUJPcDKla3olXwtaxqLTkMDnoxLS5gWDujNxjnY7iWblu3Zlba/mYMMj7cVa66oyFAmoI+sg6cDnRVqQFEoF4myIuqvMpzr3yDZzFjjEdSNFfp465RGRWGGujOCGMEFcCkVixDWjdz8s/mYv5bL9CniMytG1SbdHiHaOrWAaJFSdJtv8RkmPrR/gx9EtboKgjbObjKwapn3TH8QZNkqVac7ps8+oATW4m+VnvMN3iHbAGiN5DssGb5eExiRtjk24p/wi8FTBnOnlniLnzDjMudiPmJUthz0jQYAnMsZkNh3PMETYPmuAFFK1c7tNa8 Content-Type: text/plain; charset="utf-8" Linus, tracing fixes for v7.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. - Fix freeing of event triggers in early boot up If the same trigger is added on the kernel command line, the second one will fail to be applied and the trigger created will be freed. This calls into the deferred logic and creates a kernel thread to do the freeing. But the command line logic is called before kernel threads can be created and this leads to a NULL pointer dereference. Delay freeing event triggers until late init. Please pull the latest trace-v7.0-rc5 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-v7.0-rc5 Tag SHA1: dea0bd91348127ba82dd9d0fc94882b748b59ee8 Head SHA1: 250ab25391edeeab8462b68be42e4904506c409c Luo Haiyang (1): tracing: Fix potential deadlock in cpu hotplug with osnoise Wesley Atwell (1): tracing: Drain deferred trigger frees if kthread creation fails ---- kernel/trace/trace_events_trigger.c | 79 +++++++++++++++++++++++++++++++--= ---- kernel/trace/trace_osnoise.c | 10 ++--- 2 files changed, 71 insertions(+), 18 deletions(-) --------------------------- diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_event= s_trigger.c index d5230b759a2d..655db2e82513 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -22,6 +22,39 @@ static struct task_struct *trigger_kthread; static struct llist_head trigger_data_free_list; static DEFINE_MUTEX(trigger_data_kthread_mutex); =20 +static int trigger_kthread_fn(void *ignore); + +static void trigger_create_kthread_locked(void) +{ + lockdep_assert_held(&trigger_data_kthread_mutex); + + if (!trigger_kthread) { + struct task_struct *kthread; + + kthread =3D kthread_create(trigger_kthread_fn, NULL, + "trigger_data_free"); + if (!IS_ERR(kthread)) + WRITE_ONCE(trigger_kthread, kthread); + } +} + +static void trigger_data_free_queued_locked(void) +{ + struct event_trigger_data *data, *tmp; + struct llist_node *llnodes; + + lockdep_assert_held(&trigger_data_kthread_mutex); + + llnodes =3D llist_del_all(&trigger_data_free_list); + if (!llnodes) + return; + + tracepoint_synchronize_unregister(); + + llist_for_each_entry_safe(data, tmp, llnodes, llist) + kfree(data); +} + /* Bulk garbage collection of event_trigger_data elements */ static int trigger_kthread_fn(void *ignore) { @@ -56,30 +89,50 @@ void trigger_data_free(struct event_trigger_data *data) if (data->cmd_ops->set_filter) data->cmd_ops->set_filter(NULL, data, NULL); =20 + /* + * Boot-time trigger registration can fail before kthread creation + * works. Keep the deferred-free semantics during boot and let late + * init start the kthread to drain the list. + */ + if (system_state =3D=3D SYSTEM_BOOTING && !trigger_kthread) { + llist_add(&data->llist, &trigger_data_free_list); + return; + } + if (unlikely(!trigger_kthread)) { guard(mutex)(&trigger_data_kthread_mutex); + + trigger_create_kthread_locked(); /* Check again after taking mutex */ if (!trigger_kthread) { - struct task_struct *kthread; - - kthread =3D kthread_create(trigger_kthread_fn, NULL, - "trigger_data_free"); - if (!IS_ERR(kthread)) - WRITE_ONCE(trigger_kthread, kthread); + llist_add(&data->llist, &trigger_data_free_list); + /* Drain the queued frees synchronously if creation failed. */ + trigger_data_free_queued_locked(); + return; } } =20 - if (!trigger_kthread) { - /* Do it the slow way */ - tracepoint_synchronize_unregister(); - kfree(data); - return; - } - llist_add(&data->llist, &trigger_data_free_list); wake_up_process(trigger_kthread); } =20 +static int __init trigger_data_free_init(void) +{ + guard(mutex)(&trigger_data_kthread_mutex); + + if (llist_empty(&trigger_data_free_list)) + return 0; + + trigger_create_kthread_locked(); + if (trigger_kthread) + wake_up_process(trigger_kthread); + else + trigger_data_free_queued_locked(); + + return 0; +} +late_initcall(trigger_data_free_init); + static inline void data_ops_trigger(struct event_trigger_data *data, struct trace_buffer *buffer, void *rec, struct ring_buffer_event *event) 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();