From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD5AF1E5B63 for ; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251685; cv=none; b=AC3QMvkADPI5Q9JjQmFFtwydV3y37wG0B+nTrQMcGjtauzk6RXGbeAp1UTnea4lQv1axjtl6kTz16NX0xTNfBVgNSlJmjQOHLGwn01WFOmyCt9hQvb9QR6KW1h1UJAepCJJXoLFnQQl1B963nr0zqEMjUvtUHUEswKCA1GH3eNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251685; c=relaxed/simple; bh=vY2v5I9kO5ehK/jc4YTT7DsX1ZGch709+915nX0G2s4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=SAQKenP0DZyVxjDoreeP++jgcN3gh16zWqSy7qwytul8GamDLgVJa8QoFzuhDgiicco5qded/9wVwnPP7Rpx68H8+zsOXiw87RXLqarv3Fa758xgOdfGMg2y7IzHYzOXlD9XRmClO44DavbxB9v5mRJut+WHf8IwxSoeUnHKRFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ey3RfBoM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ey3RfBoM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74600C4CEF0; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251685; bh=vY2v5I9kO5ehK/jc4YTT7DsX1ZGch709+915nX0G2s4=; h=Date:From:To:Cc:Subject:References:From; b=Ey3RfBoM06rSS+/fFro6uDf+g5ZTLhzEwsGWC8FvEY1SIJ40ut5GNMBddS0Gow8ru oA/iFbX3oQT0f99A/75Kb9cKF2lEjljAF96vQPyj4GHS65JhecHP+pNTyF5I2ygNSX E4vgvK+0XRTZXbzGouANvxVAfVPrBc3TwxaDJzQ4I+VleFFm9LJVjLOz0KMK2yhuAr JdCO+eM5tv64/ITOBQZBP9iY1f6v6vaqbPn9IHVt4LkrMwV6OQDXCVoZH87EJLQi1M c95M52ozc/kjkodpIw60itvppls6J8H1qX2tW/BQGhSGK54CaGrN+nymR5Ed8IpypP 6X0aV0iveVHZw== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkj-0000000DIFq-28hw; Tue, 30 Sep 2025 13:03:01 -0400 Message-ID: <20250930170301.362050230@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:36 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra , Namhyung Kim , Takaya Saeki , Tom Zanussi , Thomas Gleixner , Ian Rogers , Douglas Raillard , "Paul E. McKenney" Subject: [for-next][PATCH 01/11] tracing: Replace syscall RCU pointer assignment with READ/WRITE_ONCE() References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Steven Rostedt The syscall events are pseudo events that hook to the raw syscalls. The ftrace_syscall_enter/exit() callback is called by the raw_syscall enter/exit tracepoints respectively whenever any of the syscall events are enabled. The trace_array has an array of syscall "files" that correspond to the system calls based on their __NR_SYSCALL number. The array is read and if there's a pointer to a trace_event_file then it is considered enabled and if it is NULL that syscall event is considered disabled. Currently it uses an rcu_dereference_sched() to get this pointer and a rcu_assign_ptr() or RCU_INIT_POINTER() to write to it. This is unnecessary as the file pointer will not go away outside the synchronization of the tracepoint logic itself. And this code adds no extra RCU synchronization that uses this. Replace these functions with a simple READ_ONCE() and WRITE_ONCE() which is all they need. This will also allow this code to not depend on preemption being disabled as system call tracepoints are now allowed to fault. Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Peter Zijlstra Cc: Namhyung Kim Cc: Takaya Saeki Cc: Tom Zanussi Cc: Thomas Gleixner Cc: Ian Rogers Cc: Douglas Raillard Link: https://lore.kernel.org/20250923130713.594320290@kernel.org Reviewed-by: Paul E. McKenney Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace.h | 4 ++-- kernel/trace/trace_syscalls.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 5f4bed5842f9..85eabb454bee 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -380,8 +380,8 @@ struct trace_array { #ifdef CONFIG_FTRACE_SYSCALLS int sys_refcount_enter; int sys_refcount_exit; - struct trace_event_file __rcu *enter_syscall_files[NR_syscalls]; - struct trace_event_file __rcu *exit_syscall_files[NR_syscalls]; + struct trace_event_file *enter_syscall_files[NR_syscalls]; + struct trace_event_file *exit_syscall_files[NR_syscalls]; #endif int stop_count; int clock_id; diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 46aab0ab9350..3a0b65f89130 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -310,8 +310,7 @@ static void ftrace_syscall_enter(void *data, struct pt_= regs *regs, long id) if (syscall_nr < 0 || syscall_nr >=3D NR_syscalls) return; =20 - /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */ - trace_file =3D rcu_dereference_sched(tr->enter_syscall_files[syscall_nr]); + trace_file =3D READ_ONCE(tr->enter_syscall_files[syscall_nr]); if (!trace_file) return; =20 @@ -356,8 +355,7 @@ static void ftrace_syscall_exit(void *data, struct pt_r= egs *regs, long ret) if (syscall_nr < 0 || syscall_nr >=3D NR_syscalls) return; =20 - /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */ - trace_file =3D rcu_dereference_sched(tr->exit_syscall_files[syscall_nr]); + trace_file =3D READ_ONCE(tr->exit_syscall_files[syscall_nr]); if (!trace_file) return; =20 @@ -393,7 +391,7 @@ static int reg_event_syscall_enter(struct trace_event_f= ile *file, if (!tr->sys_refcount_enter) ret =3D register_trace_sys_enter(ftrace_syscall_enter, tr); if (!ret) { - rcu_assign_pointer(tr->enter_syscall_files[num], file); + WRITE_ONCE(tr->enter_syscall_files[num], file); tr->sys_refcount_enter++; } mutex_unlock(&syscall_trace_lock); @@ -411,7 +409,7 @@ static void unreg_event_syscall_enter(struct trace_even= t_file *file, return; mutex_lock(&syscall_trace_lock); tr->sys_refcount_enter--; - RCU_INIT_POINTER(tr->enter_syscall_files[num], NULL); + WRITE_ONCE(tr->enter_syscall_files[num], NULL); if (!tr->sys_refcount_enter) unregister_trace_sys_enter(ftrace_syscall_enter, tr); mutex_unlock(&syscall_trace_lock); @@ -431,7 +429,7 @@ static int reg_event_syscall_exit(struct trace_event_fi= le *file, if (!tr->sys_refcount_exit) ret =3D register_trace_sys_exit(ftrace_syscall_exit, tr); if (!ret) { - rcu_assign_pointer(tr->exit_syscall_files[num], file); + WRITE_ONCE(tr->exit_syscall_files[num], file); tr->sys_refcount_exit++; } mutex_unlock(&syscall_trace_lock); @@ -449,7 +447,7 @@ static void unreg_event_syscall_exit(struct trace_event= _file *file, return; mutex_lock(&syscall_trace_lock); tr->sys_refcount_exit--; - RCU_INIT_POINTER(tr->exit_syscall_files[num], NULL); + WRITE_ONCE(tr->exit_syscall_files[num], NULL); if (!tr->sys_refcount_exit) unregister_trace_sys_exit(ftrace_syscall_exit, tr); mutex_unlock(&syscall_trace_lock); --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F3A73309F17 for ; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=fzgzjDkCYhYPOdmHIsiT759JTS582UlmpFk7HAg5sUncQQ0U0Ki42U8ExOw/bLRSsUEntrqxY8cczM+sg/9JEtp3NDZ9AwrTnWcB7sSulQ4aCK1Yn2XO2bI8zuY+A5e45mc/Asg6B5IjAOhrFlMcyVWN9f5oVhQwNY9Yg4tUxVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=IUS9gn4p9iWzZ6Wm0O5tf4RWJiFVhFmnx6hA+d1hSN4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=J9hMzHV7eElhk/YOzN5e42N84IRenIEBm1n84gL9qeJ6hO5wKMFDfRuGXLDvACFQB7uNsmLQkI0eEizHml1exXoEvgvYu7Vyisk4YIp8Z8bqBK8KbLmTRSWSGzI0tD8PS3CnvwfzoD2PL2s6db96OKAxD1G9H3KAWnDAcNg1mHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PbUIlZrb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PbUIlZrb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABECCC116C6; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251685; bh=IUS9gn4p9iWzZ6Wm0O5tf4RWJiFVhFmnx6hA+d1hSN4=; h=Date:From:To:Cc:Subject:References:From; b=PbUIlZrbxUuphpUFOnWVkjuhVn9S9WtyvvyiDtWTyhl/niFjHvpdicT4wGdjgwJLW wSbgp8QrvkMxbTn6wHCDNoaeH5RxkZgRRc7MoTo+7VCthIhHYGO3cPf48Ehf0Uackl dgDF2dX6SAKEIjfYF1XrSJ3nq4gHHSoRstKXFatyrXrOQvc/clMF8cMisFgQn0teOZ GNH/ZcounFq6d/b6aKogvg23d2+SNnya6HXC2HOsvRjDlIt6geXr8OhGpvah2HIqGM 68Kf7lEDRQqemulEmtPl8K3T13i1SDH4fMr8LSF6bjf4CqyiFjBgnhd/v9QK14MAeX nW1XeXcNy4j2g== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkj-0000000DIGM-2qfq; Tue, 30 Sep 2025 13:03:01 -0400 Message-ID: <20250930170301.530992021@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:37 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra , Namhyung Kim , Takaya Saeki , Tom Zanussi , Thomas Gleixner , Ian Rogers , Douglas Raillard Subject: [for-next][PATCH 02/11] tracing: Have syscall trace events show "0x" for values greater than 10 References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Steven Rostedt Currently the syscall trace events show each value as hexadecimal, but without adding "0x" it can be confusing: sys_write(fd: 4, buf: 0x55c4a1fa9270, count: 44) Looks like the above write wrote 44 bytes, when in reality it wrote 68 bytes. Add a "0x" for all values greater or equal to 10 to remove the ambiguity. For values less than 10, leave off the "0x" as that just adds noise to the output. Also change the iterator to check if "i" is nonzero and print the ", " delimiter at the start, then adding the logic to the trace_seq_printf() at the end. Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Peter Zijlstra Cc: Namhyung Kim Cc: Takaya Saeki Cc: Tom Zanussi Cc: Thomas Gleixner Cc: Ian Rogers Cc: Douglas Raillard Link: https://lore.kernel.org/20250923130713.764558957@kernel.org Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_syscalls.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 3a0b65f89130..0f932b22f9ec 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -153,14 +153,20 @@ print_syscall_enter(struct trace_iterator *iter, int = flags, if (trace_seq_has_overflowed(s)) goto end; =20 + if (i) + trace_seq_puts(s, ", "); + /* parameter types */ if (tr && tr->trace_flags & TRACE_ITER_VERBOSE) trace_seq_printf(s, "%s ", entry->types[i]); =20 /* parameter values */ - trace_seq_printf(s, "%s: %lx%s", entry->args[i], - trace->args[i], - i =3D=3D entry->nb_args - 1 ? "" : ", "); + if (trace->args[i] < 10) + trace_seq_printf(s, "%s: %lu", entry->args[i], + trace->args[i]); + else + trace_seq_printf(s, "%s: 0x%lx", entry->args[i], + trace->args[i]); } =20 trace_seq_putc(s, ')'); --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F39F53093CA for ; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=mj454+OSPawQGF4H69MIeAoJC4j9pvzfdvVGKNiR/xQAFQLVZvDiNABOFiLCKVCaK+4aOMB4p+DuctB/U/FUz4FxQ1KQLUoYjcbbdzilOwK8ufo5Xi04j50QmrXTwRMIpN7OsoJYdy0LnJu9DP4BV+u0wCG/iBrh/9Vm+s766VU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=9Has2rbY4I/41mqljMsduhjgNFk0/JrXOnwh9b4Jzv4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=LglZiov/Aa+LxHuPJdQhyT5+qrYz9Jv8dMxknq1FVBd9BTNV2rc5YvVzFhmWwi4Awj6VWR/O6pH4O+c/gU/YtajZnvYun8rTsTLcF7WLzBEECm3NaSOOPQe/bI+TXrbnMG+PlCf9n6J4HArW+7XKweHx8e8Jjg3pquhLvv5CqkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XPJzoIxU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XPJzoIxU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B09F5C116D0; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251685; bh=9Has2rbY4I/41mqljMsduhjgNFk0/JrXOnwh9b4Jzv4=; h=Date:From:To:Cc:Subject:References:From; b=XPJzoIxUiBrGX6ypsRSOTtdkHEylNcoJbvJcPsgEdAeS1Yt50+ckEU53G7ukBZyrw JZGIB6WpmkvBx9eHzNqcDwiEAZZRwvc/2COH8hJOMTOpccZW9iNKZSkTBeEra1znpw HLHt91Rrn31MbjZd5vf5E27woaDsEt6aW0TD1Wj6v5FHqJJ3tgjJ7Lh/RquFHvgklk P41/oL6PpQz0GpbI7OQUVkIZsEWd9q6+vGG/L9ZC8UsbeAVNWxbwDXUHUB+3ntemmq c5eBmcf6AqU5FJdKq/K7vKZLYFyMlB8kEMVPeB7IYNkdbcJ0ufQK16zEHqYY2e3Rg4 TYzTrurDVpU9Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkj-0000000DIGq-3Yo1; Tue, 30 Sep 2025 13:03:01 -0400 Message-ID: <20250930170301.699930470@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:38 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Qianfeng Rong Subject: [for-next][PATCH 03/11] tracing: Use vmalloc_array() to improve code References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Qianfeng Rong Remove array_size() calls and replace vmalloc() with vmalloc_array() in tracing_map_sort_entries(). vmalloc_array() is optimized better, uses fewer instructions, and handles overflow more concisely[1]. [1]: https://lore.kernel.org/lkml/abc66ec5-85a4-47e1-9759-2f60ab111971@vivo= .com/ Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250817084725.59477-1-rongqianfeng@vivo.com Signed-off-by: Qianfeng Rong Signed-off-by: Steven Rostedt (Google) --- kernel/trace/tracing_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index 1921ade45be3..7f8da4dab69d 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c @@ -1076,7 +1076,7 @@ int tracing_map_sort_entries(struct tracing_map *map, struct tracing_map_sort_entry *sort_entry, **entries; int i, n_entries, ret; =20 - entries =3D vmalloc(array_size(sizeof(sort_entry), map->max_elts)); + entries =3D vmalloc_array(map->max_elts, sizeof(sort_entry)); if (!entries) return -ENOMEM; =20 --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4671F30AABF for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=a3ttz2RcRd1FruFqLHA+5C/EsVQKIVx92+mziwlYzsfXVbliUO6o2rg30/XENsi49ClviPDk/+5YzTELX1y8m3IjaNoBXW77IOViPOUmDQlxAY3dG6xc7MHYOgQfuXBhxtTG19ffKzjL62BKuwJq/VfinhKYEqCT4ti5Qlzwgr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=ewfavwPiUlXpVnI+x4ifVIAw/sPC3d8q8xGF3eGqVOw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=n5zj6U/QAWweWyfOBxyI8zX0DiBEQTgtzAmTfbbU+50pJFvfr/dOS4kcbcmXGSZnbH6tWFHkxtEiB2M1zRZQqVTmhNRWXmGK6aIEhX4ZhrBlRqWSlONH0rqJMCxISnxpGPhcjJunhYucCNmtpesjrIDq12K5akhqwsptrUvjLvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QOch6udt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QOch6udt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE1F9C16AAE; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251685; bh=ewfavwPiUlXpVnI+x4ifVIAw/sPC3d8q8xGF3eGqVOw=; h=Date:From:To:Cc:Subject:References:From; b=QOch6udtKicHTXecfI7Ho1xQ7KnygRBKSNhRJh3owV77Gv2AVpYmYKTfpDQn1Mlqt 0Szz4O8J2ZFMPZxwLvyS4QNTyCyixlnMrtKhaJ4lbYKQz52CRSNAh0LIQiuVAI4Fuv 9XVL/Gi/y8GwYDvSOf9y6UjGu2XRczJSzT0tet99PDBF/Cz5DtaExwqLnN1urVEYSp AjZuK/Ry9V8sXeaQRrFACYUNsrj+tZM9a6eIiisTwTW/QD9JOCORdhBnAL8YQoa5Ly UL7CvkQPzyhWaJH3y4DNbmJU7IAxtdJmcsazI3Yy6LdRjpMQB0kbQr7+i/5GOeb2f9 Qtu45WBUzEc5Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIHK-04YX; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170301.869001194@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:39 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Fushuai Wang Subject: [for-next][PATCH 04/11] tracing/osnoise: Use for_each_online_cpu() instead of for_each_cpu() References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Fushuai Wang Replace the opencoded for_each_cpu(cpu, cpu_online_mask) loop with the more readable and equivalent for_each_online_cpu(cpu) macro. Link: https://lore.kernel.org/20250811064158.2456-1-wangfushuai@baidu.com Signed-off-by: Fushuai Wang Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_osnoise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index fd259da0aa64..4cb464894faf 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -271,7 +271,7 @@ static inline void tlat_var_reset(void) * So far, all the values are initialized as 0, so * zeroing the structure is perfect. */ - for_each_cpu(cpu, cpu_online_mask) { + for_each_online_cpu(cpu) { tlat_var =3D per_cpu_ptr(&per_cpu_timerlat_var, cpu); if (tlat_var->kthread) hrtimer_cancel(&tlat_var->timer); @@ -295,7 +295,7 @@ static inline void osn_var_reset(void) * So far, all the values are initialized as 0, so * zeroing the structure is perfect. */ - for_each_cpu(cpu, cpu_online_mask) { + for_each_online_cpu(cpu) { osn_var =3D per_cpu_ptr(&per_cpu_osnoise_var, cpu); memset(osn_var, 0, sizeof(*osn_var)); } --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9368530AAC2 for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=Fu1R4jWjQzhAxIf9iB4IcSXYlVfFaoMu+5RbwPhOXGkb1/63iPoufKMfYCYxYKJYpnGOYwW9QigoAuskLkvI+Uae7eoQDNEjQUb6BI1twKKERpPb7N6rggDIj8gsZKpYWXIDfWVjeje4DX/QZJYOAmeYHq3C05MbjQuJl+M9RZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=yHsMTGqvohOFfGloUw1p3CtiQgsrh/OUcTuurZP/zf0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=b9+OwRVGWnpLqWVdD6w6Up+LJqoFhU/Orhmv/Qpz886AGzk0wKzoB+j9WhWRBCoAVGFXeIErUpChpd375+n6MfYn2JUsVHvNS70tLddoamj7IxC5g2DS8uE2DMhF8bV1iFmoOHM7orqGl1Vz378wFmQPOQSuabeeq9lc34Nt664= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CYttMf2f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CYttMf2f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FC6EC113D0; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=yHsMTGqvohOFfGloUw1p3CtiQgsrh/OUcTuurZP/zf0=; h=Date:From:To:Cc:Subject:References:From; b=CYttMf2fTXDaIU4UB4/TrCKYjnT1zDUvl7QeKBPLPocnar8blRJ2sFK7Ryaxy80x/ hgoN/UPuujXSts2Wtn/pg/imbhuN9kssEJnbdC66msRvhxhMXFWvBsBJ1iQxoyOnM1 d97jsF9tfylDXBc5Y2oCcIH+fCc/UFVUkD6T4bIZRNFih/KRep3UbmYRqWuBjZ+5k7 nfd8mmMx/1OJU0JbSpYHXMfBmyGWG3N7c9sy6ijz4NZUfJ/YkIWmtPa0zpbhu2M7Gk mNe159f1+eMSCMDjPkas7WiQBWMIo7m+VW480o0wYBps2N0ylAAS/Vcrc3GM0DYXvf eDs6Ps9y+mL/Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIHo-0mOL; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170302.037046621@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:40 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Elijah Wright Subject: [for-next][PATCH 05/11] tracing: Move buffer in trace_seq to end of struct References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Elijah Wright TRACE_SEQ_BUFFER_SIZE is dependent on the architecture for its size. on 64-= bit systems, it is 8148 bytes. forced 8-byte alignment in size_t and seq_buf me= ans that trace_seq is 8200 bytes on 64-bit systems. moving the buffer to the end of the struct fixes the issue. there shouldn't be any side effects, i.e. pointer arithmetic on trace_seq Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250821053917.23301-1-git@elijahs.space Signed-off-by: Elijah Wright Signed-off-by: Steven Rostedt (Google) --- include/linux/trace_seq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index a93ed5ac3226..557780fe1c77 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -21,10 +21,10 @@ (sizeof(struct seq_buf) + sizeof(size_t) + sizeof(int))) =20 struct trace_seq { - char buffer[TRACE_SEQ_BUFFER_SIZE]; struct seq_buf seq; size_t readpos; int full; + char buffer[TRACE_SEQ_BUFFER_SIZE]; }; =20 static inline void --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9EBBE30BF62 for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=Y6vFuv4rjUzZqKgT8sutCcqLxygFYYDjIsfR16JJYWawt8M3SJKeUZJQWvlnlTOLBjCKBDBrMLGgYflvskUptMfNxbB9/9KHACDLB6aDv88YZ9ucFgAPUlpCPgOe/goF6XzMESEiImE5BEpC6GPrHg3BpmmqQQ56EcozsduqQtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=HeSHLMhtFrWa6uet7G3GDqFuRbBCaqAnnR7g3BuXQrw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=p8QIrSDaaKtPKYq9KJmnptcoLRwkTai2/7jRHiq2G0MgBBLi7jTcyHNB3vK+9CzPGccw6tNeiMDegFZHdfrF9OmWFfTsjYB2GLmYhMYXrKnaiuAe5KVz9bpOcnYw61LsYu3bTECaRVArAp8aTCkiqQRQRO+BURqN6QEMMMQerJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YQyADnxj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YQyADnxj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49CD7C4CEF0; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=HeSHLMhtFrWa6uet7G3GDqFuRbBCaqAnnR7g3BuXQrw=; h=Date:From:To:Cc:Subject:References:From; b=YQyADnxj+o0mcPyYlC12dUrHXVsDeJ4LwDKGHGnAjHSrmmb4bFC8Rc5RyiWREZ8ox 61pZedp3pL1/nktgVAA1FGwgHLtUG422IuTkxlmrI2eKnJ7sttirQ08OrrPxH63L8K DWnB0GojUbli5Oj4wVaj9m093oa/KFi9YnnoOXwY0QCcrpC9ISuQ1omctXsIE9c/Vs 7agQJhybYN6xZbh670Oi//Va/LXH1GjSooyNOgZRmTXF4FyAELHhbi/nHVxFyEuw5b KbrZ/Xtcz4wSe/qwFWdChC30XCbS918GX/nTxfsXF9MqygSucQj/Ii75DxB/UnjosR qqYvhCmduJyrg== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIII-1U8z; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170302.206716475@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:41 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Liao Yuanhong Subject: [for-next][PATCH 06/11] tracing: Remove redundant 0 value initialization References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Liao Yuanhong The saved_cmdlines_buffer struct is already zeroed by memset(). It's redundant to initialize s->cmdline_idx to 0. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250825123200.306272-1-liaoyuanhong@vivo.com Signed-off-by: Liao Yuanhong Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_sched_switch.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_s= witch.c index cb49f7279dc8..518dfc74347a 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c @@ -224,7 +224,6 @@ static struct saved_cmdlines_buffer *allocate_cmdlines_= buffer(unsigned int val) /* Place map_cmdline_to_pid array right after saved_cmdlines */ s->map_cmdline_to_pid =3D (unsigned *)&s->saved_cmdlines[val * TASK_COMM_= LEN]; =20 - s->cmdline_idx =3D 0; memset(&s->map_pid_to_cmdline, NO_CMDLINE_MAP, sizeof(s->map_pid_to_cmdline)); memset(s->map_cmdline_to_pid, NO_CMDLINE_MAP, --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BF29930C0E3 for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=rJUW3+ZY70cr1VqqMMudlNtEpO0IgYhd5mBwBiC4w3GPufFJc/JSXzXzau58r1sOIUJob0r9Forbs9Sa7WXQTQTS/An8wJTCZitlbaNDEcBIaAriCfT5gkc1xbZrWSqrGS2/p5FzeRdxDdN+kTJvk6qImaKrIl2KvcN8Gq1n6cU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=GpMP430l+55Sh3Q11LF7iWsYWpULIusNiLoUA5Q0ahY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=p0EJCilnv4Qr1kNdCDbp+ZLldmNovHXR+nFFkZ7zJHhH2IH/OY/nBOekNuo0V0Dxk3LcxrA/G9H7XI0cbCrsdAKp3I63wtgyXL5ljQ1pv2aei59No+VAQzgZJPy4gANzAQ8jCQlqgc5m0f3lrTHUJ7f1/ZkWpVqnSPJ3WjOOyx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h8GN/QFu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h8GN/QFu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 673EDC16AAE; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=GpMP430l+55Sh3Q11LF7iWsYWpULIusNiLoUA5Q0ahY=; h=Date:From:To:Cc:Subject:References:From; b=h8GN/QFuJ/EGNf6EA8HwjLxKrHWFbRBmmAbxDYjJyk6QR4KSc7qxO/EJs3JYwaqlt IjO/fF7TZC9LUgepAdSq4fT5ScvvQSpJxE0ccrYjTZsyw7tz8brUUUNDyrSZxODQnd CxpgPkllT2EIkSwcHeVEZCyh3RnHBAs4WnVGTKS/bSGtIARGR1zLVrpoFqGMAVhr1E n0qwH1gH9tnpA3dh+JIMO6mfHhzXt13sbLWLK/TaB4yZHYRi6Oe6K6IC2LmejKIUHX 2qd2pTQzFWNyH3cJKjXJy+bt1rh1TwCYnCD6AOfq92Ru7r60pUnNcZLpJHrTeRyvSw flb86TQdA0W5Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIIm-2Bgn; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170302.375260552@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:42 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Michal Hocko , Tejun Heo , Marco Crivellari Subject: [for-next][PATCH 07/11] tracing: replace use of system_wq with system_percpu_wq References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Marco Crivellari Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. system_wq is a per-CPU worqueue, yet nothing in its name tells about that CPU affinity constraint, which is very often not required by users. Make it clear by adding a system_percpu_wq. queue_work() / queue_delayed_work() mod_delayed_work() will now use the new per-cpu wq: whether the user still stick on the old name a warn will be printed along a wq redirect to the new one. This patch add the new system_percpu_wq except for mm, fs and net subsystem, whom are handled in separated patches. The old wq will be kept for a few release cylces. Cc: Lai Jiangshan Cc: Frederic Weisbecker Cc: Sebastian Andrzej Siewior Cc: Michal Hocko Cc: Masami Hiramatsu Link: https://lore.kernel.org/20250905091040.109772-2-marco.crivellari@suse= .com Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_u= ser.c index af42aaa3d172..3169182229ad 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -835,7 +835,7 @@ void user_event_mm_remove(struct task_struct *t) * so we use a work queue after call_rcu() to run within. */ INIT_RCU_WORK(&mm->put_rwork, delayed_user_event_mm_put); - queue_rcu_work(system_wq, &mm->put_rwork); + queue_rcu_work(system_percpu_wq, &mm->put_rwork); } =20 void user_event_mm_dup(struct task_struct *t, struct user_event_mm *old_mm) --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF99730C0E8 for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=oZmHhHHp6F2dicCdBMiuMc939oOipJZbjgUqjrbFIekbDosqWirUrVjbTYXcMApwofq3qWm8vG1J279eaSJJxZPOFq0L1jttvfLDY5TUjftevcoZPgj+Uh/x23h+impIlxrnlDnHRDEGfHMx1V1q8DOmt92FibItgLKzrM6KBxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=qUk+6vmoI9FoeERrBRl7q29liPWfCY0ID1ORFfm7iCk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=r0s6R57P4rNtjEFiC5G77R95UKUm1ZtuwB9DGdRiYPvlPpknT8+aHLtHEl0x5K9sjIhj7xK7LQ3nj//MEpf5eh0D0yQPy5zQpkX3YLktsivc6U/Qq6pLCYdZ5t7ZrclnDkwYBmtTtPtI4K2gs47qn0LUR3fx2zMytbOXNlcjqIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nU7VlhxJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nU7VlhxJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A988C116D0; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=qUk+6vmoI9FoeERrBRl7q29liPWfCY0ID1ORFfm7iCk=; h=Date:From:To:Cc:Subject:References:From; b=nU7VlhxJWv07BBpiR6RwkU+ZYAnqCTkf6odlDPWONV5N7r9f27F1+e01Z7+4ZGWrR SRX36o5fDXO1Ad7z9GFXLtncfs9qb9JBVzx0H4n2RtSKGCdDpuwAf2DXXT4wd6HL8a xYm3aveTZRFqf5Bqc44Vkb1XbLz3DtpPsv8kO5u0+aUHN4bojGZvQsNRFX79Bc4CyF MsYZ46uI1MuI34KRSQbsVOe2ozd0JW26V8qZ9SHLBxm2JkaMObvgKxXFmjQ1MDhf8i WC4yMPs5iw7MXJSrztUc9omT0hgvnUCpR/wxFgv6OlgUVw2oM1j+yD9TP1Sg3Ne9he 7gzIKgT4nzf2g== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIJI-2ssl; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170302.542931839@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:43 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Thorsten Blum Subject: [for-next][PATCH 08/11] tracing/osnoise: Replace kmalloc() + copy_from_user() with memdup_user() References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Thorsten Blum Replace kmalloc() followed by copy_from_user() with memdup_user() to improve and simplify osnoise_cpus_write(). No functional changes intended. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250905192116.554018-2-thorsten.blum@linux.d= ev Signed-off-by: Thorsten Blum Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_osnoise.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index 4cb464894faf..f8aa9556c695 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -2322,12 +2322,9 @@ osnoise_cpus_write(struct file *filp, const char __u= ser *ubuf, size_t count, int running, err; char *buf __free(kfree) =3D NULL; =20 - buf =3D kmalloc(count, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, ubuf, count)) - return -EFAULT; + buf =3D memdup_user(ubuf, count); + if (IS_ERR(buf)) + return PTR_ERR(buf); =20 if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL)) return -ENOMEM; --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D106B30C0E9 for ; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=XnklRz3ZuakgOzXOkGQcyU+QruEobyL7tv9M6zunyCgF4FLQ0HidcIBhp+qIZUjMz9YkFia+vTj7thuW3VKayJfnI/pu7m/xd0X4x0oZ4TjKsbeE7eMIrR4AJ/Zrw43c29nTkKmm6gE5CguWemRY2EbFjlElsrUVnz+nxf4bkdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=IN3hHRIELFdM8Dk+oCOkHs+mCOpaPtH6nsw/3sTxNZU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=kxg5CGmN5WWjAGedlaatJgWplMeA5VLAHTuSHG7wQdEqBuVJJvdp5TXDRJznGq6RVsRnYHcDE26sTd3EGmQrNhUquRiuMEzIQ2gj9djll6CAEBuvdEDyTGvXHtTDcLTEnjyTU6uNWktcwiGO4epZNGi3fT4ljfX4IxQnp2/+PN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dprBt8vE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dprBt8vE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2B70C4AF0C; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=IN3hHRIELFdM8Dk+oCOkHs+mCOpaPtH6nsw/3sTxNZU=; h=Date:From:To:Cc:Subject:References:From; b=dprBt8vEGrwrsl8vdOX/WPli9GGMnO2Vsb/Kkx0rhIX4ZdEBcPgGMkhhWuiCzmpfj VhE0a3NforV1hYtRHC32TRX3gPiklv2kOca66RtX30TVFfOWBpNOYdSzLcswqXgDJF 4dTqEeSJdvhQKgtcuGCyBC2tZ7q3ox41UM70aFlcXqw35PPtTTGb6rfa9Kx8/EnlKI yEkyoHfdix3qICkVXc/pAzQI1eplAkxAVVYtsbt3V4saPe90zqIigYvcody3Eq1Ag7 djzsDltWCCUCnsUfreIRzcbJ3AJF/WEUGpmdcwNpTNOLZ98beX/ioiZfYNF6pMic7J dagBZTMyT8Tig== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkk-0000000DIJo-3bSd; Tue, 30 Sep 2025 13:03:02 -0400 Message-ID: <20250930170302.709162951@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:44 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vladimir Riabchun Subject: [for-next][PATCH 09/11] ftrace: Fix softlockup in ftrace_module_enable References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Vladimir Riabchun A soft lockup was observed when loading amdgpu module. If a module has a lot of tracable functions, multiple calls to kallsyms_lookup can spend too much time in RCU critical section and with disabled preemption, causing kernel panic. This is the same issue that was fixed in commit d0b24b4e91fc ("ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels") and commit 42ea22e754ba ("ftrace: Add cond_resched() to ftrace_graph_set_hash()"). Fix it the same way by adding cond_resched() in ftrace_module_enable. Link: https://lore.kernel.org/aMQD9_lxYmphT-up@vova-pc Signed-off-by: Vladimir Riabchun Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ftrace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index a69067367c29..42bd2ba68a82 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7535,6 +7535,8 @@ void ftrace_module_enable(struct module *mod) if (!within_module(rec->ip, mod)) break; =20 + cond_resched(); + /* Weak functions should still be ignored */ if (!test_for_valid_rec(rec)) { /* Clear all other flags. Should not be enabled anyway */ --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4F74830C117 for ; Tue, 30 Sep 2025 17:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251687; cv=none; b=ehKxJjntxQjCo75Egao+xMcPkrv0rFUtNYpaEZyyDA6lXpfhNSwB+pTEAPbOmvhl8oOvuL05P77IYNWum8aUR92ibtSLptTdMsPYnlB6rvYogsovFWG1uwtFowOQDXmd4Oc6ibpanamNjsIAVXmfUVNYksg1bIl17uZQSIU2LdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251687; c=relaxed/simple; bh=fEgqTioolEbToOXjQJrRCpCLI4LQWJGUzbSrefxtzSA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=fdMkD2HM86AZIVe5I8G3S1uQaMVoxwJ1+NNNi+d8zYS/8WUHMg+NrEUY1NLIt89O41bZFNT08EiAtRIm6s3qxm9qVIFQ9ey+AB0ZxdCV5Cf9gulirx/5Qfe1WMPoBBwd1wRE0ATumL5bV8DZNKuVoIrsMEpEQMinU1iGtY/A6YI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PQPadHFh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PQPadHFh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0BADC116C6; Tue, 30 Sep 2025 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251686; bh=fEgqTioolEbToOXjQJrRCpCLI4LQWJGUzbSrefxtzSA=; h=Date:From:To:Cc:Subject:References:From; b=PQPadHFhMBXFKAf87cL/RsSQQ8IQ34NsH/LadOLHClSbsQef49+iuoKhw0S6Sv9R3 GZaNOmdKvjPgcedNcavW7Rnj7NLBydwkIaQS7axi+JjzlZBQWxlqsAHLHOA+gNht4O FU6vv1bjhZ0/3RkyVdY9r7xkyfMJEaaseUFJX1UcAI0gFg0xuPGGKEy5i2JVP8pz6d iQKQutVzfli2jCcjaOHA+evJzI8iPPSO7Y5KvQNweiQLzHG61iS98cytix73mykzIa SVOPg62LOvYTEZjJUqkydjica9BZN0f+/HfXMYfSfw3d/oIUNr/cGOSEEGIVeOsS9V bE4+V470gcOjg== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkl-0000000DIKJ-07Jd; Tue, 30 Sep 2025 13:03:03 -0400 Message-ID: <20250930170302.878862549@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:45 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , =?UTF-8?q?Michal=20Koutn=C3=BD?= Subject: [for-next][PATCH 10/11] tracing: Ensure optimized hashing works References: <20250930170135.285740909@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Michal=3D20Koutn=3DC3=3DBD?=3D If ever PID_MAX_DEFAULT changes, it must be compatible with tracing hashmaps assumptions. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250924113810.2433478-1-mkoutny@suse.com Link: https://lore.kernel.org/r/20240409110126.651e94cb@gandalf.local.home/ Signed-off-by: Michal Koutn=C3=BD Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_sched_switch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_s= witch.c index 518dfc74347a..c46d584ded3b 100644 --- a/kernel/trace/trace_sched_switch.c +++ b/kernel/trace/trace_sched_switch.c @@ -247,6 +247,8 @@ int trace_save_cmdline(struct task_struct *tsk) if (!tsk->pid) return 1; =20 + BUILD_BUG_ON(!is_power_of_2(PID_MAX_DEFAULT)); + tpid =3D tsk->pid & (PID_MAX_DEFAULT - 1); =20 /* --=20 2.50.1 From nobody Wed Oct 1 21:27:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7D19C30C605 for ; Tue, 30 Sep 2025 17:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251687; cv=none; b=E6oCD9EvVQC4x3xmsqdKruL2Muyz5mglvLg2UDaRHJ1Z2qexX1ehngOxR8Pp4ucv0/aK65BrM3e7bMo1d1yQCh0TD3wgwN/eGfADjsmzApk4HDw/Z6XmMlVbnTKo4CwISGtFlmHImwjt4zCSwTE8qDG9GjQmxA5CNmmfN9f4uh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251687; c=relaxed/simple; bh=4WO7FoqGFohz7g21DYiHjK+J4HuZtWXe3wwp/JlD4sA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=S20ev5Gzh/6PAzONfgG3Ka72Ns/VAlWI2J/qX4yDffxZ9Lz0XclNLAPQpYufTev85cmMLwAiNumkdDczi5YXxqFx2fo3rwKrMSZa9qGSBd/4b1rOJz8dFtpEmG/0NV3JWchDp44QNOophl/xPsSuky1VxH9DJU9XGBfw8AoU0fY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VJxa7Xig; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VJxa7Xig" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20AF2C113D0; Tue, 30 Sep 2025 17:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251687; bh=4WO7FoqGFohz7g21DYiHjK+J4HuZtWXe3wwp/JlD4sA=; h=Date:From:To:Cc:Subject:References:From; b=VJxa7XigX5CtShF+YJgYosNo6mbXSN3DO+rHrcTrukJnVLsS3Boll/dO8WEoL1Fcg iCu1GU0qiG1i6Q4/2CiVYeGT7jJ5dbl37maUpRkH5WoN+rZdFMAWLBOj+A3XImdGzF W2Z9zghxaBGQXLZD1pQL10VFvmcf2ByyooQuqL1G9kfV+h+/dj6oU9M3HdnOahK6dF MQxEf1QsIQEwxI9J1bbLSTJNgtLN8m3NTZ2wBvjDZ5IBrxBQfAE1IHB/LM5Cj0AkHv 0UcRXoFxp/WTV0dZ0eDB8cBkr0DnrBuGfbMgHY5Dd8jF8MxnEDjz0z3j1ZHiFXTaoy vJQBJMAcRsxfg== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkl-0000000DIKo-0pUc; Tue, 30 Sep 2025 13:03:03 -0400 Message-ID: <20250930170303.049610095@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:46 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Sasha Levin Subject: [for-next][PATCH 11/11] tracing: Fix lock imbalance in s_start() memory allocation failure path References: <20250930170135.285740909@kernel.org> 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 Content-Type: text/plain; charset="utf-8" From: Sasha Levin When s_start() fails to allocate memory for set_event_iter, it returns NULL before acquiring event_mutex. However, the corresponding s_stop() function always tries to unlock the mutex, causing a lock imbalance warning: WARNING: bad unlock balance detected! 6.17.0-rc7-00175-g2b2e0c04f78c #7 Not tainted ------------------------------------- syz.0.85611/376514 is trying to release lock (event_mutex) at: [] traverse.part.0.constprop.0+0x2c4/0x650 fs/seq_file.= c:131 but there are no more locks to release! The issue was introduced by commit b355247df104 ("tracing: Cache ':mod:' events for modules not loaded yet") which added the kzalloc() allocation be= fore the mutex lock, creating a path where s_start() could return without locking the mutex while s_stop() would still try to unlock it. Fix this by unconditionally acquiring the mutex immediately after allocatio= n, regardless of whether the allocation succeeded. Link: https://lore.kernel.org/20250929113238.3722055-1-sashal@kernel.org Fixes: b355247df104 ("tracing: Cache ":mod:" events for modules not loaded = yet") Signed-off-by: Sasha Levin Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 9f3e9537417d..e00da4182deb 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1629,11 +1629,10 @@ static void *s_start(struct seq_file *m, loff_t *po= s) loff_t l; =20 iter =3D kzalloc(sizeof(*iter), GFP_KERNEL); + mutex_lock(&event_mutex); if (!iter) return NULL; =20 - mutex_lock(&event_mutex); - iter->type =3D SET_EVENT_FILE; iter->file =3D list_entry(&tr->events, struct trace_event_file, list); =20 --=20 2.50.1