Linux Trace Kernel
 help / color / mirror / Atom feed
* Re: [PATCH v3 1/5] mm: introduce zone lock wrappers
From: SeongJae Park @ 2026-02-27  1:01 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: SeongJae Park, Dmitry Ilvokhin, Andrew Morton, David Hildenbrand,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Axel Rasmussen, Yuanchu Xie,
	Wei Xu, Masami Hiramatsu, Mathieu Desnoyers, Brendan Jackman,
	Johannes Weiner, Zi Yan, Oscar Salvador, Qi Zheng, Shakeel Butt,
	linux-kernel, linux-mm, linux-trace-kernel, linux-cxl,
	kernel-team, Benjamin Cheatham
In-Reply-To: <20260226195355.611ec7f3@gandalf.local.home>

On Thu, 26 Feb 2026 19:53:55 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 26 Feb 2026 16:38:55 -0800
> SeongJae Park <sj@kernel.org> wrote:
> 
> > checkpatch.pl complains as below.  Should be ok to ignore, but, may better to
> > kindly make it silence?
> > 
> >     WARNING: Single statement macros should not use a do {} while (0) loop
> 
> Hmm, why is this an issue?
> 
> >     #116: FILE: include/linux/zone_lock.h:13:
> >     +#define zone_lock_irqsave(zone, flags)                         \
> >     +do {                                                           \
> >     +       spin_lock_irqsave(&(zone)->lock, flags);                \
> >     +} while (0)
> > 
> 
> I know this is checkpatch and not you complaining about it, but I really
> think it's a useless complaint. I can see it better as a do { } while (0)
> because it is creating a "function" like feature but can't be inline due to
> flags.
> 
> This is one of the reasons I still never use checkpatch.pl :-(

Makes sense to me, thank you Steve :)


Thanks,
SJ

[...]

^ permalink raw reply

* Re: [PATCH v17 0/3] Improve proc RSS accuracy
From: Nathan Chancellor @ 2026-02-27  1:12 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Heiko Carstens, Andrew Morton, linux-kernel, Paul E. McKenney,
	Steven Rostedt, Masami Hiramatsu, Dennis Zhou, Tejun Heo,
	Christoph Lameter, Martin Liu, David Rientjes, christian.koenig,
	Shakeel Butt, SeongJae Park, Michal Hocko, Johannes Weiner,
	Sweet Tea Dorminy, Lorenzo Stoakes, Liam R . Howlett,
	Mike Rapoport, Suren Baghdasaryan, Vlastimil Babka,
	Christian Brauner, Wei Yang, David Hildenbrand, Miaohe Lin,
	Al Viro, linux-mm, linux-trace-kernel, Yu Zhao, Roman Gushchin,
	Mateusz Guzik, Matthew Wilcox, Baolin Wang, Aboorva Devarajan,
	Vasily Gorbik, linux-s390
In-Reply-To: <73e6fea9-caf2-4404-b511-11646013f8db@efficios.com>

Hi Mathieu,

On Thu, Feb 26, 2026 at 02:38:04PM -0500, Mathieu Desnoyers wrote:
> I've successfully booted a defconfig s390x next-20260226 kernel in qemu
> with 1 and 4 CPUs, and within a nested s390x VM on 2 cpus.
> 
> I guess I'll really need more info about your specific .config and
> command line args to help further.

FWIW, the ClangBuiltLinux CI sees a boot failure with sparc64_defconfig,
which does not appear to be clang specific. I can reproduce it here
with:

  $ make -skj"$(nproc)" ARCH=sparc CROSS_COMPILE=sparc64-linux- mrproper sparc64_defconfig image

  $ curl -LSs https://github.com/ClangBuiltLinux/boot-utils/releases/download/20241120-044434/sparc64-rootfs.cpio.zst | zstd -d >rootfs.cpio

  $ qemu-system-sparc64 \
      -display none \
      -nodefaults \
      -M sun4u \
      -cpu 'TI UltraSparc IIi' \
      -append console=ttyS0 \
      -kernel arch/sparc/boot/image \
      -initrd rootfs.cpio \
      -m 1G \
      -serial mon:stdio
  ...
  [    0.001502] Linux version 7.0.0-rc1+ (nathan@framework-amd-ryzen-maxplus-395) (sparc64-linux-gcc (GCC) 15.2.0, GNU ld (GNU Binutils) 2.45) #1 SMP Thu Feb 26 18:00:08 MST 2026
  ...
  [    1.339282] Run /init as init process
  [    1.340037] Unable to handle kernel NULL pointer dereference
  [    1.340515] tsk->{mm,active_mm}->context = 0000000000000000
  [    1.340684] tsk->{mm,active_mm}->pgd = fffff80000402000
  [    1.340838]               \|/ ____ \|/
  [    1.340838]               "@'/ .. \`@"
  [    1.340838]               /_| \__/ |_\
  [    1.340838]                  \__U_/
  [    1.341260] swapper/0(1): Oops [#1]
  [    1.341575] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.0.0-rc1+ #1 VOLUNTARY
  [    1.341937] TSTATE: 0000004411001606 TPC: 0000000000465674 TNPC: 0000000000465678 Y: 00000021    Not tainted
  [    1.342199] TPC: <init_new_context+0x14/0xc0>
  [    1.342584] g0: 0000000000000000 g1: 0000000000000000 g2: 0000000000000000 g3: 0000000000000000
  [    1.342815] g4: fffff80004170000 g5: fffff8003e1d2000 g6: fffff80004134000 g7: fffff8003f814598
  [    1.343047] o0: fffff8000479c0a0 o1: 0000000000000000 o2: 0000000000002000 o3: 0000000000000000
  [    1.343276] o4: fffff80004621200 o5: fffff80004006e00 sp: fffff80004137331 ret_pc: 000000000062a520
  [    1.343513] RPC: <kmem_cache_alloc_noprof+0x1c0/0x560>
  [    1.343681] l0: ffffffffffffffff l1: 0000000000000000 l2: 0000000000000001 l3: 0000000000000000
  [    1.343917] l4: 000000004fd6805e l5: 0000000001503c00 l6: 0000000001423800 l7: 0000000000000012
  [    1.344144] i0: fffff80004170000 i1: fffff8000479c0a0 i2: 0000000000472030 i3: 000000000180ac00
  [    1.344371] i4: 0000000000000000 i5: fffff8000400b500 i6: fffff800041373e1 i7: 0000000000472044
  [    1.344601] I7: <mm_init.isra.0+0x144/0x1e0>
  [    1.344751] Call Trace:
  [    1.344871] [<0000000000472044>] mm_init.isra.0+0x144/0x1e0
  [    1.345054] [<00000000006602ec>] alloc_bprm+0xcc/0x1e0
  [    1.345195] [<0000000000660e6c>] kernel_execve+0x2c/0x1c0
  [    1.345345] [<0000000000be4060>] kernel_init+0x70/0x128
  [    1.345496] [<00000000004060f0>] ret_from_fork+0x24/0x34
  [    1.345652] [<0000000000000000>] 0x0
  [    1.345823] Disabling lock debugging due to kernel taint
  [    1.346046] Caller[0000000000472044]: mm_init.isra.0+0x144/0x1e0
  [    1.346229] Caller[00000000006602ec]: alloc_bprm+0xcc/0x1e0
  [    1.346388] Caller[0000000000660e6c]: kernel_execve+0x2c/0x1c0
  [    1.346553] Caller[0000000000be4060]: kernel_init+0x70/0x128
  [    1.346707] Caller[00000000004060f0]: ret_from_fork+0x24/0x34
  [    1.346864] Caller[0000000000000000]: 0x0
  [    1.346985] Instruction DUMP:
  [    1.347007]  92102000
  [    1.347135]  90100019
  [    1.347204]  f85e6490
  [    1.347281] <c6588000>
  [    1.347349]  c25e6388
  [    1.347416]  fa5e6488
  [    1.347485]  82004003
  [    1.347552]  c65e63c0
  [    1.347619]  83784c00
  [    1.347689]
  [    1.348041] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
  [    1.348649] Press Stop-A (L1-A) from sun keyboard or send break
  [    1.348649] twice on console to return to the boot prom
  [    1.348940] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009 ]---

This series is not bisectable to see which specific patch causes this,
as I get

  In file included from mm/init-mm.c:2:
  include/linux/mm_types.h:1419:57: error: 'PERCPU_COUNTER_TREE_ITEMS_STATIC_SIZE' undeclared here (not in a function)
   1419 |         [0 ... sizeof(cpumask_t) + MM_CID_STATIC_SIZE + PERCPU_COUNTER_TREE_ITEMS_STATIC_SIZE. - 1] = 0  \
        |                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  mm/init-mm.c:50:27: note: in expansion of macro 'MM_STRUCT_FLEXIBLE_ARRAY_INIT'
     50 |         .flexible_array = MM_STRUCT_FLEXIBLE_ARRAY_INIT,
        |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  include/linux/mm_types.h:1419:10: error: array index in initializer not of integer type
   1419 |         [0 ... sizeof(cpumask_t) + MM_CID_STATIC_SIZE + PERCPU_COUNTER_TREE_ITEMS_STATIC_SIZE - 1] = 0  \
        |          ^
  mm/init-mm.c:50:27: note: in expansion of macro 'MM_STRUCT_FLEXIBLE_ARRAY_INIT'
     50 |         .flexible_array = MM_STRUCT_FLEXIBLE_ARRAY_INIT,
        |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  include/linux/mm_types.h:1419:10: note: (near initialization for 'init_mm.flexible_array')
   1419 |         [0 ... sizeof(cpumask_t) + MM_CID_STATIC_SIZE + PERCPU_COUNTER_TREE_ITEMS_STATIC_SIZE - 1] = 0  \
        |          ^
  mm/init-mm.c:50:27: note: in expansion of macro 'MM_STRUCT_FLEXIBLE_ARRAY_INIT'
     50 |         .flexible_array = MM_STRUCT_FLEXIBLE_ARRAY_INIT,
        |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

prior to this change that removes PERCPU_COUNTER_TREE_ITEMS_STATIC_SIZE.

Cheers,
Nathan

^ permalink raw reply

* Re: [PATCH] kernel/trace/ftrace: introduce ftrace module notifier
From: Song Chen @ 2026-02-27  1:34 UTC (permalink / raw)
  To: Steven Rostedt, Miroslav Benes
  Cc: mcgrof, petr.pavlu, da.gomez, samitolvanen, atomlin, mhiramat,
	mark.rutland, mathieu.desnoyers, linux-modules, linux-kernel,
	linux-trace-kernel, live-patching
In-Reply-To: <20260226123014.2197d9b7@gandalf.local.home>

Hi,

在 2026/2/27 01:30, Steven Rostedt 写道:
> On Thu, 26 Feb 2026 11:51:53 +0100 (CET)
> Miroslav Benes <mbenes@suse.cz> wrote:
> 
>>> Let me see if there is any way to use notifier and remain below calling
>>> sequence:
>>>
>>> ftrace_module_enable
>>> klp_module_coming
>>> blocking_notifier_call_chain_robust(MODULE_STATE_COMING)
>>>
>>> blocking_notifier_call_chain(MODULE_STATE_GOING)
>>> klp_module_going
>>> ftrace_release_mod
>>
>> Both klp and ftrace used module notifiers in the past. We abandoned that
>> and opted for direct calls due to issues with ordering at the time. I do
>> not have the list of problems at hand but I remember it was very fragile.
>>
>> See commits 7dcd182bec27 ("ftrace/module: remove ftrace module
>> notifier"), 7e545d6eca20 ("livepatch/module: remove livepatch module
>> notifier") and their surroundings.
>>
>> So unless there is a reason for the change (which should be then carefully
>> reviewed and properly tested), I would prefer to keep it as is. What is
>> the motivation? I am failing to find it in the commit log.

There is no special motivation, i just read btf initialization in module 
loading and found direct calls of ftrace and klp, i thought they were 
just forgotten to use notifier and i even didn't search git log to 
verify, sorry about that.

> 
> Honestly, I do think just decoupling ftrace and live kernel patching from
> modules is rationale enough, as it makes the code a bit cleaner. But to do
> so, we really need to make sure there is absolutely no regressions.
> 
> Thus, to allow such a change, I would ask those that are proposing it, show
> a full work flow of how ftrace, live kernel patching, and modules work with
> each other and why those functions are currently injected in the module code.
> 
> As Miroslav stated, we tried to do it via notifiers in the past and it
> failed. I don't want to find out why they failed by just adding them back
> to notifiers again. Instead, the reasons must be fully understood and
> updates made to make sure they will not fail in the future.

Yes, you are right, i read commit msg of 7dcd182bec27, this patch just 
reverses it simply and will introduce order issue back. I will try to 
find out the problem in the past at first.

Thank you both.

/Song

> 
> -- Steve
> 
> 


^ permalink raw reply

* [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close
From: Qing Wang @ 2026-02-27  2:58 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Qing Wang,
	Vincent Donnefort
  Cc: linux-kernel, linux-trace-kernel, syzbot+3b5dd2030fe08afdf65d

When a process forks, the child process copies the parent's VMAs but the
user_mapped reference count is not incremented. As a result, when both the
parent and child processes exit, tracing_buffers_mmap_close() is called
twice. On the second call, user_mapped is already 0, causing the function to
return -ENODEV and triggering a WARN_ON.

Fix it by incrementing the user_mapped reference count without re-mapping
the pages in the VMA's open callback.

Fixes: cf9f0f7c4c5bb ("tracing: Allow user-space mapping of the ring-buffer")
Reported-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3b5dd2030fe08afdf65d
Tested-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
Signed-off-by: Qing Wang <wangqing7171@gmail.com>
---
 include/linux/ring_buffer.h |  1 +
 kernel/trace/ring_buffer.c  | 21 +++++++++++++++++++++
 kernel/trace/trace.c        | 13 +++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 876358cfe1b1..d862fa610270 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -248,6 +248,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node);
 
 int ring_buffer_map(struct trace_buffer *buffer, int cpu,
 		    struct vm_area_struct *vma);
+void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu);
 int ring_buffer_unmap(struct trace_buffer *buffer, int cpu);
 int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu);
 #endif /* _LINUX_RING_BUFFER_H */
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f16f053ef77d..17d0ea0cc3e6 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -7310,6 +7310,27 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
 	return err;
 }
 
+/*
+ * This is called when a VMA is duplicated (e.g., on fork()) to increment
+ * the user_mapped counter without remapping pages.
+ */
+void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu)
+{
+	struct ring_buffer_per_cpu *cpu_buffer;
+
+	if (WARN_ON(!cpumask_test_cpu(cpu, buffer->cpumask)))
+		return;
+
+	cpu_buffer = buffer->buffers[cpu];
+
+	guard(mutex)(&cpu_buffer->mapping_lock);
+
+	if (cpu_buffer->user_mapped)
+		__rb_inc_dec_mapped(cpu_buffer, true);
+	else
+		WARN(1, "Unexpected buffer stat, it should be mapped");
+}
+
 int ring_buffer_unmap(struct trace_buffer *buffer, int cpu)
 {
 	struct ring_buffer_per_cpu *cpu_buffer;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 23de3719f495..1e7c032a72d2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8213,6 +8213,18 @@ static inline int get_snapshot_map(struct trace_array *tr) { return 0; }
 static inline void put_snapshot_map(struct trace_array *tr) { }
 #endif
 
+/*
+ * This is called when a VMA is duplicated (e.g., on fork()) to increment
+ * the user_mapped counter without remapping pages.
+ */
+static void tracing_buffers_mmap_open(struct vm_area_struct *vma)
+{
+	struct ftrace_buffer_info *info = vma->vm_file->private_data;
+	struct trace_iterator *iter = &info->iter;
+
+	ring_buffer_map_dup(iter->array_buffer->buffer, iter->cpu_file);
+}
+
 static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
 {
 	struct ftrace_buffer_info *info = vma->vm_file->private_data;
@@ -8232,6 +8244,7 @@ static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long a
 }
 
 static const struct vm_operations_struct tracing_buffers_vmops = {
+	.open		= tracing_buffers_mmap_open,
 	.close		= tracing_buffers_mmap_close,
 	.may_split      = tracing_buffers_may_split,
 };
-- 
2.34.1


^ permalink raw reply related

* Re: [syzbot] [trace?] WARNING in tracing_buffers_mmap_close (3)
From: Qing Wang @ 2026-02-27  3:07 UTC (permalink / raw)
  To: rostedt
  Cc: linux-kernel, linux-trace-kernel, mathieu.desnoyers, mhiramat,
	syzbot+3b5dd2030fe08afdf65d, syzkaller-bugs, wangqing7171
In-Reply-To: <20260226115229.7111b070@gandalf.local.home>

On Fri, 27 Feb 2026 at 00:52, Steven Rostedt <rostedt@goodmis.org> wrote:
> OK, so the issue is that the ring buffer was mapped, then the process that
> mapped it forked duplicating the mappings. And then on exit (or unmap),
> the first one to unmap the buffer will cause the ring buffer to think it
> was fully unmapped causing the next one to unmap to trigger the error.
> 
> 
> > + */
> > +void ring_buffer_map_user_mapped_inc(struct trace_buffer *buffer, int cpu)
> 
> Let's call this ring_buffer_map_dup() to be consistent with ring_buffer_map().
> 
> inc would expect a dec, but dup() is more of what it is doing.
> 
> > +{
> > +	struct ring_buffer_per_cpu *cpu_buffer;
> > +
> > +	if (!cpumask_test_cpu(cpu, buffer->cpumask))
> > +		return;
> 
> I wonder if this fails we should warn. As it should never be called unless
> it was successfully mapped.
> 
> > +
> > +	cpu_buffer = buffer->buffers[cpu];
> > +
> > +	guard(mutex)(&cpu_buffer->mapping_lock);
> > +
> > +	if (cpu_buffer->user_mapped)
> > +		__rb_inc_dec_mapped(cpu_buffer, true);
> 
> Probably should also warn if user_mapped is not set. Again, this should not
> ever not be mapped if we get here.
> 
> -- Steve

Thanks for your suggestion. I sent a patch [0] and looking forward to your review.
 [0] https://lore.kernel.org/all/20260227025842.1085206-1-wangqing7171@gmail.com/

--
Best regards,
Qing

^ permalink raw reply

* Re: [syzbot] [bpf?] [trace?] KASAN: slab-use-after-free Read in bpf_trace_run3 (2)
From: Qing Wang @ 2026-02-27  3:53 UTC (permalink / raw)
  To: syzbot+9ea7c90be2b24e189592
  Cc: andrii, ast, bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa,
	kpsingh, linux-kernel, linux-trace-kernel, martin.lau,
	mathieu.desnoyers, mattbobrowski, mhiramat, rostedt, sdf, song,
	syzkaller-bugs, yonghong.song
In-Reply-To: <69a0544c.050a0220.3a55be.0004.GAE@google.com>

#syz test

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2d14fb6d0ed0..038bf4436959 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3783,6 +3783,8 @@ static void bpf_raw_tp_link_release(struct bpf_link *link)
 
 	bpf_probe_unregister(raw_tp->btp, raw_tp);
 	bpf_put_raw_tracepoint(raw_tp->btp);
+
+	synchronize_rcu();
 }
 
 static void bpf_raw_tp_link_dealloc(struct bpf_link *link)

^ permalink raw reply related

* Re: [syzbot] [bpf?] [trace?] KASAN: slab-use-after-free Read in bpf_trace_run3 (2)
From: syzbot @ 2026-02-27  4:12 UTC (permalink / raw)
  To: andrii, ast, bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa,
	kpsingh, linux-kernel, linux-trace-kernel, martin.lau,
	mathieu.desnoyers, mattbobrowski, mhiramat, rostedt, sdf, song,
	syzkaller-bugs, wangqing7171, yonghong.song
In-Reply-To: <20260227035341.1108372-1-wangqing7171@gmail.com>

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in bpf_trace_run3

==================================================================
BUG: KASAN: slab-use-after-free in __bpf_trace_run kernel/trace/bpf_trace.c:2075 [inline]
BUG: KASAN: slab-use-after-free in bpf_trace_run3+0xdd/0x850 kernel/trace/bpf_trace.c:2130
Read of size 8 at addr ffff888047c32a18 by task syz.0.2435/10835

CPU: 0 UID: 0 PID: 10835 Comm: syz.0.2435 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xba/0x230 mm/kasan/report.c:482
 kasan_report+0x117/0x150 mm/kasan/report.c:595
 __bpf_trace_run kernel/trace/bpf_trace.c:2075 [inline]
 bpf_trace_run3+0xdd/0x850 kernel/trace/bpf_trace.c:2130
 __bpf_trace_mmap_lock_acquire_returned+0x17e/0x1d0 include/trace/events/mmap_lock.h:47
 __do_trace_mmap_lock_acquire_returned include/trace/events/mmap_lock.h:47 [inline]
 trace_mmap_lock_acquire_returned include/trace/events/mmap_lock.h:47 [inline]
 __mmap_lock_do_trace_acquire_returned+0x1a1/0x210 mm/mmap_lock.c:35
 __mmap_lock_trace_acquire_returned include/linux/mmap_lock.h:42 [inline]
 mmap_write_lock_killable include/linux/mmap_lock.h:557 [inline]
 do_mprotect_pkey+0x389/0xcd0 mm/mprotect.c:832
 __do_sys_mprotect mm/mprotect.c:951 [inline]
 __se_sys_mprotect mm/mprotect.c:948 [inline]
 __x64_sys_mprotect+0x80/0x90 mm/mprotect.c:948
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fa0dcb9c427
Code: 89 38 eb 84 0f 1f 80 00 00 00 00 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 48 c7 c0 ff ff ff ff e9 7a ff ff ff b8 0a 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff44e34e58 EFLAGS: 00000206 ORIG_RAX: 000000000000000a
RAX: ffffffffffffffda RBX: 00007fa0ddad26c0 RCX: 00007fa0dcb9c427
RDX: 0000000000000003 RSI: 0000000000020000 RDI: 00007fa0ddab3000
RBP: 0000000000000000 R08: 00000000ffffffff R09: 0000000000000000
R10: 0000000000021000 R11: 0000000000000206 R12: 00007fff44e34fb0
R13: ffffffffffffffc0 R14: 0000000000001000 R15: 0000000000000000
 </TASK>

Allocated by task 10832:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
 kasan_kmalloc include/linux/kasan.h:263 [inline]
 __kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5339
 kmalloc_noprof include/linux/slab.h:962 [inline]
 kzalloc_noprof include/linux/slab.h:1200 [inline]
 bpf_raw_tp_link_attach+0x278/0x700 kernel/bpf/syscall.c:4266
 bpf_raw_tracepoint_open+0x1b2/0x220 kernel/bpf/syscall.c:4314
 __sys_bpf+0x846/0x950 kernel/bpf/syscall.c:6272
 __do_sys_bpf kernel/bpf/syscall.c:6343 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:6341 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:6341
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5963:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
 poison_slab_object mm/kasan/common.c:253 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:2687 [inline]
 slab_free mm/slub.c:6124 [inline]
 kfree+0x1c1/0x630 mm/slub.c:6442
 rcu_do_batch kernel/rcu/tree.c:2617 [inline]
 rcu_core+0x7cd/0x1070 kernel/rcu/tree.c:2869
 handle_softirqs+0x22a/0x870 kernel/softirq.c:622
 do_softirq+0x76/0xd0 kernel/softirq.c:523
 __local_bh_enable_ip+0xf8/0x130 kernel/softirq.c:450
 local_bh_enable include/linux/bottom_half.h:33 [inline]
 update_defense_level+0x91e/0xd70 net/netfilter/ipvs/ip_vs_ctl.c:209
 defense_work_handler+0x2d/0xd0 net/netfilter/ipvs/ip_vs_ctl.c:234
 process_one_work kernel/workqueue.c:3275 [inline]
 process_scheduled_works+0xb02/0x1830 kernel/workqueue.c:3358
 worker_thread+0xa50/0xfc0 kernel/workqueue.c:3439
 kthread+0x388/0x470 kernel/kthread.c:467
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Last potentially related work creation:
 kasan_save_stack+0x3e/0x60 mm/kasan/common.c:57
 kasan_record_aux_stack+0xbd/0xd0 mm/kasan/generic.c:556
 __call_rcu_common kernel/rcu/tree.c:3131 [inline]
 call_rcu+0xee/0x890 kernel/rcu/tree.c:3251
 bpf_link_put_direct kernel/bpf/syscall.c:3323 [inline]
 bpf_link_release+0x6b/0x80 kernel/bpf/syscall.c:3330
 __fput+0x44f/0xa70 fs/file_table.c:469
 task_work_run+0x1d9/0x270 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
 do_syscall_64+0x32d/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888047c32a00
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 24 bytes inside of
 freed 192-byte region [ffff888047c32a00, ffff888047c32ac0)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x47c32
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff88801ac413c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5734, tgid 5734 (syz-executor), ts 170582106129, free_ts 164219023362
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
 prep_new_page mm/page_alloc.c:1897 [inline]
 get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
 __alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
 alloc_slab_page mm/slub.c:3255 [inline]
 allocate_slab+0x77/0x660 mm/slub.c:3444
 new_slab mm/slub.c:3502 [inline]
 refill_objects+0x331/0x3c0 mm/slub.c:7134
 refill_sheaf mm/slub.c:2804 [inline]
 __pcs_replace_empty_main+0x2b9/0x620 mm/slub.c:4578
 alloc_from_pcs mm/slub.c:4681 [inline]
 slab_alloc_node mm/slub.c:4815 [inline]
 __kmalloc_cache_noprof+0x392/0x660 mm/slub.c:5334
 kmalloc_noprof include/linux/slab.h:962 [inline]
 kzalloc_noprof include/linux/slab.h:1200 [inline]
 kset_create lib/kobject.c:965 [inline]
 kset_create_and_add+0x5a/0x170 lib/kobject.c:1008
 register_queue_kobjects net/core/net-sysfs.c:2106 [inline]
 netdev_register_kobject+0x1a2/0x310 net/core/net-sysfs.c:2362
 register_netdevice+0x12c0/0x1cf0 net/core/dev.c:11422
 nsim_init_netdevsim drivers/net/netdevsim/netdev.c:1063 [inline]
 nsim_create+0xb92/0x1100 drivers/net/netdevsim/netdev.c:1145
 __nsim_dev_port_add+0x72a/0xb50 drivers/net/netdevsim/dev.c:1493
 nsim_dev_port_add_all+0x37/0xf0 drivers/net/netdevsim/dev.c:1549
 nsim_drv_probe+0x905/0xc20 drivers/net/netdevsim/dev.c:1710
 call_driver_probe drivers/base/dd.c:-1 [inline]
 really_probe+0x267/0xaf0 drivers/base/dd.c:661
 __driver_probe_device+0x18c/0x320 drivers/base/dd.c:803
page last free pid 29 tgid 29 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 __free_pages_prepare mm/page_alloc.c:1433 [inline]
 __free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
 __folio_put+0x414/0x4f0 mm/swap.c:112
 folio_put include/linux/mm.h:1817 [inline]
 migrate_folio_done mm/migrate.c:1199 [inline]
 migrate_folio_move mm/migrate.c:1413 [inline]
 migrate_folios_move mm/migrate.c:1721 [inline]
 migrate_pages_batch+0x3593/0x4d80 mm/migrate.c:1977
 migrate_pages_sync mm/migrate.c:2007 [inline]
 migrate_pages+0x1c74/0x2a70 mm/migrate.c:2116
 compact_zone+0x26cd/0x4850 mm/compaction.c:2647
 compact_node+0x21a/0x320 mm/compaction.c:2916
 kcompactd+0xc20/0x1330 mm/compaction.c:3214
 kthread+0x388/0x470 kernel/kthread.c:467
 ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Memory state around the buggy address:
 ffff888047c32900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888047c32980: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
>ffff888047c32a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888047c32a80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888047c32b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


Tested on:

commit:         a75cb869 Merge tag 'v7.0-rc1-ksmbd-server-fixes' of gi..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1648cd5a580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=56150637ffd942dd
dashboard link: https://syzkaller.appspot.com/bug?extid=9ea7c90be2b24e189592
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=16640952580000


^ permalink raw reply

* [PATCH] blktrace: fix __this_cpu_read/write in preemptible context
From: Chaitanya Kulkarni @ 2026-02-27  5:03 UTC (permalink / raw)
  To: axboe, rostedt, mhiramat, mathieu.desnoyers
  Cc: shinichiro.kawasaki, linux-block, linux-trace-kernel,
	Chaitanya Kulkarni

tracing_record_cmdline() internally uses __this_cpu_read() and
__this_cpu_write() on the per-CPU variable trace_taskinfo_save, and
trace_save_cmdline() explicitly asserts preemption is disabled via
lockdep_assert_preemption_disabled().  These operations are safe only
when preemption is off, as they were designed to be called from the
scheduler's context probe_wakeup_sched_switch() / probe_wakeup().

__blk_add_trace() calls tracing_record_cmdline(current) from process
context where preemption is fully enabled, triggering the following
splat on using blktests/blktrace/002:

blktrace/002 (blktrace ftrace corruption with sysfs trace)   [failed]
    runtime  0.367s  ...  0.437s
    something found in dmesg:
    [   81.211018] run blktests blktrace/002 at 2026-02-25 22:24:33
    [   81.239580] null_blk: disk nullb1 created
    [   81.357294] BUG: using __this_cpu_read() in preemptible [00000000] code: dd/2516
    [   81.362842] caller is tracing_record_cmdline+0x10/0x40
    [   81.362872] CPU: 16 UID: 0 PID: 2516 Comm: dd Tainted: G                 N  7.0.0-rc1lblk+ #84 PREEMPT(full)
    [   81.362877] Tainted: [N]=TEST
    [   81.362878] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014
    [   81.362881] Call Trace:
    [   81.362884]  <TASK>
    [   81.362886]  dump_stack_lvl+0x8d/0xb0
    ...
    (See '/mnt/sda/blktests/results/nodev/blktrace/002.dmesg' for the entire message)

[   81.211018] run blktests blktrace/002 at 2026-02-25 22:24:33
[   81.239580] null_blk: disk nullb1 created
[   81.357294] BUG: using __this_cpu_read() in preemptible [00000000] code: dd/2516
[   81.362842] caller is tracing_record_cmdline+0x10/0x40
[   81.362872] CPU: 16 UID: 0 PID: 2516 Comm: dd Tainted: G                 N  7.0.0-rc1lblk+ #84 PREEMPT(full)
[   81.362877] Tainted: [N]=TEST
[   81.362878] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014
[   81.362881] Call Trace:
[   81.362884]  <TASK>
[   81.362886]  dump_stack_lvl+0x8d/0xb0
[   81.362895]  check_preemption_disabled+0xce/0xe0
[   81.362902]  tracing_record_cmdline+0x10/0x40
[   81.362923]  __blk_add_trace+0x307/0x5d0
[   81.362934]  ? lock_acquire+0xe0/0x300
[   81.362940]  ? iov_iter_extract_pages+0x101/0xa30
[   81.362959]  blk_add_trace_bio+0x106/0x1e0
[   81.362968]  submit_bio_noacct_nocheck+0x24b/0x3a0
[   81.362979]  ? lockdep_init_map_type+0x58/0x260
[   81.362988]  submit_bio_wait+0x56/0x90
[   81.363009]  __blkdev_direct_IO_simple+0x16c/0x250
[   81.363026]  ? __pfx_submit_bio_wait_endio+0x10/0x10
[   81.363038]  ? rcu_read_lock_any_held+0x73/0xa0
[   81.363051]  blkdev_read_iter+0xc1/0x140
[   81.363059]  vfs_read+0x20b/0x330
[   81.363083]  ksys_read+0x67/0xe0
[   81.363090]  do_syscall_64+0xbf/0xf00
[   81.363102]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[   81.363106] RIP: 0033:0x7f281906029d
[   81.363111] Code: 31 c0 e9 c6 fe ff ff 50 48 8d 3d 66 63 0a 00 e8 59 ff 01 00 66 0f 1f 84 00 00 00 00 00 80 3d 41 33 0e 00 00 74 17 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 5b c3 66 2e 0f 1f 84 00 00 00 00 00 48 83 ec
[   81.363113] RSP: 002b:00007ffca127dd48 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[   81.363120] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f281906029d
[   81.363122] RDX: 0000000000001000 RSI: 0000559f8bfae000 RDI: 0000000000000000
[   81.363123] RBP: 0000000000001000 R08: 0000002863a10a81 R09: 00007f281915f000
[   81.363124] R10: 00007f2818f77b60 R11: 0000000000000246 R12: 0000559f8bfae000
[   81.363126] R13: 0000000000000000 R14: 0000000000000000 R15: 000000000000000a
[   81.363142]  </TASK>

The same BUG fires from blk_add_trace_plug(), blk_add_trace_unplug(),
and blk_add_trace_rq() paths as well.

Fix by wrapping the tracing_record_cmdline() call with
preempt_disable()/preempt_enable().  This is a best-effort "record
the comm string for this PID" operation and briefly disabling
preemption around it is both should be safe.

With this patch now blktests for blktrace pass :-

blktests (master) # ./check blktrace
blktrace/001 (blktrace zone management command tracing)      [passed]
    runtime  3.652s  ...  3.649s
blktrace/002 (blktrace ftrace corruption with sysfs trace)   [passed]
    runtime  0.437s  ...  0.389s
blktests (master) #

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 kernel/trace/blktrace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 3b7c102a6eb3..488552036583 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -383,7 +383,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 	cpu = raw_smp_processor_id();
 
 	if (blk_tracer) {
+		preempt_disable_notrace();
 		tracing_record_cmdline(current);
+		preempt_enable_notrace();
 
 		buffer = blk_tr->array_buffer.buffer;
 		trace_ctx = tracing_gen_ctx_flags(0);
-- 
2.39.5


^ permalink raw reply related

* Re: [syzbot] [bpf?] [trace?] KASAN: slab-use-after-free Read in bpf_trace_run3 (2)
From: Qing Wang @ 2026-02-27  6:17 UTC (permalink / raw)
  To: syzbot+9ea7c90be2b24e189592
  Cc: andrii, ast, bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa,
	kpsingh, linux-kernel, linux-trace-kernel, martin.lau,
	mathieu.desnoyers, mattbobrowski, mhiramat, rostedt, sdf, song,
	syzkaller-bugs, yonghong.song
In-Reply-To: <69a0544c.050a0220.3a55be.0004.GAE@google.com>

#syz test

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2d14fb6d0ed0..f7a0116c7e46 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3783,6 +3783,8 @@ static void bpf_raw_tp_link_release(struct bpf_link *link)
 
 	bpf_probe_unregister(raw_tp->btp, raw_tp);
 	bpf_put_raw_tracepoint(raw_tp->btp);
+
+	tracepoint_synchronize_unregister();
 }
 
 static void bpf_raw_tp_link_dealloc(struct bpf_link *link)

^ permalink raw reply related

* Re: [syzbot] [bpf?] [trace?] KASAN: slab-use-after-free Read in bpf_trace_run3 (2)
From: syzbot @ 2026-02-27  6:35 UTC (permalink / raw)
  To: andrii, ast, bpf, daniel, eddyz87, haoluo, john.fastabend, jolsa,
	kpsingh, linux-kernel, linux-trace-kernel, martin.lau,
	mathieu.desnoyers, mattbobrowski, mhiramat, rostedt, sdf, song,
	syzkaller-bugs, wangqing7171, yonghong.song
In-Reply-To: <20260227061759.1126681-1-wangqing7171@gmail.com>

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine



Tested on:

commit:         a75cb869 Merge tag 'v7.0-rc1-ksmbd-server-fixes' of gi..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12e650ba580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=56150637ffd942dd
dashboard link: https://syzkaller.appspot.com/bug?extid=9ea7c90be2b24e189592
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1476755a580000


^ permalink raw reply

* Re: [PATCH v5 1/3] ring-buffer: Flush and stop persistent ring buffer on panic
From: Masami Hiramatsu @ 2026-02-27  7:44 UTC (permalink / raw)
  To: kernel test robot
  Cc: Steven Rostedt, oe-kbuild-all, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel
In-Reply-To: <202602270244.3JWhusi4-lkp@intel.com>

On Fri, 27 Feb 2026 02:48:26 +0800
kernel test robot <lkp@intel.com> wrote:

> Hi Masami,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v7.0-rc1 next-20260226]
> [cannot apply to trace/for-next]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Masami-Hiramatsu-Google/ring-buffer-Flush-and-stop-persistent-ring-buffer-on-panic/20260226-222418
> base:   linus/master
> patch link:    https://lore.kernel.org/r/177211311593.419230.2212568977306190482.stgit%40mhiramat.tok.corp.google.com
> patch subject: [PATCH v5 1/3] ring-buffer: Flush and stop persistent ring buffer on panic
> config: sparc-randconfig-001-20260227 (https://download.01.org/0day-ci/archive/20260227/202602270244.3JWhusi4-lkp@intel.com/config)
> compiler: sparc64-linux-gcc (GCC) 11.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260227/202602270244.3JWhusi4-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202602270244.3JWhusi4-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    kernel/trace/ring_buffer.c: In function 'rb_flush_buffer_cb':
> >> kernel/trace/ring_buffer.c:2481:9: error: implicit declaration of function 'flush_cache_all'; did you mean 'flush_cache_page'? [-Werror=implicit-function-declaration]
>     2481 |         flush_cache_all();
>          |         ^~~~~~~~~~~~~~~
>          |         flush_cache_page
>    cc1: some warnings being treated as errors

I guess this is a miss of the sparc. Anyway, I will add asm/ring_buffer.h
to define a wrapper macro. At least I need to sync the cache on arm64 but
flush_cache_all() is a dummy on arm64. I would like to use dcache_clear_pop()
instead.

Thanks,

> 
> 
> vim +2481 kernel/trace/ring_buffer.c
> 
>   2475	
>   2476	static int rb_flush_buffer_cb(struct notifier_block *nb, unsigned long event, void *data)
>   2477	{
>   2478		struct trace_buffer *buffer = container_of(nb, struct trace_buffer, flush_nb);
>   2479	
>   2480		ring_buffer_record_off(buffer);
> > 2481		flush_cache_all();
>   2482		return NOTIFY_DONE;
>   2483	}
>   2484	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply

* Re: [PATCH 47/61] ubifs: update format strings for u64 i_ino
From: Zhihao Cheng @ 2026-02-27  8:16 UTC (permalink / raw)
  To: Jeff Layton, Alexander Viro, Christian Brauner, Jan Kara,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Dan Williams,
	Matthew Wilcox, Eric Biggers, Theodore Y. Ts'o, Muchun Song,
	Oscar Salvador, David Hildenbrand, David Howells, Paulo Alcantara,
	Andreas Dilger, Jan Kara, Jaegeuk Kim, Chao Yu, Trond Myklebust,
	Anna Schumaker, Chuck Lever, NeilBrown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, Steve French, Ronnie Sahlberg,
	Shyam Prasad N, Bharath SM, Alexander Aring, Ryusuke Konishi,
	Viacheslav Dubeyko, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck, David Sterba,
	Marc Dionne, Ian Kent, Luis de Bethencourt, Salah Triki,
	Tigran A. Aivazian, Ilya Dryomov, Alex Markuze, Jan Harkes, coda,
	Nicolas Pitre, Tyler Hicks, Amir Goldstein, Christoph Hellwig,
	John Paul Adrian Glaubitz, Yangtao Li, Mikulas Patocka,
	David Woodhouse, Richard Weinberger, Dave Kleikamp,
	Konstantin Komarov, Mark Fasheh, Joel Becker, Joseph Qi,
	Mike Marshall, Martin Brandenburg, Miklos Szeredi, Anders Larsen,
	Damien Le Moal, Naohiro Aota, Johannes Thumshirn, John Johansen,
	Paul Moore, James Morris, Serge E. Hallyn, Mimi Zohar,
	Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
	Stephen Smalley, Ondrej Mosnacek, Casey Schaufler, Alex Deucher,
	Christian König, David Airlie, Simona Vetter, Sumit Semwal,
	Eric Dumazet, Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn,
	David S. Miller, Jakub Kicinski, Simon Horman, Oleg Nesterov,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, James Clark, Darrick J. Wong,
	Martin Schiller
  Cc: linux-fsdevel, linux-kernel, linux-trace-kernel, nvdimm, fsverity,
	linux-mm, netfs, linux-ext4, linux-f2fs-devel, linux-nfs,
	linux-cifs, samba-technical, linux-nilfs, v9fs, linux-afs, autofs,
	ceph-devel, codalist, ecryptfs, linux-mtd, jfs-discussion, ntfs3,
	ocfs2-devel, devel, linux-unionfs, apparmor,
	linux-security-module, linux-integrity, selinux, amd-gfx,
	dri-devel, linux-media, linaro-mm-sig, netdev, linux-perf-users,
	linux-fscrypt, linux-xfs, linux-hams, linux-x25
In-Reply-To: <20260226-iino-u64-v1-47-ccceff366db9@kernel.org>

在 2026/2/26 23:55, Jeff Layton 写道:
> Update format strings and local variable types in ubifs for the
> i_ino type change from unsigned long to u64.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   fs/ubifs/debug.c   |  8 ++++----
>   fs/ubifs/dir.c     | 28 ++++++++++++++--------------
>   fs/ubifs/file.c    | 28 ++++++++++++++--------------
>   fs/ubifs/journal.c |  6 +++---
>   fs/ubifs/super.c   | 16 ++++++++--------
>   fs/ubifs/tnc.c     |  4 ++--
>   fs/ubifs/xattr.c   | 14 +++++++-------
>   7 files changed, 52 insertions(+), 52 deletions(-)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 160c16aa7b6e7088355582670357262ab3930225..5794de5a9069f20302b6630c39c1452183137acc 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -230,7 +230,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>   	int count = 2;
>   
>   	pr_err("Dump in-memory inode:");
> -	pr_err("\tinode          %lu\n", inode->i_ino);
> +	pr_err("\tinode          %llu\n", inode->i_ino);
>   	pr_err("\tsize           %llu\n",
>   	       (unsigned long long)i_size_read(inode));
>   	pr_err("\tnlink          %u\n", inode->i_nlink);
> @@ -1101,7 +1101,7 @@ int dbg_check_synced_i_size(const struct ubifs_info *c, struct inode *inode)
>   	if (ui->ui_size != ui->synced_i_size && !ui->dirty) {
>   		ubifs_err(c, "ui_size is %lld, synced_i_size is %lld, but inode is clean",
>   			  ui->ui_size, ui->synced_i_size);
> -		ubifs_err(c, "i_ino %lu, i_mode %#x, i_size %lld", inode->i_ino,
> +		ubifs_err(c, "i_ino %llu, i_mode %#x, i_size %lld", inode->i_ino,
>   			  inode->i_mode, i_size_read(inode));
>   		dump_stack();
>   		err = -EINVAL;
> @@ -1163,7 +1163,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir)
>   	kfree(pdent);
>   
>   	if (i_size_read(dir) != size) {
> -		ubifs_err(c, "directory inode %lu has size %llu, but calculated size is %llu",
> +		ubifs_err(c, "directory inode %llu has size %llu, but calculated size is %llu",
>   			  dir->i_ino, (unsigned long long)i_size_read(dir),
>   			  (unsigned long long)size);
>   		ubifs_dump_inode(c, dir);
> @@ -1171,7 +1171,7 @@ int dbg_check_dir(struct ubifs_info *c, const struct inode *dir)
>   		return -EINVAL;
>   	}
>   	if (dir->i_nlink != nlink) {
> -		ubifs_err(c, "directory inode %lu has nlink %u, but calculated nlink is %u",
> +		ubifs_err(c, "directory inode %llu has nlink %u, but calculated nlink is %u",
>   			  dir->i_ino, dir->i_nlink, nlink);
>   		ubifs_dump_inode(c, dir);
>   		dump_stack();
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 4c9f57f3b2adbbd396b288878cb18fa87cdbd0df..86d41e077e4d621dbb8c448acd0065c8ac7ae225 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -223,7 +223,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
>   	struct ubifs_info *c = dir->i_sb->s_fs_info;
>   	struct fscrypt_name nm;
>   
> -	dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
> +	dbg_gen("'%pd' in dir ino %llu", dentry, dir->i_ino);
>   
>   	err = fscrypt_prepare_lookup(dir, dentry, &nm);
>   	if (err == -ENOENT)
> @@ -281,7 +281,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
>   	if (IS_ENCRYPTED(dir) &&
>   	    (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
>   	    !fscrypt_has_permitted_context(dir, inode)) {
> -		ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu",
> +		ubifs_warn(c, "Inconsistent encryption contexts: %llu/%llu",
>   			   dir->i_ino, inode->i_ino);
>   		iput(inode);
>   		inode = ERR_PTR(-EPERM);
> @@ -318,7 +318,7 @@ static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
>   	 * parent directory inode.
>   	 */
>   
> -	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
> +	dbg_gen("dent '%pd', mode %#hx in dir ino %llu",
>   		dentry, mode, dir->i_ino);
>   
>   	err = ubifs_budget_space(c, &req);
> @@ -386,7 +386,7 @@ static struct inode *create_whiteout(struct inode *dir, struct dentry *dentry)
>   	 * atomically.
>   	 */
>   
> -	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
> +	dbg_gen("dent '%pd', mode %#hx in dir ino %llu",
>   		dentry, mode, dir->i_ino);
>   
>   	inode = ubifs_new_inode(c, dir, mode, false);
> @@ -460,7 +460,7 @@ static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
>   	 * be released via writeback.
>   	 */
>   
> -	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
> +	dbg_gen("dent '%pd', mode %#hx in dir ino %llu",
>   		dentry, mode, dir->i_ino);
>   
>   	err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm);
> @@ -589,7 +589,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
>   	bool encrypted = IS_ENCRYPTED(dir);
>   	struct ubifs_dir_data *data = file->private_data;
>   
> -	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
> +	dbg_gen("dir ino %llu, f_pos %#llx", dir->i_ino, ctx->pos);
>   
>   	if (ctx->pos > UBIFS_S_KEY_HASH_MASK || ctx->pos == 2)
>   		/*
> @@ -764,7 +764,7 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
>   	 * changing the parent inode.
>   	 */
>   
> -	dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu",
> +	dbg_gen("dent '%pd' to ino %llu (nlink %d) in dir ino %llu",
>   		dentry, inode->i_ino,
>   		inode->i_nlink, dir->i_ino);
>   	ubifs_assert(c, inode_is_locked(dir));
> @@ -836,7 +836,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
>   	 * deletions.
>   	 */
>   
> -	dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu",
> +	dbg_gen("dent '%pd' from ino %llu (nlink %d) in dir ino %llu",
>   		dentry, inode->i_ino,
>   		inode->i_nlink, dir->i_ino);
>   
> @@ -941,7 +941,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
>   	 * because we have extra space reserved for deletions.
>   	 */
>   
> -	dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry,
> +	dbg_gen("directory '%pd', ino %llu in dir ino %llu", dentry,
>   		inode->i_ino, dir->i_ino);
>   	ubifs_assert(c, inode_is_locked(dir));
>   	ubifs_assert(c, inode_is_locked(inode));
> @@ -1018,7 +1018,7 @@ static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>   	 * directory inode.
>   	 */
>   
> -	dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
> +	dbg_gen("dent '%pd', mode %#hx in dir ino %llu",
>   		dentry, mode, dir->i_ino);
>   
>   	err = ubifs_budget_space(c, &req);
> @@ -1096,7 +1096,7 @@ static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
>   	 * directory inode.
>   	 */
>   
> -	dbg_gen("dent '%pd' in dir ino %lu", dentry, dir->i_ino);
> +	dbg_gen("dent '%pd' in dir ino %llu", dentry, dir->i_ino);
>   
>   	if (S_ISBLK(mode) || S_ISCHR(mode)) {
>   		dev = kmalloc_obj(union ubifs_dev_desc, GFP_NOFS);
> @@ -1183,7 +1183,7 @@ static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
>   					.dirtied_ino = 1 };
>   	struct fscrypt_name nm;
>   
> -	dbg_gen("dent '%pd', target '%s' in dir ino %lu", dentry,
> +	dbg_gen("dent '%pd', target '%s' in dir ino %llu", dentry,
>   		symname, dir->i_ino);
>   
>   	err = fscrypt_prepare_symlink(dir, symname, len, UBIFS_MAX_INO_DATA,
> @@ -1349,7 +1349,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>   	 *   ino_req: marks the target inode as dirty and does not write it.
>   	 */
>   
> -	dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu flags 0x%x",
> +	dbg_gen("dent '%pd' ino %llu in dir ino %llu to dent '%pd' in dir ino %llu flags 0x%x",
>   		old_dentry, old_inode->i_ino, old_dir->i_ino,
>   		new_dentry, new_dir->i_ino, flags);
>   
> @@ -1597,7 +1597,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
>   	 * parent directory inodes.
>   	 */
>   
> -	dbg_gen("dent '%pd' ino %lu in dir ino %lu exchange dent '%pd' ino %lu in dir ino %lu",
> +	dbg_gen("dent '%pd' ino %llu in dir ino %llu exchange dent '%pd' ino %llu in dir ino %llu",
>   		old_dentry, fst_inode->i_ino, old_dir->i_ino,
>   		new_dentry, snd_inode->i_ino, new_dir->i_ino);
>   
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index cd04755e792a7f8e7d33ed4e67806cd202c71fad..e73c28b12f97fd1fbeb67510434e499eab84da70 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -90,7 +90,7 @@ static int read_block(struct inode *inode, struct folio *folio, size_t offset,
>   	return 0;
>   
>   dump:
> -	ubifs_err(c, "bad data node (block %u, inode %lu)",
> +	ubifs_err(c, "bad data node (block %u, inode %llu)",
>   		  block, inode->i_ino);
>   	ubifs_dump_node(c, dn, UBIFS_MAX_DATA_NODE_SZ);
>   	return -EINVAL;
> @@ -106,7 +106,7 @@ static int do_readpage(struct folio *folio)
>   	loff_t i_size = i_size_read(inode);
>   	size_t offset = 0;
>   
> -	dbg_gen("ino %lu, pg %lu, i_size %lld, flags %#lx",
> +	dbg_gen("ino %llu, pg %lu, i_size %lld, flags %#lx",
>   		inode->i_ino, folio->index, i_size, folio->flags.f);
>   	ubifs_assert(c, !folio_test_checked(folio));
>   	ubifs_assert(c, !folio->private);
> @@ -162,7 +162,7 @@ static int do_readpage(struct folio *folio)
>   			dbg_gen("hole");
>   			err = 0;
>   		} else {
> -			ubifs_err(c, "cannot read page %lu of inode %lu, error %d",
> +			ubifs_err(c, "cannot read page %lu of inode %llu, error %d",
>   				  folio->index, inode->i_ino, err);
>   		}
>   	}
> @@ -212,7 +212,7 @@ static int write_begin_slow(struct address_space *mapping,
>   	int err, appending = !!(pos + len > inode->i_size);
>   	struct folio *folio;
>   
> -	dbg_gen("ino %lu, pos %llu, len %u, i_size %lld",
> +	dbg_gen("ino %llu, pos %llu, len %u, i_size %lld",
>   		inode->i_ino, pos, len, inode->i_size);
>   
>   	/*
> @@ -526,7 +526,7 @@ static int ubifs_write_end(const struct kiocb *iocb,
>   	loff_t end_pos = pos + len;
>   	int appending = !!(end_pos > inode->i_size);
>   
> -	dbg_gen("ino %lu, pos %llu, pg %lu, len %u, copied %d, i_size %lld",
> +	dbg_gen("ino %llu, pos %llu, pg %lu, len %u, copied %d, i_size %lld",
>   		inode->i_ino, pos, folio->index, len, copied, inode->i_size);
>   
>   	if (unlikely(copied < len && !folio_test_uptodate(folio))) {
> @@ -599,7 +599,7 @@ static int populate_page(struct ubifs_info *c, struct folio *folio,
>   	size_t offset = 0;
>   	pgoff_t end_index;
>   
> -	dbg_gen("ino %lu, pg %lu, i_size %lld, flags %#lx",
> +	dbg_gen("ino %llu, pg %lu, i_size %lld, flags %#lx",
>   		inode->i_ino, folio->index, i_size, folio->flags.f);
>   
>   	end_index = (i_size - 1) >> PAGE_SHIFT;
> @@ -680,7 +680,7 @@ static int populate_page(struct ubifs_info *c, struct folio *folio,
>   	return 0;
>   
>   out_err:
> -	ubifs_err(c, "bad data node (block %u, inode %lu)",
> +	ubifs_err(c, "bad data node (block %u, inode %llu)",
>   		  page_block, inode->i_ino);
>   	return -EINVAL;
>   }
> @@ -913,7 +913,7 @@ static int do_writepage(struct folio *folio, size_t len)
>   	}
>   	if (err) {
>   		mapping_set_error(folio->mapping, err);
> -		ubifs_err(c, "cannot write folio %lu of inode %lu, error %d",
> +		ubifs_err(c, "cannot write folio %lu of inode %llu, error %d",
>   			  folio->index, inode->i_ino, err);
>   		ubifs_ro_mode(c, err);
>   	}
> @@ -987,7 +987,7 @@ static int ubifs_writepage(struct folio *folio, struct writeback_control *wbc)
>   	loff_t i_size =  i_size_read(inode), synced_i_size;
>   	int err, len = folio_size(folio);
>   
> -	dbg_gen("ino %lu, pg %lu, pg flags %#lx",
> +	dbg_gen("ino %llu, pg %lu, pg flags %#lx",
>   		inode->i_ino, folio->index, folio->flags.f);
>   	ubifs_assert(c, folio->private != NULL);
>   
> @@ -1106,7 +1106,7 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
>   	int offset = new_size & (UBIFS_BLOCK_SIZE - 1), budgeted = 1;
>   	struct ubifs_inode *ui = ubifs_inode(inode);
>   
> -	dbg_gen("ino %lu, size %lld -> %lld", inode->i_ino, old_size, new_size);
> +	dbg_gen("ino %llu, size %lld -> %lld", inode->i_ino, old_size, new_size);
>   	memset(&req, 0, sizeof(struct ubifs_budget_req));
>   
>   	/*
> @@ -1258,7 +1258,7 @@ int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>   	struct inode *inode = d_inode(dentry);
>   	struct ubifs_info *c = inode->i_sb->s_fs_info;
>   
> -	dbg_gen("ino %lu, mode %#x, ia_valid %#x",
> +	dbg_gen("ino %llu, mode %#x, ia_valid %#x",
>   		inode->i_ino, inode->i_mode, attr->ia_valid);
>   	err = setattr_prepare(&nop_mnt_idmap, dentry, attr);
>   	if (err)
> @@ -1308,7 +1308,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
>   	struct ubifs_info *c = inode->i_sb->s_fs_info;
>   	int err;
>   
> -	dbg_gen("syncing inode %lu", inode->i_ino);
> +	dbg_gen("syncing inode %llu", inode->i_ino);
>   
>   	if (c->ro_mount)
>   		/*
> @@ -1495,7 +1495,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
>   	struct ubifs_budget_req req = { .new_page = 1 };
>   	int err, update_time;
>   
> -	dbg_gen("ino %lu, pg %lu, i_size %lld",	inode->i_ino, folio->index,
> +	dbg_gen("ino %llu, pg %lu, i_size %lld",	inode->i_ino, folio->index,
>   		i_size_read(inode));
>   	ubifs_assert(c, !c->ro_media && !c->ro_mount);
>   
> @@ -1531,7 +1531,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
>   	err = ubifs_budget_space(c, &req);
>   	if (unlikely(err)) {
>   		if (err == -ENOSPC)
> -			ubifs_warn(c, "out of space for mmapped file (inode number %lu)",
> +			ubifs_warn(c, "out of space for mmapped file (inode number %llu)",
>   				   inode->i_ino);
>   		return VM_FAULT_SIGBUS;
>   	}
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index e28ab4395e5ca404d8e8d8f735c3113b58bcc941..40a95a2fad50039f39917e71da7b71a735237469 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -982,7 +982,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
>   	int kill_xattrs = ui->xattr_cnt && last_reference;
>   	u8 hash[UBIFS_HASH_ARR_SZ];
>   
> -	dbg_jnl("ino %lu, nlink %u", inode->i_ino, inode->i_nlink);
> +	dbg_jnl("ino %llu, nlink %u", inode->i_ino, inode->i_nlink);
>   
>   	if (kill_xattrs && ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
>   		ubifs_err(c, "Cannot delete inode, it has too many xattrs!");
> @@ -1743,7 +1743,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
>   			int dn_len = le32_to_cpu(dn->size);
>   
>   			if (dn_len <= 0 || dn_len > UBIFS_BLOCK_SIZE) {
> -				ubifs_err(c, "bad data node (block %u, inode %lu)",
> +				ubifs_err(c, "bad data node (block %u, inode %llu)",
>   					  blk, inode->i_ino);
>   				ubifs_dump_node(c, dn, dn_size);
>   				err = -EUCLEAN;
> @@ -1987,7 +1987,7 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
>   	u8 hash_host[UBIFS_HASH_ARR_SZ];
>   	u8 hash[UBIFS_HASH_ARR_SZ];
>   
> -	dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino);
> +	dbg_jnl("ino %llu, ino %llu", host->i_ino, inode->i_ino);
>   	ubifs_assert(c, inode->i_nlink > 0);
>   	ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex));
>   
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 03bf924756ca003809d229837a970d5935450f23..9a77d8b64ffa70f9d5b695fb3d87c22cb223704f 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -92,7 +92,7 @@ static int validate_inode(struct ubifs_info *c, const struct inode *inode)
>   		return 5;
>   
>   	if (!ubifs_compr_present(c, ui->compr_type)) {
> -		ubifs_warn(c, "inode %lu uses '%s' compression, but it was not compiled in",
> +		ubifs_warn(c, "inode %llu uses '%s' compression, but it was not compiled in",
>   			   inode->i_ino, ubifs_compr_name(c, ui->compr_type));
>   	}
>   
> @@ -248,14 +248,14 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
>   	return inode;
>   
>   out_invalid:
> -	ubifs_err(c, "inode %lu validation failed, error %d", inode->i_ino, err);
> +	ubifs_err(c, "inode %llu validation failed, error %d", inode->i_ino, err);
>   	ubifs_dump_node(c, ino, UBIFS_MAX_INO_NODE_SZ);
>   	ubifs_dump_inode(c, inode);
>   	err = -EINVAL;
>   out_ino:
>   	kfree(ino);
>   out:
> -	ubifs_err(c, "failed to read inode %lu, error %d", inode->i_ino, err);
> +	ubifs_err(c, "failed to read inode %llu, error %d", inode->i_ino, err);
>   	iget_failed(inode);
>   	return ERR_PTR(err);
>   }
> @@ -316,12 +316,12 @@ static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc)
>   	 * As an optimization, do not write orphan inodes to the media just
>   	 * because this is not needed.
>   	 */
> -	dbg_gen("inode %lu, mode %#x, nlink %u",
> +	dbg_gen("inode %llu, mode %#x, nlink %u",
>   		inode->i_ino, (int)inode->i_mode, inode->i_nlink);
>   	if (inode->i_nlink) {
>   		err = ubifs_jnl_write_inode(c, inode);
>   		if (err)
> -			ubifs_err(c, "can't write inode %lu, error %d",
> +			ubifs_err(c, "can't write inode %llu, error %d",
>   				  inode->i_ino, err);
>   		else
>   			err = dbg_check_inode_size(c, inode, ui->ui_size);
> @@ -357,7 +357,7 @@ static void ubifs_evict_inode(struct inode *inode)
>   		 */
>   		goto out;
>   
> -	dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode);
> +	dbg_gen("inode %llu, mode %#x", inode->i_ino, (int)inode->i_mode);
>   	ubifs_assert(c, !icount_read(inode));
>   
>   	truncate_inode_pages_final(&inode->i_data);
> @@ -375,7 +375,7 @@ static void ubifs_evict_inode(struct inode *inode)
>   		 * Worst case we have a lost orphan inode wasting space, so a
>   		 * simple error message is OK here.
>   		 */
> -		ubifs_err(c, "can't delete inode %lu, error %d",
> +		ubifs_err(c, "can't delete inode %llu, error %d",
>   			  inode->i_ino, err);
>   
>   out:
> @@ -399,7 +399,7 @@ static void ubifs_dirty_inode(struct inode *inode, int flags)
>   	ubifs_assert(c, mutex_is_locked(&ui->ui_mutex));
>   	if (!ui->dirty) {
>   		ui->dirty = 1;
> -		dbg_gen("inode %lu",  inode->i_ino);
> +		dbg_gen("inode %llu",  inode->i_ino);
>   	}
>   }
>   
> diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
> index 694b08d27d7d9c7d9d7d9039f406637c702f8613..52c758c5290d8cc425fdc6d49c608d0cb0ba7ff7 100644
> --- a/fs/ubifs/tnc.c
> +++ b/fs/ubifs/tnc.c
> @@ -3561,8 +3561,8 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
>   
>   out_dump:
>   	block = key_block(c, key);
> -	ubifs_err(c, "inode %lu has size %lld, but there are data at offset %lld",
> -		  (unsigned long)inode->i_ino, size,
> +	ubifs_err(c, "inode %llu has size %lld, but there are data at offset %lld",
> +		  (unsigned long long)inode->i_ino, size,
>   		  ((loff_t)block) << UBIFS_BLOCK_SHIFT);
>   	mutex_unlock(&c->tnc_mutex);
>   	ubifs_dump_inode(c, inode);
> diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> index c21a0c2b3e907c1572780d4a3e48cc9d2a11b9d6..b5a9ab9d8a10adcf49e6d7228d385cb986e6e75e 100644
> --- a/fs/ubifs/xattr.c
> +++ b/fs/ubifs/xattr.c
> @@ -76,7 +76,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
>   				.dirtied_ino_d = ALIGN(host_ui->data_len, 8) };
>   
>   	if (host_ui->xattr_cnt >= ubifs_xattr_max_cnt(c)) {
> -		ubifs_err(c, "inode %lu already has too many xattrs (%d), cannot create more",
> +		ubifs_err(c, "inode %llu already has too many xattrs (%d), cannot create more",
>   			  host->i_ino, host_ui->xattr_cnt);
>   		return -ENOSPC;
>   	}
> @@ -88,7 +88,7 @@ static int create_xattr(struct ubifs_info *c, struct inode *host,
>   	 */
>   	names_len = host_ui->xattr_names + host_ui->xattr_cnt + fname_len(nm) + 1;
>   	if (names_len > XATTR_LIST_MAX) {
> -		ubifs_err(c, "cannot add one more xattr name to inode %lu, total names length would become %d, max. is %d",
> +		ubifs_err(c, "cannot add one more xattr name to inode %llu, total names length would become %d, max. is %d",
>   			  host->i_ino, names_len, XATTR_LIST_MAX);
>   		return -ENOSPC;
>   	}
> @@ -390,7 +390,7 @@ ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size)
>   	int err, len, written = 0;
>   	struct fscrypt_name nm = {0};
>   
> -	dbg_gen("ino %lu ('%pd'), buffer size %zd", host->i_ino,
> +	dbg_gen("ino %llu ('%pd'), buffer size %zd", host->i_ino,
>   		dentry, size);
>   
>   	down_read(&host_ui->xattr_sem);
> @@ -498,7 +498,7 @@ int ubifs_purge_xattrs(struct inode *host)
>   	if (ubifs_inode(host)->xattr_cnt <= ubifs_xattr_max_cnt(c))
>   		return 0;
>   
> -	ubifs_warn(c, "inode %lu has too many xattrs, doing a non-atomic deletion",
> +	ubifs_warn(c, "inode %llu has too many xattrs, doing a non-atomic deletion",
>   		   host->i_ino);
>   
>   	down_write(&ubifs_inode(host)->xattr_sem);
> @@ -641,7 +641,7 @@ int ubifs_init_security(struct inode *dentry, struct inode *inode,
>   					   &init_xattrs, NULL);
>   	if (err) {
>   		struct ubifs_info *c = dentry->i_sb->s_fs_info;
> -		ubifs_err(c, "cannot initialize security for inode %lu, error %d",
> +		ubifs_err(c, "cannot initialize security for inode %llu, error %d",
>   			  inode->i_ino, err);
>   	}
>   	return err;
> @@ -652,7 +652,7 @@ static int xattr_get(const struct xattr_handler *handler,
>   			   struct dentry *dentry, struct inode *inode,
>   			   const char *name, void *buffer, size_t size)
>   {
> -	dbg_gen("xattr '%s', ino %lu ('%pd'), buf size %zd", name,
> +	dbg_gen("xattr '%s', ino %llu ('%pd'), buf size %zd", name,
>   		inode->i_ino, dentry, size);
>   
>   	name = xattr_full_name(handler, name);
> @@ -665,7 +665,7 @@ static int xattr_set(const struct xattr_handler *handler,
>   			   const char *name, const void *value,
>   			   size_t size, int flags)
>   {
> -	dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd",
> +	dbg_gen("xattr '%s', host ino %llu ('%pd'), size %zd",
>   		name, inode->i_ino, dentry, size);
>   
>   	name = xattr_full_name(handler, name);
> 


^ permalink raw reply

* [PATCH v6 0/3] ring-buffer: Making persistent ring buffers robust
From: Masami Hiramatsu (Google) @ 2026-02-27  9:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel

Hi,

Here is the 6th version of improvement patches for making persistent
ring buffers robust to failures.
The previous version is here:

https://lore.kernel.org/all/177211310553.419230.7846100548994399256.stgit@mhiramat.tok.corp.google.com/

In this version, I introduced asm/ring_buffer.h file for wrapping
flush ring buffer function and use dcache_clean_pop() for arm64[1/3]
also, showing invalid page detection (first time for each cpu)
message when validating the persistent ring buffer[3/3]. 

Thank you,

---

Masami Hiramatsu (Google) (3):
      ring-buffer: Flush and stop persistent ring buffer on panic
      ring-buffer: Handle RB_MISSED_* flags on commit field correctly
      ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer


 arch/alpha/include/asm/Kbuild        |    1 
 arch/arc/include/asm/Kbuild          |    1 
 arch/arm/include/asm/Kbuild          |    1 
 arch/arm64/include/asm/ring_buffer.h |   10 ++++
 arch/csky/include/asm/Kbuild         |    1 
 arch/hexagon/include/asm/Kbuild      |    1 
 arch/loongarch/include/asm/Kbuild    |    1 
 arch/m68k/include/asm/Kbuild         |    1 
 arch/microblaze/include/asm/Kbuild   |    1 
 arch/mips/include/asm/Kbuild         |    1 
 arch/nios2/include/asm/Kbuild        |    1 
 arch/openrisc/include/asm/Kbuild     |    1 
 arch/parisc/include/asm/Kbuild       |    1 
 arch/powerpc/include/asm/Kbuild      |    1 
 arch/riscv/include/asm/Kbuild        |    1 
 arch/s390/include/asm/Kbuild         |    1 
 arch/sh/include/asm/Kbuild           |    1 
 arch/sparc/include/asm/Kbuild        |    1 
 arch/um/include/asm/Kbuild           |    1 
 arch/x86/include/asm/Kbuild          |    1 
 arch/xtensa/include/asm/Kbuild       |    1 
 include/asm-generic/ring_buffer.h    |   13 ++++++
 kernel/trace/ring_buffer.c           |   78 ++++++++++++++++++++++++----------
 23 files changed, 97 insertions(+), 24 deletions(-)
 create mode 100644 arch/arm64/include/asm/ring_buffer.h
 create mode 100644 include/asm-generic/ring_buffer.h

--
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply

* [PATCH v6 1/3] ring-buffer: Flush and stop persistent ring buffer on panic
From: Masami Hiramatsu (Google) @ 2026-02-27  9:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel
In-Reply-To: <177218401821.1988514.5579163042147205021.stgit@mhiramat.tok.corp.google.com>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

On real hardware, panic and machine reboot may not flush hardware cache
to memory. This means the persistent ring buffer, which relies on a
coherent state of memory, may not have its events written to the buffer
and they may be lost. Moreover, there may be inconsistency with the
counters which are used for validation of the integrity of the
persistent ring buffer which may cause all data to be discarded.

To avoid this issue, stop recording of the ring buffer on panic and
flush the cache of the ring buffer's memory.

Fixes: e645535a954a ("tracing: Add option to use memmapped memory for trace boot instance")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 Changes in v6:
   - Introduce asm/ring_buffer.h for arch_ring_buffer_flush_range().
   - Use flush_cache_vmap() instead of flush_cache_all().
 Changes in v5:
   - Use ring_buffer_record_off() instead of ring_buffer_record_disable().
   - Use flush_cache_all() to ensure flush all cache.
 Changes in v3:
   - update patch description.
---
 arch/alpha/include/asm/Kbuild        |    1 +
 arch/arc/include/asm/Kbuild          |    1 +
 arch/arm/include/asm/Kbuild          |    1 +
 arch/arm64/include/asm/ring_buffer.h |   10 ++++++++++
 arch/csky/include/asm/Kbuild         |    1 +
 arch/hexagon/include/asm/Kbuild      |    1 +
 arch/loongarch/include/asm/Kbuild    |    1 +
 arch/m68k/include/asm/Kbuild         |    1 +
 arch/microblaze/include/asm/Kbuild   |    1 +
 arch/mips/include/asm/Kbuild         |    1 +
 arch/nios2/include/asm/Kbuild        |    1 +
 arch/openrisc/include/asm/Kbuild     |    1 +
 arch/parisc/include/asm/Kbuild       |    1 +
 arch/powerpc/include/asm/Kbuild      |    1 +
 arch/riscv/include/asm/Kbuild        |    1 +
 arch/s390/include/asm/Kbuild         |    1 +
 arch/sh/include/asm/Kbuild           |    1 +
 arch/sparc/include/asm/Kbuild        |    1 +
 arch/um/include/asm/Kbuild           |    1 +
 arch/x86/include/asm/Kbuild          |    1 +
 arch/xtensa/include/asm/Kbuild       |    1 +
 include/asm-generic/ring_buffer.h    |   13 +++++++++++++
 kernel/trace/ring_buffer.c           |   22 ++++++++++++++++++++++
 23 files changed, 65 insertions(+)
 create mode 100644 arch/arm64/include/asm/ring_buffer.h
 create mode 100644 include/asm-generic/ring_buffer.h

diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index 483965c5a4de..b154b4e3dfa8 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -5,4 +5,5 @@ generic-y += agp.h
 generic-y += asm-offsets.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += text-patching.h
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild
index 4c69522e0328..483caacc6988 100644
--- a/arch/arc/include/asm/Kbuild
+++ b/arch/arc/include/asm/Kbuild
@@ -5,5 +5,6 @@ generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += parport.h
+generic-y += ring_buffer.h
 generic-y += user.h
 generic-y += text-patching.h
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index 03657ff8fbe3..decad5f2c826 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -3,6 +3,7 @@ generic-y += early_ioremap.h
 generic-y += extable.h
 generic-y += flat.h
 generic-y += parport.h
+generic-y += ring_buffer.h
 
 generated-y += mach-types.h
 generated-y += unistd-nr.h
diff --git a/arch/arm64/include/asm/ring_buffer.h b/arch/arm64/include/asm/ring_buffer.h
new file mode 100644
index 000000000000..62316c406888
--- /dev/null
+++ b/arch/arm64/include/asm/ring_buffer.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _ASM_ARM64_RING_BUFFER_H
+#define _ASM_ARM64_RING_BUFFER_H
+
+#include <asm/cacheflush.h>
+
+/* Flush D-cache on persistent ring buffer */
+#define arch_ring_buffer_flush_range(start, end)	dcache_clean_pop(start, end)
+
+#endif /* _ASM_ARM64_RING_BUFFER_H */
diff --git a/arch/csky/include/asm/Kbuild b/arch/csky/include/asm/Kbuild
index 3a5c7f6e5aac..7dca0c6cdc84 100644
--- a/arch/csky/include/asm/Kbuild
+++ b/arch/csky/include/asm/Kbuild
@@ -9,6 +9,7 @@ generic-y += qrwlock.h
 generic-y += qrwlock_types.h
 generic-y += qspinlock.h
 generic-y += parport.h
+generic-y += ring_buffer.h
 generic-y += user.h
 generic-y += vmlinux.lds.h
 generic-y += text-patching.h
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 1efa1e993d4b..0f887d4238ed 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -5,4 +5,5 @@ generic-y += extable.h
 generic-y += iomap.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += text-patching.h
diff --git a/arch/loongarch/include/asm/Kbuild b/arch/loongarch/include/asm/Kbuild
index 9034b583a88a..7e92957baf6a 100644
--- a/arch/loongarch/include/asm/Kbuild
+++ b/arch/loongarch/include/asm/Kbuild
@@ -10,5 +10,6 @@ generic-y += qrwlock.h
 generic-y += user.h
 generic-y += ioctl.h
 generic-y += mmzone.h
+generic-y += ring_buffer.h
 generic-y += statfs.h
 generic-y += text-patching.h
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index b282e0dd8dc1..62543bf305ff 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -3,5 +3,6 @@ generated-y += syscall_table.h
 generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += spinlock.h
 generic-y += text-patching.h
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index 7178f990e8b3..0030309b47ad 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -5,6 +5,7 @@ generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += parport.h
+generic-y += ring_buffer.h
 generic-y += syscalls.h
 generic-y += tlb.h
 generic-y += user.h
diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild
index 684569b2ecd6..9771c3d85074 100644
--- a/arch/mips/include/asm/Kbuild
+++ b/arch/mips/include/asm/Kbuild
@@ -12,5 +12,6 @@ generic-y += mcs_spinlock.h
 generic-y += parport.h
 generic-y += qrwlock.h
 generic-y += qspinlock.h
+generic-y += ring_buffer.h
 generic-y += user.h
 generic-y += text-patching.h
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild
index 28004301c236..0a2530964413 100644
--- a/arch/nios2/include/asm/Kbuild
+++ b/arch/nios2/include/asm/Kbuild
@@ -5,6 +5,7 @@ generic-y += cmpxchg.h
 generic-y += extable.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += spinlock.h
 generic-y += user.h
 generic-y += text-patching.h
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index cef49d60d74c..8aa34621702d 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -8,4 +8,5 @@ generic-y += spinlock_types.h
 generic-y += spinlock.h
 generic-y += qrwlock_types.h
 generic-y += qrwlock.h
+generic-y += ring_buffer.h
 generic-y += user.h
diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild
index 4fb596d94c89..d48d158f7241 100644
--- a/arch/parisc/include/asm/Kbuild
+++ b/arch/parisc/include/asm/Kbuild
@@ -4,4 +4,5 @@ generated-y += syscall_table_64.h
 generic-y += agp.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += user.h
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
index 2e23533b67e3..805b5aeebb6f 100644
--- a/arch/powerpc/include/asm/Kbuild
+++ b/arch/powerpc/include/asm/Kbuild
@@ -5,4 +5,5 @@ generated-y += syscall_table_spu.h
 generic-y += agp.h
 generic-y += mcs_spinlock.h
 generic-y += qrwlock.h
+generic-y += ring_buffer.h
 generic-y += early_ioremap.h
diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild
index bd5fc9403295..7721b63642f4 100644
--- a/arch/riscv/include/asm/Kbuild
+++ b/arch/riscv/include/asm/Kbuild
@@ -14,5 +14,6 @@ generic-y += ticket_spinlock.h
 generic-y += qrwlock.h
 generic-y += qrwlock_types.h
 generic-y += qspinlock.h
+generic-y += ring_buffer.h
 generic-y += user.h
 generic-y += vmlinux.lds.h
diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild
index 80bad7de7a04..0c1fc47c3ba0 100644
--- a/arch/s390/include/asm/Kbuild
+++ b/arch/s390/include/asm/Kbuild
@@ -7,3 +7,4 @@ generated-y += unistd_nr.h
 generic-y += asm-offsets.h
 generic-y += mcs_spinlock.h
 generic-y += mmzone.h
+generic-y += ring_buffer.h
diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild
index 4d3f10ed8275..f0403d3ee8ab 100644
--- a/arch/sh/include/asm/Kbuild
+++ b/arch/sh/include/asm/Kbuild
@@ -3,4 +3,5 @@ generated-y += syscall_table.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += parport.h
+generic-y += ring_buffer.h
 generic-y += text-patching.h
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index 17ee8a273aa6..49c6bb326b75 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -4,4 +4,5 @@ generated-y += syscall_table_64.h
 generic-y += agp.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
+generic-y += ring_buffer.h
 generic-y += text-patching.h
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index 1b9b82bbe322..2a1629ba8140 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -17,6 +17,7 @@ generic-y += module.lds.h
 generic-y += parport.h
 generic-y += percpu.h
 generic-y += preempt.h
+generic-y += ring_buffer.h
 generic-y += runtime-const.h
 generic-y += softirq_stack.h
 generic-y += switch_to.h
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 4566000e15c4..078fd2c0d69d 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -14,3 +14,4 @@ generic-y += early_ioremap.h
 generic-y += fprobe.h
 generic-y += mcs_spinlock.h
 generic-y += mmzone.h
+generic-y += ring_buffer.h
diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild
index 13fe45dea296..e57af619263a 100644
--- a/arch/xtensa/include/asm/Kbuild
+++ b/arch/xtensa/include/asm/Kbuild
@@ -6,5 +6,6 @@ generic-y += mcs_spinlock.h
 generic-y += parport.h
 generic-y += qrwlock.h
 generic-y += qspinlock.h
+generic-y += ring_buffer.h
 generic-y += user.h
 generic-y += text-patching.h
diff --git a/include/asm-generic/ring_buffer.h b/include/asm-generic/ring_buffer.h
new file mode 100644
index 000000000000..dbe94f5785f9
--- /dev/null
+++ b/include/asm-generic/ring_buffer.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Generiuc arch dependent ring_buffer macros.
+ */
+#ifndef __ASM_GENERIC_RING_BUFFER_H__
+#define __ASM_GENERIC_RING_BUFFER_H__
+
+#include <linux/cacheflush.h>
+
+/* Flush cache on ring buffer range if needed */
+#define arch_ring_buffer_flush_range(start, end)	flush_cache_vmap(start, end)
+
+#endif /* __ASM_GENERIC_RING_BUFFER_H__ */
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index f16f053ef77d..156ed19fb569 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -6,6 +6,7 @@
  */
 #include <linux/sched/isolation.h>
 #include <linux/trace_recursion.h>
+#include <linux/panic_notifier.h>
 #include <linux/trace_events.h>
 #include <linux/ring_buffer.h>
 #include <linux/trace_clock.h>
@@ -30,6 +31,7 @@
 #include <linux/oom.h>
 #include <linux/mm.h>
 
+#include <asm/ring_buffer.h>
 #include <asm/local64.h>
 #include <asm/local.h>
 #include <asm/setup.h>
@@ -589,6 +591,7 @@ struct trace_buffer {
 
 	unsigned long			range_addr_start;
 	unsigned long			range_addr_end;
+	struct notifier_block		flush_nb;
 
 	struct ring_buffer_meta		*meta;
 
@@ -2471,6 +2474,16 @@ static void rb_free_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)
 	kfree(cpu_buffer);
 }
 
+/* Stop recording on a persistent buffer and flush cache if needed. */
+static int rb_flush_buffer_cb(struct notifier_block *nb, unsigned long event, void *data)
+{
+	struct trace_buffer *buffer = container_of(nb, struct trace_buffer, flush_nb);
+
+	ring_buffer_record_off(buffer);
+	arch_ring_buffer_flush_range(buffer->range_addr_start, buffer->range_addr_end);
+	return NOTIFY_DONE;
+}
+
 static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
 					 int order, unsigned long start,
 					 unsigned long end,
@@ -2590,6 +2603,12 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
 
 	mutex_init(&buffer->mutex);
 
+	/* Persistent ring buffer needs to flush cache before reboot. */
+	if (start & end) {
+		buffer->flush_nb.notifier_call = rb_flush_buffer_cb;
+		atomic_notifier_chain_register(&panic_notifier_list, &buffer->flush_nb);
+	}
+
 	return_ptr(buffer);
 
  fail_free_buffers:
@@ -2677,6 +2696,9 @@ ring_buffer_free(struct trace_buffer *buffer)
 {
 	int cpu;
 
+	if (buffer->range_addr_start && buffer->range_addr_end)
+		atomic_notifier_chain_unregister(&panic_notifier_list, &buffer->flush_nb);
+
 	cpuhp_state_remove_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node);
 
 	irq_work_sync(&buffer->irq_work.work);


^ permalink raw reply related

* [PATCH v6 2/3] ring-buffer: Handle RB_MISSED_* flags on commit field correctly
From: Masami Hiramatsu (Google) @ 2026-02-27  9:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel
In-Reply-To: <177218401821.1988514.5579163042147205021.stgit@mhiramat.tok.corp.google.com>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Since the MSBs of rb_data_page::commit are used for storing
RB_MISSED_EVENTS and RB_MISSED_STORED, we need to mask out those bits
when it is used for finding the size of data pages.

Fixes: 5f3b6e839f3c ("ring-buffer: Validate boot range memory events")
Fixes: 5b7be9c709e1 ("ring-buffer: Add test to validate the time stamp deltas")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 Changes in v5:
   - Do not move rb_commit_index().
   - Fix verify_event() and rb_cpu_meta_valid() too.
 Changes in v4:
   - Fix to move rb_commit_index() after ring_buffer_per_cpu definition.
---
 kernel/trace/ring_buffer.c |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 156ed19fb569..87d6958e9656 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -396,6 +396,12 @@ static __always_inline unsigned int rb_page_commit(struct buffer_page *bpage)
 	return local_read(&bpage->page->commit);
 }
 
+/* Size is determined by what has been committed */
+static __always_inline unsigned int rb_page_size(struct buffer_page *bpage)
+{
+	return rb_page_commit(bpage) & ~RB_MISSED_MASK;
+}
+
 static void free_buffer_page(struct buffer_page *bpage)
 {
 	/* Range pages are not to be freed */
@@ -677,7 +683,7 @@ static void verify_event(struct ring_buffer_per_cpu *cpu_buffer,
 	do {
 		if (page == tail_page || WARN_ON_ONCE(stop++ > 100))
 			done = true;
-		commit = local_read(&page->page->commit);
+		commit = rb_page_size(page);
 		write = local_read(&page->write);
 		if (addr >= (unsigned long)&page->page->data[commit] &&
 		    addr < (unsigned long)&page->page->data[write])
@@ -1821,13 +1827,16 @@ static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
 
 	/* Is the meta buffers and the subbufs themselves have correct data? */
 	for (i = 0; i < meta->nr_subbufs; i++) {
+		unsigned long commit;
+
 		if (meta->buffers[i] < 0 ||
 		    meta->buffers[i] >= meta->nr_subbufs) {
 			pr_info("Ring buffer boot meta [%d] array out of range\n", cpu);
 			return false;
 		}
 
-		if ((unsigned)local_read(&subbuf->commit) > subbuf_size) {
+		commit = local_read(&subbuf->commit) & ~RB_MISSED_MASK;
+		if (commit > subbuf_size) {
 			pr_info("Ring buffer boot meta [%d] buffer invalid commit\n", cpu);
 			return false;
 		}
@@ -1908,7 +1917,7 @@ static int rb_validate_buffer(struct buffer_data_page *dpage, int cpu)
 	u64 delta;
 	int tail;
 
-	tail = local_read(&dpage->commit);
+	tail = local_read(&dpage->commit) & ~RB_MISSED_MASK;
 	return rb_read_data_buffer(dpage, tail, cpu, &ts, &delta);
 }
 
@@ -1935,7 +1944,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
 		goto invalid;
 	}
 	entries += ret;
-	entry_bytes += local_read(&cpu_buffer->reader_page->page->commit);
+	entry_bytes += rb_page_size(cpu_buffer->reader_page);
 	local_set(&cpu_buffer->reader_page->entries, ret);
 
 	ts = head_page->page->time_stamp;
@@ -2055,7 +2064,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
 			local_inc(&cpu_buffer->pages_touched);
 
 		entries += ret;
-		entry_bytes += local_read(&head_page->page->commit);
+		entry_bytes += rb_page_size(head_page);
 		local_set(&cpu_buffer->head_page->entries, ret);
 
 		if (head_page == cpu_buffer->commit_page)
@@ -3258,12 +3267,6 @@ rb_iter_head_event(struct ring_buffer_iter *iter)
 	return NULL;
 }
 
-/* Size is determined by what has been committed */
-static __always_inline unsigned rb_page_size(struct buffer_page *bpage)
-{
-	return rb_page_commit(bpage) & ~RB_MISSED_MASK;
-}
-
 static __always_inline unsigned
 rb_commit_index(struct ring_buffer_per_cpu *cpu_buffer)
 {
@@ -4434,7 +4437,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,
 
 	if (tail == CHECK_FULL_PAGE) {
 		full = true;
-		tail = local_read(&bpage->commit);
+		tail = local_read(&bpage->commit) & ~RB_MISSED_MASK;
 	} else if (info->add_timestamp &
 		   (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE)) {
 		/* Ignore events with absolute time stamps */


^ permalink raw reply related

* [PATCH v6 3/3] ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer
From: Masami Hiramatsu (Google) @ 2026-02-27  9:20 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel
In-Reply-To: <177218401821.1988514.5579163042147205021.stgit@mhiramat.tok.corp.google.com>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Skip invalid sub-buffers when validating the persistent ring buffer
instead of discarding the entire ring buffer. Also, mark there are
missed events on the discarded buffer.

If the cache data in memory fails to be synchronized during a reboot,
the persistent ring buffer may become partially corrupted, but other
sub-buffers may still contain readable event data. Only discard the
subbuffersa that ar found to be corrupted.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
  Changes in v6:
  - Show invalid page detection message once per CPU.
  Changes in v5:
  - Instead of showing errors for each page, just show the number
    of discarded pages at last.
  Changes in v3:
  - Record missed data event on commit.
---
 kernel/trace/ring_buffer.c |   31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 87d6958e9656..5838ee897aa3 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1928,6 +1928,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
 	struct buffer_page *head_page, *orig_head;
 	unsigned long entry_bytes = 0;
 	unsigned long entries = 0;
+	int discarded = 0;
 	int ret;
 	u64 ts;
 	int i;
@@ -2054,19 +2055,22 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
 
 		ret = rb_validate_buffer(head_page->page, cpu_buffer->cpu);
 		if (ret < 0) {
-			pr_info("Ring buffer meta [%d] invalid buffer page\n",
-				cpu_buffer->cpu);
-			goto invalid;
-		}
-
-		/* If the buffer has content, update pages_touched */
-		if (ret)
-			local_inc(&cpu_buffer->pages_touched);
-
-		entries += ret;
-		entry_bytes += rb_page_size(head_page);
-		local_set(&cpu_buffer->head_page->entries, ret);
+			if (!discarded)
+				pr_info("Ring buffer meta [%d] invalid buffer page detected\n",
+					cpu_buffer->cpu);
+			discarded++;
+			/* Instead of discard whole ring buffer, discard only this sub-buffer. */
+			local_set(&head_page->entries, 0);
+			local_set(&head_page->page->commit, RB_MISSED_EVENTS);
+		} else {
+			/* If the buffer has content, update pages_touched */
+			if (ret)
+				local_inc(&cpu_buffer->pages_touched);
 
+			entries += ret;
+			entry_bytes += rb_page_size(head_page);
+			local_set(&cpu_buffer->head_page->entries, ret);
+		}
 		if (head_page == cpu_buffer->commit_page)
 			break;
 	}
@@ -2080,7 +2084,8 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
 	local_set(&cpu_buffer->entries, entries);
 	local_set(&cpu_buffer->entries_bytes, entry_bytes);
 
-	pr_info("Ring buffer meta [%d] is from previous boot!\n", cpu_buffer->cpu);
+	pr_info("Ring buffer meta [%d] is from previous boot! (%d pages discarded)\n",
+		cpu_buffer->cpu, discarded);
 	return;
 
  invalid:


^ permalink raw reply related

* Re: [PATCH 00/61] vfs: change inode->i_ino from unsigned long to u64
From: Christian König @ 2026-02-27  9:30 UTC (permalink / raw)
  To: Jeff Layton, Alexander Viro, Christian Brauner, Jan Kara,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Dan Williams,
	Matthew Wilcox, Eric Biggers, Theodore Y. Ts'o, Muchun Song,
	Oscar Salvador, David Hildenbrand, David Howells, Paulo Alcantara,
	Andreas Dilger, Jan Kara, Jaegeuk Kim, Chao Yu, Trond Myklebust,
	Anna Schumaker, Chuck Lever, NeilBrown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, Steve French, Ronnie Sahlberg,
	Shyam Prasad N, Bharath SM, Alexander Aring, Ryusuke Konishi,
	Viacheslav Dubeyko, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck, David Sterba,
	Marc Dionne, Ian Kent, Luis de Bethencourt, Salah Triki,
	Tigran A. Aivazian, Ilya Dryomov, Alex Markuze, Jan Harkes, coda,
	Nicolas Pitre, Tyler Hicks, Amir Goldstein, Christoph Hellwig,
	John Paul Adrian Glaubitz, Yangtao Li, Mikulas Patocka,
	David Woodhouse, Richard Weinberger, Dave Kleikamp,
	Konstantin Komarov, Mark Fasheh, Joel Becker, Joseph Qi,
	Mike Marshall, Martin Brandenburg, Miklos Szeredi, Anders Larsen,
	Zhihao Cheng, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	John Johansen, Paul Moore, James Morris, Serge E. Hallyn,
	Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
	Stephen Smalley, Ondrej Mosnacek, Casey Schaufler, Alex Deucher,
	David Airlie, Simona Vetter, Sumit Semwal, Eric Dumazet,
	Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn, David S. Miller,
	Jakub Kicinski, Simon Horman, Oleg Nesterov, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Darrick J. Wong, Martin Schiller
  Cc: linux-fsdevel, linux-kernel, linux-trace-kernel, nvdimm, fsverity,
	linux-mm, netfs, linux-ext4, linux-f2fs-devel, linux-nfs,
	linux-cifs, samba-technical, linux-nilfs, v9fs, linux-afs, autofs,
	ceph-devel, codalist, ecryptfs, linux-mtd, jfs-discussion, ntfs3,
	ocfs2-devel, devel, linux-unionfs, apparmor,
	linux-security-module, linux-integrity, selinux, amd-gfx,
	dri-devel, linux-media, linaro-mm-sig, netdev, linux-perf-users,
	linux-fscrypt, linux-xfs, linux-hams, linux-x25
In-Reply-To: <20260226-iino-u64-v1-0-ccceff366db9@kernel.org>

On 2/26/26 16:55, Jeff Layton wrote:
> Christian said [1] to "just do it" when I proposed this, so here we are!
> 
> For historical reasons, the inode->i_ino field is an unsigned long,
> which means that it's 32 bits on 32 bit architectures. This has caused a
> number of filesystems to implement hacks to hash a 64-bit identifier
> into a 32-bit field, and deprives us of a universal identifier field for
> an inode.
> 
> This patchset changes the inode->i_ino field from an unsigned long to a
> u64. This shouldn't make any material difference on 64-bit hosts, but
> 32-bit hosts will see struct inode grow by at least 4 bytes. This could
> have effects on slabcache sizes and field alignment.
> 
> The bulk of the changes are to format strings and tracepoints, since the
> kernel itself doesn't care that much about the i_ino field. The first
> patch changes some vfs function arguments, so check that one out
> carefully.
> 
> With this change, we may be able to shrink some inode structures. For
> instance, struct nfs_inode has a fileid field that holds the 64-bit
> inode number. With this set of changes, that field could be eliminated.
> I'd rather leave that sort of cleanups for later just to keep this
> simple.
> 
> Much of this set was generated by LLM, but I attributed it to myself
> since I consider this to be in the "menial tasks" category of LLM usage.

Sounds reasonable to me, should get_next_ino() also be changed to return an 64bit ino?

Currently it is always only 32bit and we have workarounds for that in DMA-buf for example.

Thanks,
Christian.

> 
> [1]: https://lore.kernel.org/linux-fsdevel/20260219-portrait-winkt-959070cee42f@brauner/
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> Jeff Layton (61):
>       vfs: widen inode hash/lookup functions to u64
>       vfs: change i_ino from unsigned long to u64
>       trace: update VFS-layer trace events for u64 i_ino
>       ext4: update for u64 i_ino
>       jbd2: update format strings for u64 i_ino
>       f2fs: update for u64 i_ino
>       lockd: update format strings for u64 i_ino
>       nfs: update for u64 i_ino
>       nfs: remove nfs_fattr_to_ino_t() and nfs_fileid_to_ino_t()
>       nfs: remove nfs_compat_user_ino64()
>       nfs: remove enable_ino64 module parameter
>       nfsd: update format strings for u64 i_ino
>       smb: store full 64-bit uniqueid in i_ino
>       smb: remove cifs_uniqueid_to_ino_t()
>       locks: update /proc/locks format for u64 i_ino
>       proc: update /proc/PID/maps for u64 i_ino
>       nilfs2: update for u64 i_ino
>       9p: update format strings for u64 i_ino
>       affs: update format strings for u64 i_ino
>       afs: update format strings for u64 i_ino
>       autofs: update format strings for u64 i_ino
>       befs: update format strings for u64 i_ino
>       bfs: update format strings for u64 i_ino
>       cachefiles: update format strings for u64 i_ino
>       ceph: update format strings for u64 i_ino
>       coda: update format strings for u64 i_ino
>       cramfs: update format strings for u64 i_ino
>       ecryptfs: update format strings for u64 i_ino
>       efs: update format strings for u64 i_ino
>       exportfs: update format strings for u64 i_ino
>       ext2: update format strings for u64 i_ino
>       freevxfs: update format strings for u64 i_ino
>       hfs: update format strings for u64 i_ino
>       hfsplus: update format strings for u64 i_ino
>       hpfs: update format strings for u64 i_ino
>       isofs: update format strings for u64 i_ino
>       jffs2: update format strings for u64 i_ino
>       jfs: update format strings for u64 i_ino
>       minix: update format strings for u64 i_ino
>       nsfs: update format strings for u64 i_ino
>       ntfs3: update format strings for u64 i_ino
>       ocfs2: update format strings for u64 i_ino
>       orangefs: update format strings for u64 i_ino
>       overlayfs: update format strings for u64 i_ino
>       qnx4: update format strings for u64 i_ino
>       qnx6: update format strings for u64 i_ino
>       ubifs: update format strings for u64 i_ino
>       udf: update format strings for u64 i_ino
>       ufs: update format strings for u64 i_ino
>       zonefs: update format strings for u64 i_ino
>       security: update audit format strings for u64 i_ino
>       drm/amdgpu: update for u64 i_ino
>       fsnotify: update fdinfo format strings for u64 i_ino
>       net: update socket dname format for u64 i_ino
>       uprobes: update format strings for u64 i_ino
>       dma-buf: update format string for u64 i_ino
>       fscrypt: update format strings for u64 i_ino
>       fsverity: update format string for u64 i_ino
>       iomap: update format string for u64 i_ino
>       net: update legacy protocol format strings for u64 i_ino
>       vfs: update core format strings for u64 i_ino
> 
>  drivers/dma-buf/dma-buf.c                  |   2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |   4 +-
>  fs/9p/vfs_addr.c                           |   4 +-
>  fs/9p/vfs_inode.c                          |   6 +-
>  fs/9p/vfs_inode_dotl.c                     |   6 +-
>  fs/affs/amigaffs.c                         |   8 +-
>  fs/affs/bitmap.c                           |   2 +-
>  fs/affs/dir.c                              |   2 +-
>  fs/affs/file.c                             |  20 +-
>  fs/affs/inode.c                            |  12 +-
>  fs/affs/namei.c                            |  14 +-
>  fs/affs/symlink.c                          |   2 +-
>  fs/afs/dir.c                               |  10 +-
>  fs/afs/dir_search.c                        |   2 +-
>  fs/afs/dynroot.c                           |   2 +-
>  fs/afs/inode.c                             |   2 +-
>  fs/autofs/inode.c                          |   2 +-
>  fs/befs/linuxvfs.c                         |  28 +-
>  fs/bfs/dir.c                               |   4 +-
>  fs/cachefiles/io.c                         |   6 +-
>  fs/cachefiles/namei.c                      |  12 +-
>  fs/cachefiles/xattr.c                      |   2 +-
>  fs/ceph/crypto.c                           |   4 +-
>  fs/coda/dir.c                              |   2 +-
>  fs/coda/inode.c                            |   2 +-
>  fs/cramfs/inode.c                          |   2 +-
>  fs/crypto/crypto.c                         |   2 +-
>  fs/crypto/hooks.c                          |   2 +-
>  fs/crypto/keysetup.c                       |   2 +-
>  fs/dcache.c                                |   4 +-
>  fs/ecryptfs/crypto.c                       |   6 +-
>  fs/ecryptfs/file.c                         |   2 +-
>  fs/efs/inode.c                             |   6 +-
>  fs/eventpoll.c                             |   2 +-
>  fs/exportfs/expfs.c                        |   4 +-
>  fs/ext2/dir.c                              |  10 +-
>  fs/ext2/ialloc.c                           |   9 +-
>  fs/ext2/inode.c                            |   2 +-
>  fs/ext2/xattr.c                            |  14 +-
>  fs/ext4/dir.c                              |   2 +-
>  fs/ext4/ext4.h                             |   4 +-
>  fs/ext4/extents.c                          |   8 +-
>  fs/ext4/extents_status.c                   |  28 +-
>  fs/ext4/fast_commit.c                      |   8 +-
>  fs/ext4/ialloc.c                           |  10 +-
>  fs/ext4/indirect.c                         |   2 +-
>  fs/ext4/inline.c                           |  14 +-
>  fs/ext4/inode.c                            |  22 +-
>  fs/ext4/ioctl.c                            |   4 +-
>  fs/ext4/mballoc.c                          |   6 +-
>  fs/ext4/migrate.c                          |   2 +-
>  fs/ext4/move_extent.c                      |  20 +-
>  fs/ext4/namei.c                            |  10 +-
>  fs/ext4/orphan.c                           |  16 +-
>  fs/ext4/page-io.c                          |  10 +-
>  fs/ext4/super.c                            |  22 +-
>  fs/ext4/xattr.c                            |  10 +-
>  fs/f2fs/compress.c                         |   4 +-
>  fs/f2fs/dir.c                              |   2 +-
>  fs/f2fs/extent_cache.c                     |   8 +-
>  fs/f2fs/f2fs.h                             |   6 +-
>  fs/f2fs/file.c                             |  12 +-
>  fs/f2fs/gc.c                               |   2 +-
>  fs/f2fs/inline.c                           |   4 +-
>  fs/f2fs/inode.c                            |  48 ++--
>  fs/f2fs/namei.c                            |   8 +-
>  fs/f2fs/node.c                             |  12 +-
>  fs/f2fs/recovery.c                         |  10 +-
>  fs/f2fs/xattr.c                            |  10 +-
>  fs/freevxfs/vxfs_bmap.c                    |   4 +-
>  fs/fserror.c                               |   2 +-
>  fs/hfs/catalog.c                           |   2 +-
>  fs/hfs/extent.c                            |   4 +-
>  fs/hfs/inode.c                             |   4 +-
>  fs/hfsplus/attributes.c                    |  10 +-
>  fs/hfsplus/catalog.c                       |   2 +-
>  fs/hfsplus/dir.c                           |   6 +-
>  fs/hfsplus/extents.c                       |   6 +-
>  fs/hfsplus/inode.c                         |   8 +-
>  fs/hfsplus/super.c                         |   6 +-
>  fs/hfsplus/xattr.c                         |  10 +-
>  fs/hpfs/dir.c                              |   4 +-
>  fs/hpfs/dnode.c                            |   4 +-
>  fs/hpfs/ea.c                               |   4 +-
>  fs/hpfs/inode.c                            |   4 +-
>  fs/inode.c                                 |  46 ++--
>  fs/iomap/ioend.c                           |   2 +-
>  fs/isofs/compress.c                        |   2 +-
>  fs/isofs/dir.c                             |   2 +-
>  fs/isofs/inode.c                           |   6 +-
>  fs/isofs/namei.c                           |   2 +-
>  fs/jbd2/journal.c                          |   4 +-
>  fs/jbd2/transaction.c                      |   2 +-
>  fs/jffs2/dir.c                             |   4 +-
>  fs/jffs2/file.c                            |   4 +-
>  fs/jffs2/fs.c                              |  18 +-
>  fs/jfs/inode.c                             |   2 +-
>  fs/jfs/jfs_imap.c                          |   2 +-
>  fs/jfs/jfs_metapage.c                      |   2 +-
>  fs/lockd/svclock.c                         |   8 +-
>  fs/lockd/svcsubs.c                         |   2 +-
>  fs/locks.c                                 |   6 +-
>  fs/minix/inode.c                           |  10 +-
>  fs/nfs/dir.c                               |  22 +-
>  fs/nfs/file.c                              |   8 +-
>  fs/nfs/filelayout/filelayout.c             |   8 +-
>  fs/nfs/flexfilelayout/flexfilelayout.c     |   8 +-
>  fs/nfs/inode.c                             |  54 +---
>  fs/nfs/nfs4proc.c                          |   4 +-
>  fs/nfs/pnfs.c                              |  12 +-
>  fs/nfsd/export.c                           |   2 +-
>  fs/nfsd/nfs4state.c                        |   4 +-
>  fs/nfsd/nfsfh.c                            |   4 +-
>  fs/nfsd/vfs.c                              |   2 +-
>  fs/nilfs2/alloc.c                          |  10 +-
>  fs/nilfs2/bmap.c                           |   2 +-
>  fs/nilfs2/btnode.c                         |   2 +-
>  fs/nilfs2/btree.c                          |  12 +-
>  fs/nilfs2/dir.c                            |  12 +-
>  fs/nilfs2/direct.c                         |   4 +-
>  fs/nilfs2/gcinode.c                        |   2 +-
>  fs/nilfs2/inode.c                          |   8 +-
>  fs/nilfs2/mdt.c                            |   2 +-
>  fs/nilfs2/namei.c                          |   2 +-
>  fs/nilfs2/segment.c                        |   2 +-
>  fs/notify/fdinfo.c                         |   4 +-
>  fs/nsfs.c                                  |   4 +-
>  fs/ntfs3/super.c                           |   2 +-
>  fs/ocfs2/alloc.c                           |   2 +-
>  fs/ocfs2/aops.c                            |   4 +-
>  fs/ocfs2/dir.c                             |   8 +-
>  fs/ocfs2/dlmfs/dlmfs.c                     |  10 +-
>  fs/ocfs2/extent_map.c                      |  12 +-
>  fs/ocfs2/inode.c                           |   2 +-
>  fs/ocfs2/quota_local.c                     |   2 +-
>  fs/ocfs2/refcounttree.c                    |  10 +-
>  fs/ocfs2/xattr.c                           |   4 +-
>  fs/orangefs/inode.c                        |   2 +-
>  fs/overlayfs/export.c                      |   2 +-
>  fs/overlayfs/namei.c                       |   4 +-
>  fs/overlayfs/util.c                        |   2 +-
>  fs/pipe.c                                  |   2 +-
>  fs/proc/fd.c                               |   2 +-
>  fs/proc/task_mmu.c                         |   4 +-
>  fs/qnx4/inode.c                            |   4 +-
>  fs/qnx6/inode.c                            |   2 +-
>  fs/smb/client/cifsfs.h                     |  17 --
>  fs/smb/client/inode.c                      |   6 +-
>  fs/smb/client/readdir.c                    |   2 +-
>  fs/ubifs/debug.c                           |   8 +-
>  fs/ubifs/dir.c                             |  28 +-
>  fs/ubifs/file.c                            |  28 +-
>  fs/ubifs/journal.c                         |   6 +-
>  fs/ubifs/super.c                           |  16 +-
>  fs/ubifs/tnc.c                             |   4 +-
>  fs/ubifs/xattr.c                           |  14 +-
>  fs/udf/directory.c                         |  18 +-
>  fs/udf/file.c                              |   2 +-
>  fs/udf/inode.c                             |  12 +-
>  fs/udf/namei.c                             |   8 +-
>  fs/udf/super.c                             |   2 +-
>  fs/ufs/balloc.c                            |   6 +-
>  fs/ufs/dir.c                               |  10 +-
>  fs/ufs/ialloc.c                            |   6 +-
>  fs/ufs/inode.c                             |  18 +-
>  fs/ufs/ufs_fs.h                            |   6 +-
>  fs/ufs/util.c                              |   2 +-
>  fs/verity/init.c                           |   2 +-
>  fs/zonefs/super.c                          |   8 +-
>  include/linux/fs.h                         |  28 +-
>  include/linux/nfs_fs.h                     |  10 -
>  include/trace/events/cachefiles.h          |  18 +-
>  include/trace/events/ext4.h                | 427 +++++++++++++++--------------
>  include/trace/events/f2fs.h                | 172 ++++++------
>  include/trace/events/filelock.h            |  16 +-
>  include/trace/events/filemap.h             |  20 +-
>  include/trace/events/fs_dax.h              |  20 +-
>  include/trace/events/fsverity.h            |  30 +-
>  include/trace/events/hugetlbfs.h           |  28 +-
>  include/trace/events/netfs.h               |   4 +-
>  include/trace/events/nilfs2.h              |  12 +-
>  include/trace/events/readahead.h           |  12 +-
>  include/trace/events/timestamp.h           |  12 +-
>  include/trace/events/writeback.h           | 148 +++++-----
>  kernel/events/uprobes.c                    |   4 +-
>  net/netrom/af_netrom.c                     |   4 +-
>  net/rose/af_rose.c                         |   4 +-
>  net/socket.c                               |   2 +-
>  net/x25/x25_proc.c                         |   4 +-
>  security/apparmor/apparmorfs.c             |   4 +-
>  security/integrity/integrity_audit.c       |   2 +-
>  security/ipe/audit.c                       |   2 +-
>  security/lsm_audit.c                       |  10 +-
>  security/selinux/hooks.c                   |   4 +-
>  security/smack/smack_lsm.c                 |  12 +-
>  195 files changed, 1101 insertions(+), 1166 deletions(-)
> ---
> base-commit: 2bf35e96cf6c6c3a290b69b777d34be15888e364
> change-id: 20260224-iino-u64-b44a3a72543c
> 
> Best regards,


^ permalink raw reply

* Re: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close
From: Vincent Donnefort @ 2026-02-27 10:02 UTC (permalink / raw)
  To: Qing Wang
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, syzbot+3b5dd2030fe08afdf65d
In-Reply-To: <20260227025842.1085206-1-wangqing7171@gmail.com>

On Fri, Feb 27, 2026 at 10:58:42AM +0800, Qing Wang wrote:
> When a process forks, the child process copies the parent's VMAs but the
> user_mapped reference count is not incremented. As a result, when both the
> parent and child processes exit, tracing_buffers_mmap_close() is called
> twice. On the second call, user_mapped is already 0, causing the function to
> return -ENODEV and triggering a WARN_ON.
> 
> Fix it by incrementing the user_mapped reference count without re-mapping
> the pages in the VMA's open callback.

Hum, not sure this is entirely correct. We do set VM_DONTCOPY when creating the
mapping (see __rb_map_vma). So AFAICT ->open() is not called in this situation (see
dup_mmap())

> 
> Fixes: cf9f0f7c4c5bb ("tracing: Allow user-space mapping of the ring-buffer")
> Reported-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=3b5dd2030fe08afdf65d
> Tested-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> Signed-off-by: Qing Wang <wangqing7171@gmail.com>
> ---
>  include/linux/ring_buffer.h |  1 +
>  kernel/trace/ring_buffer.c  | 21 +++++++++++++++++++++
>  kernel/trace/trace.c        | 13 +++++++++++++
>  3 files changed, 35 insertions(+)
> 
> diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
> index 876358cfe1b1..d862fa610270 100644
> --- a/include/linux/ring_buffer.h
> +++ b/include/linux/ring_buffer.h
> @@ -248,6 +248,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node);
>  
>  int ring_buffer_map(struct trace_buffer *buffer, int cpu,
>  		    struct vm_area_struct *vma);
> +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu);
>  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu);
>  int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu);
>  #endif /* _LINUX_RING_BUFFER_H */
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index f16f053ef77d..17d0ea0cc3e6 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -7310,6 +7310,27 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
>  	return err;
>  }
>  
> +/*
> + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> + * the user_mapped counter without remapping pages.
> + */
> +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu)
> +{
> +	struct ring_buffer_per_cpu *cpu_buffer;
> +
> +	if (WARN_ON(!cpumask_test_cpu(cpu, buffer->cpumask)))
> +		return;
> +
> +	cpu_buffer = buffer->buffers[cpu];
> +
> +	guard(mutex)(&cpu_buffer->mapping_lock);
> +
> +	if (cpu_buffer->user_mapped)
> +		__rb_inc_dec_mapped(cpu_buffer, true);
> +	else
> +		WARN(1, "Unexpected buffer stat, it should be mapped");
> +}
> +
>  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu)
>  {
>  	struct ring_buffer_per_cpu *cpu_buffer;
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 23de3719f495..1e7c032a72d2 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -8213,6 +8213,18 @@ static inline int get_snapshot_map(struct trace_array *tr) { return 0; }
>  static inline void put_snapshot_map(struct trace_array *tr) { }
>  #endif
>  
> +/*
> + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> + * the user_mapped counter without remapping pages.
> + */
> +static void tracing_buffers_mmap_open(struct vm_area_struct *vma)
> +{
> +	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> +	struct trace_iterator *iter = &info->iter;
> +
> +	ring_buffer_map_dup(iter->array_buffer->buffer, iter->cpu_file);
> +}
> +
>  static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
>  {
>  	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> @@ -8232,6 +8244,7 @@ static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long a
>  }
>  
>  static const struct vm_operations_struct tracing_buffers_vmops = {
> +	.open		= tracing_buffers_mmap_open,
>  	.close		= tracing_buffers_mmap_close,
>  	.may_split      = tracing_buffers_may_split,
>  };
> -- 
> 2.34.1
> 

^ permalink raw reply

* Re: [PATCH 00/61] vfs: change inode->i_ino from unsigned long to u64
From: Christian Brauner @ 2026-02-27 10:06 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Alexander Viro, Jan Kara, Steven Rostedt, Masami Hiramatsu,
	Mathieu Desnoyers, Dan Williams, Matthew Wilcox, Eric Biggers,
	Theodore Y. Ts'o, Muchun Song, Oscar Salvador,
	David Hildenbrand, David Howells, Paulo Alcantara, Andreas Dilger,
	Jan Kara, Jaegeuk Kim, Chao Yu, Trond Myklebust, Anna Schumaker,
	Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Steve French, Ronnie Sahlberg, Shyam Prasad N, Bharath SM,
	Alexander Aring, Ryusuke Konishi, Viacheslav Dubeyko,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Ilya Dryomov, Alex Markuze, Jan Harkes, coda, Nicolas Pitre,
	Tyler Hicks, Amir Goldstein, Christoph Hellwig,
	John Paul Adrian Glaubitz, Yangtao Li, Mikulas Patocka,
	David Woodhouse, Richard Weinberger, Dave Kleikamp,
	Konstantin Komarov, Mark Fasheh, Joel Becker, Joseph Qi,
	Mike Marshall, Martin Brandenburg, Miklos Szeredi, Anders Larsen,
	Zhihao Cheng, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	John Johansen, Paul Moore, James Morris, Serge E. Hallyn,
	Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
	Stephen Smalley, Ondrej Mosnacek, Casey Schaufler, Alex Deucher,
	Christian König, David Airlie, Simona Vetter, Sumit Semwal,
	Eric Dumazet, Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn,
	David S. Miller, Jakub Kicinski, Simon Horman, Oleg Nesterov,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, James Clark, Darrick J. Wong,
	Martin Schiller, linux-fsdevel, linux-kernel, linux-trace-kernel,
	nvdimm, fsverity, linux-mm, netfs, linux-ext4, linux-f2fs-devel,
	linux-nfs, linux-cifs, samba-technical, linux-nilfs, v9fs,
	linux-afs, autofs, ceph-devel, codalist, ecryptfs, linux-mtd,
	jfs-discussion, ntfs3, ocfs2-devel, devel, linux-unionfs,
	apparmor, linux-security-module, linux-integrity, selinux,
	amd-gfx, dri-devel, linux-media, linaro-mm-sig, netdev,
	linux-perf-users, linux-fscrypt, linux-xfs, linux-hams, linux-x25
In-Reply-To: <20260226-iino-u64-v1-0-ccceff366db9@kernel.org>

On Thu, Feb 26, 2026 at 10:55:02AM -0500, Jeff Layton wrote:
> Christian said [1] to "just do it" when I proposed this, so here we are!
> 
> For historical reasons, the inode->i_ino field is an unsigned long,
> which means that it's 32 bits on 32 bit architectures. This has caused a
> number of filesystems to implement hacks to hash a 64-bit identifier
> into a 32-bit field, and deprives us of a universal identifier field for
> an inode.
> 
> This patchset changes the inode->i_ino field from an unsigned long to a
> u64. This shouldn't make any material difference on 64-bit hosts, but
> 32-bit hosts will see struct inode grow by at least 4 bytes. This could
> have effects on slabcache sizes and field alignment.
> 
> The bulk of the changes are to format strings and tracepoints, since the
> kernel itself doesn't care that much about the i_ino field. The first
> patch changes some vfs function arguments, so check that one out
> carefully.
> 
> With this change, we may be able to shrink some inode structures. For
> instance, struct nfs_inode has a fileid field that holds the 64-bit
> inode number. With this set of changes, that field could be eliminated.
> I'd rather leave that sort of cleanups for later just to keep this
> simple.
> 
> Much of this set was generated by LLM, but I attributed it to myself
> since I consider this to be in the "menial tasks" category of LLM usage.
> 
> [1]: https://lore.kernel.org/linux-fsdevel/20260219-portrait-winkt-959070cee42f@brauner/

I'm working under the assumption that we have crossed the threshold and
people send patches they did completely themselves and also patches that
were done with the help of or almost completely by a tool. You have to
defend it one way or the other.

Frankly, as long as you understand what you're doing in general well and
I know that you are a trusted and thorough developer/maintainer I could
not care less if you tell me whether or not you did this all on your
own or with the help of some tool. In my experience, laziness grows with
experience but so does the amount of ideas. 

So attribute it to yourself or attribute it partially to the tool. I
personally don't care.

^ permalink raw reply

* Re: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close
From: Vincent Donnefort @ 2026-02-27 10:41 UTC (permalink / raw)
  To: Qing Wang
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, syzbot+3b5dd2030fe08afdf65d
In-Reply-To: <aaFrmHzIAkEe7ufy@google.com>

On Fri, Feb 27, 2026 at 10:02:00AM +0000, Vincent Donnefort wrote:
> On Fri, Feb 27, 2026 at 10:58:42AM +0800, Qing Wang wrote:
> > When a process forks, the child process copies the parent's VMAs but the
> > user_mapped reference count is not incremented. As a result, when both the
> > parent and child processes exit, tracing_buffers_mmap_close() is called
> > twice. On the second call, user_mapped is already 0, causing the function to
> > return -ENODEV and triggering a WARN_ON.
> > 
> > Fix it by incrementing the user_mapped reference count without re-mapping
> > the pages in the VMA's open callback.
> 
> Hum, not sure this is entirely correct. We do set VM_DONTCOPY when creating the
> mapping (see __rb_map_vma). So AFAICT ->open() is not called in this situation (see
> dup_mmap())

Ah right, Syzkaller is using madvise(MADVISE_DOFORK) which resets VM_DONTCOPY.

> 
> > 
> > Fixes: cf9f0f7c4c5bb ("tracing: Allow user-space mapping of the ring-buffer")
> > Reported-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=3b5dd2030fe08afdf65d
> > Tested-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> > Signed-off-by: Qing Wang <wangqing7171@gmail.com>
> > ---
> >  include/linux/ring_buffer.h |  1 +
> >  kernel/trace/ring_buffer.c  | 21 +++++++++++++++++++++
> >  kernel/trace/trace.c        | 13 +++++++++++++
> >  3 files changed, 35 insertions(+)
> > 
> > diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
> > index 876358cfe1b1..d862fa610270 100644
> > --- a/include/linux/ring_buffer.h
> > +++ b/include/linux/ring_buffer.h
> > @@ -248,6 +248,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node);
> >  
> >  int ring_buffer_map(struct trace_buffer *buffer, int cpu,
> >  		    struct vm_area_struct *vma);
> > +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu);
> >  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu);
> >  int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu);
> >  #endif /* _LINUX_RING_BUFFER_H */
> > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> > index f16f053ef77d..17d0ea0cc3e6 100644
> > --- a/kernel/trace/ring_buffer.c
> > +++ b/kernel/trace/ring_buffer.c
> > @@ -7310,6 +7310,27 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
> >  	return err;
> >  }
> >  
> > +/*
> > + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> > + * the user_mapped counter without remapping pages.
> > + */
> > +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu)
> > +{
> > +	struct ring_buffer_per_cpu *cpu_buffer;
> > +
> > +	if (WARN_ON(!cpumask_test_cpu(cpu, buffer->cpumask)))
> > +		return;
> > +
> > +	cpu_buffer = buffer->buffers[cpu];
> > +
> > +	guard(mutex)(&cpu_buffer->mapping_lock);
> > +
> > +	if (cpu_buffer->user_mapped)
> > +		__rb_inc_dec_mapped(cpu_buffer, true);
> > +	else
> > +		WARN(1, "Unexpected buffer stat, it should be mapped");
> > +}
> > +
> >  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu)
> >  {
> >  	struct ring_buffer_per_cpu *cpu_buffer;
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 23de3719f495..1e7c032a72d2 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -8213,6 +8213,18 @@ static inline int get_snapshot_map(struct trace_array *tr) { return 0; }
> >  static inline void put_snapshot_map(struct trace_array *tr) { }
> >  #endif
> >  
> > +/*
> > + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> > + * the user_mapped counter without remapping pages.
> > + */
> > +static void tracing_buffers_mmap_open(struct vm_area_struct *vma)
> > +{
> > +	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> > +	struct trace_iterator *iter = &info->iter;
> > +
> > +	ring_buffer_map_dup(iter->array_buffer->buffer, iter->cpu_file);
> > +}
> > +
> >  static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
> >  {
> >  	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> > @@ -8232,6 +8244,7 @@ static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long a
> >  }
> >  
> >  static const struct vm_operations_struct tracing_buffers_vmops = {
> > +	.open		= tracing_buffers_mmap_open,
> >  	.close		= tracing_buffers_mmap_close,
> >  	.may_split      = tracing_buffers_may_split,
> >  };
> > -- 
> > 2.34.1
> > 

^ permalink raw reply

* Re: [PATCH] tracing: Fix WARN_ON in tracing_buffers_mmap_close
From: Vincent Donnefort @ 2026-02-27 11:22 UTC (permalink / raw)
  To: Qing Wang
  Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
	linux-trace-kernel, syzbot+3b5dd2030fe08afdf65d
In-Reply-To: <aaF0zS3xh5KgM_yy@google.com>

On Fri, Feb 27, 2026 at 10:41:17AM +0000, Vincent Donnefort wrote:
> On Fri, Feb 27, 2026 at 10:02:00AM +0000, Vincent Donnefort wrote:
> > On Fri, Feb 27, 2026 at 10:58:42AM +0800, Qing Wang wrote:
> > > When a process forks, the child process copies the parent's VMAs but the
> > > user_mapped reference count is not incremented. As a result, when both the
> > > parent and child processes exit, tracing_buffers_mmap_close() is called
> > > twice. On the second call, user_mapped is already 0, causing the function to
> > > return -ENODEV and triggering a WARN_ON.
> > > 
> > > Fix it by incrementing the user_mapped reference count without re-mapping
> > > the pages in the VMA's open callback.
> > 
> > Hum, not sure this is entirely correct. We do set VM_DONTCOPY when creating the
> > mapping (see __rb_map_vma). So AFAICT ->open() is not called in this situation (see
> > dup_mmap())
> 
> Ah right, Syzkaller is using madvise(MADVISE_DOFORK) which resets VM_DONTCOPY.

As we are applying restrictive rules for this mapping, I believe setting VM_IO
might be a better fix.

> 
> > 
> > > 
> > > Fixes: cf9f0f7c4c5bb ("tracing: Allow user-space mapping of the ring-buffer")
> > > Reported-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> > > Closes: https://syzkaller.appspot.com/bug?extid=3b5dd2030fe08afdf65d
> > > Tested-by: syzbot+3b5dd2030fe08afdf65d@syzkaller.appspotmail.com
> > > Signed-off-by: Qing Wang <wangqing7171@gmail.com>
> > > ---
> > >  include/linux/ring_buffer.h |  1 +
> > >  kernel/trace/ring_buffer.c  | 21 +++++++++++++++++++++
> > >  kernel/trace/trace.c        | 13 +++++++++++++
> > >  3 files changed, 35 insertions(+)
> > > 
> > > diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
> > > index 876358cfe1b1..d862fa610270 100644
> > > --- a/include/linux/ring_buffer.h
> > > +++ b/include/linux/ring_buffer.h
> > > @@ -248,6 +248,7 @@ int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node);
> > >  
> > >  int ring_buffer_map(struct trace_buffer *buffer, int cpu,
> > >  		    struct vm_area_struct *vma);
> > > +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu);
> > >  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu);
> > >  int ring_buffer_map_get_reader(struct trace_buffer *buffer, int cpu);
> > >  #endif /* _LINUX_RING_BUFFER_H */
> > > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> > > index f16f053ef77d..17d0ea0cc3e6 100644
> > > --- a/kernel/trace/ring_buffer.c
> > > +++ b/kernel/trace/ring_buffer.c
> > > @@ -7310,6 +7310,27 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
> > >  	return err;
> > >  }
> > >  
> > > +/*
> > > + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> > > + * the user_mapped counter without remapping pages.
> > > + */
> > > +void ring_buffer_map_dup(struct trace_buffer *buffer, int cpu)
> > > +{
> > > +	struct ring_buffer_per_cpu *cpu_buffer;
> > > +
> > > +	if (WARN_ON(!cpumask_test_cpu(cpu, buffer->cpumask)))
> > > +		return;
> > > +
> > > +	cpu_buffer = buffer->buffers[cpu];
> > > +
> > > +	guard(mutex)(&cpu_buffer->mapping_lock);
> > > +
> > > +	if (cpu_buffer->user_mapped)
> > > +		__rb_inc_dec_mapped(cpu_buffer, true);
> > > +	else
> > > +		WARN(1, "Unexpected buffer stat, it should be mapped");
> > > +}
> > > +
> > >  int ring_buffer_unmap(struct trace_buffer *buffer, int cpu)
> > >  {
> > >  	struct ring_buffer_per_cpu *cpu_buffer;
> > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > > index 23de3719f495..1e7c032a72d2 100644
> > > --- a/kernel/trace/trace.c
> > > +++ b/kernel/trace/trace.c
> > > @@ -8213,6 +8213,18 @@ static inline int get_snapshot_map(struct trace_array *tr) { return 0; }
> > >  static inline void put_snapshot_map(struct trace_array *tr) { }
> > >  #endif
> > >  
> > > +/*
> > > + * This is called when a VMA is duplicated (e.g., on fork()) to increment
> > > + * the user_mapped counter without remapping pages.
> > > + */
> > > +static void tracing_buffers_mmap_open(struct vm_area_struct *vma)
> > > +{
> > > +	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> > > +	struct trace_iterator *iter = &info->iter;
> > > +
> > > +	ring_buffer_map_dup(iter->array_buffer->buffer, iter->cpu_file);
> > > +}
> > > +
> > >  static void tracing_buffers_mmap_close(struct vm_area_struct *vma)
> > >  {
> > >  	struct ftrace_buffer_info *info = vma->vm_file->private_data;
> > > @@ -8232,6 +8244,7 @@ static int tracing_buffers_may_split(struct vm_area_struct *vma, unsigned long a
> > >  }
> > >  
> > >  static const struct vm_operations_struct tracing_buffers_vmops = {
> > > +	.open		= tracing_buffers_mmap_open,
> > >  	.close		= tracing_buffers_mmap_close,
> > >  	.may_split      = tracing_buffers_may_split,
> > >  };
> > > -- 
> > > 2.34.1
> > > 

^ permalink raw reply

* Re: [PATCH 00/61] vfs: change inode->i_ino from unsigned long to u64
From: Jeff Layton @ 2026-02-27 11:52 UTC (permalink / raw)
  To: Christian König, Alexander Viro, Christian Brauner, Jan Kara,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Dan Williams,
	Matthew Wilcox, Eric Biggers, Theodore Y. Ts'o, Muchun Song,
	Oscar Salvador, David Hildenbrand, David Howells, Paulo Alcantara,
	Andreas Dilger, Jan Kara, Jaegeuk Kim, Chao Yu, Trond Myklebust,
	Anna Schumaker, Chuck Lever, NeilBrown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, Steve French, Ronnie Sahlberg,
	Shyam Prasad N, Bharath SM, Alexander Aring, Ryusuke Konishi,
	Viacheslav Dubeyko, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck, David Sterba,
	Marc Dionne, Ian Kent, Luis de Bethencourt, Salah Triki,
	Tigran A. Aivazian, Ilya Dryomov, Alex Markuze, Jan Harkes, coda,
	Nicolas Pitre, Tyler Hicks, Amir Goldstein, Christoph Hellwig,
	John Paul Adrian Glaubitz, Yangtao Li, Mikulas Patocka,
	David Woodhouse, Richard Weinberger, Dave Kleikamp,
	Konstantin Komarov, Mark Fasheh, Joel Becker, Joseph Qi,
	Mike Marshall, Martin Brandenburg, Miklos Szeredi, Anders Larsen,
	Zhihao Cheng, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	John Johansen, Paul Moore, James Morris, Serge E. Hallyn,
	Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg, Fan Wu,
	Stephen Smalley, Ondrej Mosnacek, Casey Schaufler, Alex Deucher,
	David Airlie, Simona Vetter, Sumit Semwal, Eric Dumazet,
	Kuniyuki Iwashima, Paolo Abeni, Willem de Bruijn, David S. Miller,
	Jakub Kicinski, Simon Horman, Oleg Nesterov, Peter Zijlstra,
	Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Darrick J. Wong, Martin Schiller
  Cc: linux-fsdevel, linux-kernel, linux-trace-kernel, nvdimm, fsverity,
	linux-mm, netfs, linux-ext4, linux-f2fs-devel, linux-nfs,
	linux-cifs, samba-technical, linux-nilfs, v9fs, linux-afs, autofs,
	ceph-devel, codalist, ecryptfs, linux-mtd, jfs-discussion, ntfs3,
	ocfs2-devel, devel, linux-unionfs, apparmor,
	linux-security-module, linux-integrity, selinux, amd-gfx,
	dri-devel, linux-media, linaro-mm-sig, netdev, linux-perf-users,
	linux-fscrypt, linux-xfs, linux-hams, linux-x25
In-Reply-To: <b4f32cab-2b34-4002-83d1-3ae038a4bb38@amd.com>

On Fri, 2026-02-27 at 10:30 +0100, Christian König wrote:
> On 2/26/26 16:55, Jeff Layton wrote:
> > Christian said [1] to "just do it" when I proposed this, so here we are!
> > 
> > For historical reasons, the inode->i_ino field is an unsigned long,
> > which means that it's 32 bits on 32 bit architectures. This has caused a
> > number of filesystems to implement hacks to hash a 64-bit identifier
> > into a 32-bit field, and deprives us of a universal identifier field for
> > an inode.
> > 
> > This patchset changes the inode->i_ino field from an unsigned long to a
> > u64. This shouldn't make any material difference on 64-bit hosts, but
> > 32-bit hosts will see struct inode grow by at least 4 bytes. This could
> > have effects on slabcache sizes and field alignment.
> > 
> > The bulk of the changes are to format strings and tracepoints, since the
> > kernel itself doesn't care that much about the i_ino field. The first
> > patch changes some vfs function arguments, so check that one out
> > carefully.
> > 
> > With this change, we may be able to shrink some inode structures. For
> > instance, struct nfs_inode has a fileid field that holds the 64-bit
> > inode number. With this set of changes, that field could be eliminated.
> > I'd rather leave that sort of cleanups for later just to keep this
> > simple.
> > 
> > Much of this set was generated by LLM, but I attributed it to myself
> > since I consider this to be in the "menial tasks" category of LLM usage.
> 
> Sounds reasonable to me, should get_next_ino() also be changed to return an 64bit ino?
> 

I'm not opposed to doing that, but I'd probably leave that for a
follow-on cleanup. Just doing the i_ino conversion is already making
for a huge patchset.
-- 
Jeff Layton <jlayton@kernel.org>

^ permalink raw reply

* Re: [PATCH 50/61] zonefs: update format strings for u64 i_ino
From: Johannes Thumshirn @ 2026-02-27 11:55 UTC (permalink / raw)
  To: Jeff Layton, Alexander Viro, Christian Brauner, Jan Kara,
	Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Dan Williams,
	Matthew Wilcox, Eric Biggers, Theodore Y. Ts'o, Muchun Song,
	Oscar Salvador, David Hildenbrand, David Howells, Paulo Alcantara,
	Andreas Dilger, Jan Kara, Jaegeuk Kim, Chao Yu, Trond Myklebust,
	Anna Schumaker, Chuck Lever, NeilBrown, Olga Kornievskaia,
	Dai Ngo, Tom Talpey, Steve French, Ronnie Sahlberg,
	Shyam Prasad N, Bharath SM, Alexander Aring, Ryusuke Konishi,
	Viacheslav Dubeyko, Eric Van Hensbergen, Latchesar Ionkov,
	Dominique Martinet, Christian Schoenebeck, David Sterba,
	Marc Dionne, Ian Kent, Luis de Bethencourt, Salah Triki,
	Tigran A. Aivazian, Ilya Dryomov, Alex Markuze, Jan Harkes,
	coda@cs.cmu.edu, Nicolas Pitre, Tyler Hicks, Amir Goldstein,
	hch@infradead.org, John Paul Adrian Glaubitz, Yangtao Li,
	Mikulas Patocka, David Woodhouse, Richard Weinberger,
	Dave Kleikamp, Konstantin Komarov, Mark Fasheh, Joel Becker,
	Joseph Qi, Mike Marshall, Martin Brandenburg, Miklos Szeredi,
	Anders Larsen, Zhihao Cheng, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Mimi Zohar, Roberto Sassu, Dmitry Kasatkin,
	Eric Snowberg, Fan Wu, Stephen Smalley, Ondrej Mosnacek,
	Casey Schaufler, Alex Deucher, Christian König, David Airlie,
	Simona Vetter, Sumit Semwal, Eric Dumazet, Kuniyuki Iwashima,
	Paolo Abeni, Willem de Bruijn, David S. Miller, Jakub Kicinski,
	Simon Horman, Oleg Nesterov, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Darrick J. Wong, Martin Schiller
  Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, nvdimm@lists.linux.dev,
	fsverity@lists.linux.dev, linux-mm@kvack.org,
	netfs@lists.linux.dev, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, linux-nfs@vger.kernel.org,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-nilfs@vger.kernel.org, v9fs@lists.linux.dev,
	linux-afs@lists.infradead.org, autofs@vger.kernel.org,
	ceph-devel@vger.kernel.org, codalist@coda.cs.cmu.edu,
	ecryptfs@vger.kernel.org, linux-mtd@lists.infradead.org,
	jfs-discussion@lists.sourceforge.net, ntfs3@lists.linux.dev,
	ocfs2-devel@lists.linux.dev, devel@lists.orangefs.org,
	linux-unionfs@vger.kernel.org, apparmor@lists.ubuntu.com,
	linux-security-module@vger.kernel.org,
	linux-integrity@vger.kernel.org, selinux@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	netdev@vger.kernel.org, linux-perf-users@vger.kernel.org,
	linux-fscrypt@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-hams@vger.kernel.org, linux-x25@vger.kernel.org
In-Reply-To: <20260226-iino-u64-v1-50-ccceff366db9@kernel.org>

Looks good,

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>


^ permalink raw reply

* Re: [PATCH v3 5/5] mm: add tracepoints for zone lock
From: Dmitry Ilvokhin @ 2026-02-27 12:39 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Axel Rasmussen, Yuanchu Xie,
	Wei Xu, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Brendan Jackman, Johannes Weiner, Zi Yan, Oscar Salvador,
	Qi Zheng, linux-kernel, linux-mm, linux-trace-kernel, linux-cxl,
	kernel-team, Benjamin Cheatham
In-Reply-To: <aaC7S2ensAGTyujc@linux.dev>

On Thu, Feb 26, 2026 at 01:31:48PM -0800, Shakeel Butt wrote:
> On Thu, Feb 26, 2026 at 01:25:01PM -0800, Andrew Morton wrote:
> > On Thu, 26 Feb 2026 11:14:52 -0800 Shakeel Butt <shakeel.butt@linux.dev> wrote:
> > 
> > > On Thu, Feb 26, 2026 at 06:26:22PM +0000, Dmitry Ilvokhin wrote:
> > > > Add tracepoint instrumentation to zone lock acquire/release operations
> > > > via the previously introduced wrappers.
> > > > 
> > > > The implementation follows the mmap_lock tracepoint pattern: a
> > > > lightweight inline helper checks whether the tracepoint is enabled and
> > > > calls into an out-of-line helper when tracing is active. When
> > > > CONFIG_TRACING is disabled, helpers compile to empty inline stubs.
> > > > 
> > > > The fast path is unaffected when tracing is disabled.
> > > > 
> > > > Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com>
> > > 
> > > ...
> > >
> > > > +void __zone_lock_do_trace_start_locking(struct zone *zone)
> > > > +{
> > > > +	trace_zone_lock_start_locking(zone);
> > > > +}
> > > > +EXPORT_SYMBOL(__zone_lock_do_trace_start_locking);
> > > 
> > > No reason to not have these as EXPORT_SYMBOL_GPL (& below)
> > 
> > Do we need the exports at all?
> 
> Very good point and we don't. I think this might just be copying the mmap_lock
> tracepoint wrappers which might need the exports as some drivers might be taking
> the mmap_lock.
> 
> Dmitry, please confirm (test) and let us know.

This is a good catch, thank you. I don't think we need EXPORT_SYMBOL()
here. Just verified it locally. I'll remove it in v4. 

^ permalink raw reply

* Re: [PATCH v3 1/5] mm: introduce zone lock wrappers
From: Dmitry Ilvokhin @ 2026-02-27 13:06 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Axel Rasmussen, Yuanchu Xie,
	Wei Xu, Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
	Brendan Jackman, Johannes Weiner, Zi Yan, Oscar Salvador,
	Qi Zheng, Shakeel Butt, linux-kernel, linux-mm,
	linux-trace-kernel, linux-cxl, kernel-team, Benjamin Cheatham
In-Reply-To: <20260227003140.82789-1-sj@kernel.org>

On Thu, Feb 26, 2026 at 04:31:39PM -0800, SeongJae Park wrote:
> On Thu, 26 Feb 2026 18:26:18 +0000 Dmitry Ilvokhin <d@ilvokhin.com> wrote:
> 
> > Add thin wrappers around zone lock acquire/release operations. This
> > prepares the code for future tracepoint instrumentation without
> > modifying individual call sites.
> > 
> > Centralizing zone lock operations behind wrappers allows future
> > instrumentation or debugging hooks to be added without touching
> > all users.
> > 
> > No functional change intended. The wrappers are introduced in
> > preparation for subsequent patches and are not yet used.
> > 
> > Signed-off-by: Dmitry Ilvokhin <d@ilvokhin.com>
> > Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
> > ---
> >  MAINTAINERS               |  1 +
> >  include/linux/zone_lock.h | 38 ++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 39 insertions(+)
> >  create mode 100644 include/linux/zone_lock.h
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 55af015174a5..61e3d1f5bf43 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -16680,6 +16680,7 @@ F:	include/linux/pgtable.h
> >  F:	include/linux/ptdump.h
> >  F:	include/linux/vmpressure.h
> >  F:	include/linux/vmstat.h
> > +F:	include/linux/zone_lock.h
> >  F:	kernel/fork.c
> >  F:	mm/Kconfig
> >  F:	mm/debug.c
> > diff --git a/include/linux/zone_lock.h b/include/linux/zone_lock.h
> > new file mode 100644
> > index 000000000000..c531e26280e6
> > --- /dev/null
> > +++ b/include/linux/zone_lock.h
> > @@ -0,0 +1,38 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _LINUX_ZONE_LOCK_H
> > +#define _LINUX_ZONE_LOCK_H
> > +
> > +#include <linux/mmzone.h>
> > +#include <linux/spinlock.h>
> 
> I'm bit worried if I will think this as a file for another general locking, not
> the mm specific one.  I hence think renaming it to more clearly saying the
> fact, say, mmzone_lock.h, might be less confusing.  Or, putting things in
> mmzone.h might also be an option?  What do you think?

Thanks for the feedback, SJ.

Good point. I agree the current name looks too generic. Putting it into
mmzone.h would further overload that header, so renaming zone_lock.h to
mmzone_lock.h seems like the clearest option.

I'll make that change in v4.

> 
> 
> Thanks,
> SJ
> 
> [...]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox