On Fri, 29 Aug 2025 at 14:18, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > > > > Just do the parsing at parse time. End of story. > > What does "parsing at parse time" mean? In user space. When parsing the trace events. Not in kernel space, when generating the events. Arnaldo already said it was workable. > When I get a user space stack trace, I get the virtual addresses of each of > the user space functions. This is saved into an user stack trace event in > the ring buffer that usually gets mapped right to a file for post > processing. > > I still do the: > > user_stack_trace() { > foreach addr each stack frame > vma = vma_lookup(mm, addr); > callchain[i++] = (addr - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT); > > Are you saying that this shouldn't be done either? I'm saying that's ALL that should be done. And then that *ONE* single thing: callchain_filehash[i++] = hash(vma->vm_file); BUT NOTHING ELSE. None of that trace_file_map() garbage. None of that add_into_hash() garbage. NOTHING like that. You don't look at the hash. You don't "register" it. You don't touch it in any way. You literally just use it as a value, and user space will figure it out later. At event parsing time. At most, you could have some trivial optimization to avoid hashing the same pointer twice, ie have some single-entry cache of "it's still the same file pointer, I'll just use the same hash I calculated last time". And I mean *single*-level, because siphash is fast enough that doing anything *more* than that is going to be slower than just re-calculating the hash. In fact, you should probably do that optimization at the whole vma_lookup() level, and try to not look up the same vma multiple times when a common situation is probably that you'll have multiple stack frames all with entries pointing to the same executable (or library) mapping. Because "vma_lookup()" is likely about as expensive as the hashing is. Linus