On Tue, Feb 13, 2024 at 06:08:45PM -0500, Kent Overstreet wrote: > This is what instrumenting an allocation function looks like: > > #define krealloc_array(...) alloc_hooks(krealloc_array_noprof(__VA_ARGS__)) > > IOW, we have to: > - rename krealloc_array to krealloc_array_noprof > - replace krealloc_array with a one wrapper macro call > > Is this really all we're getting worked up over? > > The renaming we need regardless, because the thing that makes this > approach efficient enough to run in production is that we account at > _one_ point in the callstack, we don't save entire backtraces. I'm probably going to regret getting involved in this thread, but since Suren already decided to put me on the cc ... There might be a way to do it without renaming. We have a bit of the linker script called SCHED_TEXT which lets us implement in_sched_functions(). ie we could have the equivalent of include/linux/sched/debug.h:#define __sched __section(".sched.text") perhaps #define __memalloc __section(".memalloc.text") which would do all the necessary magic to know where the backtrace should stop.