On Fri, 27 Feb 2026 16:15:05 -0500 AnishMulay <[email protected]> wrote:
> In fs/tracefs/inode.c, tracefs_syscall_mkdir() and tracefs_syscall_rmdir() > previously used a local helper, get_dname(), which allocated a temporary > buffer on the heap via kmalloc() to hold the dentry name. This introduced > unnecessary overhead, an ENOMEM failure path, and required manual memory > cleanup via kfree(). > > As suggested by Al Viro, replace this heap allocation with the VFS dentry > name snapshot API. By stack-allocating a `struct name_snapshot` and using > take_dentry_name_snapshot() and release_dentry_name_snapshot(), we safely > capture the dentry name locklessly, eliminate the heap allocation entirely, > and remove the now-obsolete error handling paths. The get_dname() helper > is completely removed. > > Testing: > Booted a custom kernel natively in virtme-ng (ARM64). Triggered tracefs > inode and dentry allocation by creating and removing a custom directory > under a temporary tracefs mount. Verified that the instance is created > successfully and that no memory errors or warnings are emitted in dmesg. > > Signed-off-by: AnishMulay <[email protected]> > --- It's nice to add version change history below the "---" with a link to the previous patch: Changes since v1: https://lore.kernel.org/linux-trace-kernel/[email protected]/ - Use the helper functions take/release_dentry_name_snapshot() instead of allocating the name. (Al Viro) As when I pull in a patch, my scripts add a link to the patch itself, and having that patch have a link to the previous version is always helpful. (This email serves that purpose for this patch) -- Steve
