Re: [PATCH v3 0/2] fs, audit: Avoid excessive dput/dget in audit_context setup and reset paths

From: Ricardo Robaina

Date: Thu Feb 12 2026 - 11:38:22 EST


On Fri, Feb 6, 2026 at 5:19 PM Waiman Long <longman@xxxxxxxxxx> wrote:
>
> v3:
> - Add a new counter in fs_struct to track # of additional references
> to pwd and add a new get_fs_pwd_pool() and put_fs_pwd_pool helpers
> to use the new counter.
> - Make audit use the new helpers instead of storing pwd reference
> internally.
>
> v2: https://lore.kernel.org/lkml/20260203194433.1738162-1-longman@xxxxxxxxxx/
>
> When the audit subsystem is enabled, it can do a lot of get_fs_pwd()
> calls to get references to fs->pwd and then releasing those references
> back with path_put() later. That may cause a lot of spinlock contention
> on a single pwd's dentry lock because of the constant changes to the
> reference count when there are many processes on the same working
> directory actively doing open/close system calls. This can cause
> noticeable performance regresssion when compared with the case where
> the audit subsystem is turned off especially on systems with a lot of
> CPUs which is becoming more common these days.
>
> This patch series aim to avoid this type of performance regression caused
> by audit by adding a new set of fs_struct helpers to reduce unncessary
> path_get() and path_put() calls and the audit code is modified to use
> these new helpers.
>
> Waiman Long (2):
> fs: Add a pool of extra fs->pwd references to fs_struct
> audit: Use the new {get,put}_fs_pwd_pool() APIs to get/put pwd
> references
>
> fs/fs_struct.c | 26 +++++++++++++++++++++-----
> fs/namespace.c | 8 ++++++++
> include/linux/fs_struct.h | 30 +++++++++++++++++++++++++++++-
> kernel/auditsc.c | 7 +++++--
> 4 files changed, 63 insertions(+), 8 deletions(-)
>
> --
> 2.52.0
>

Looks good to me. I ran a local kernel build against the
audit-testsuite and verified there are no noticeable audit functional
regressions.

Reviewed-by: Ricardo Robaina <rrobaina@xxxxxxxxxx>
Tested-by: Ricardo Robaina <rrobaina@xxxxxxxxxx>

# uname -r
6.19.0+

# make test
Running as user root
with context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
on system Fedora

amcast_joinpart/test ................. ok
backlog_wait_time_actual_reset/test .. ok
bpf/test ............................. ok
exec_execve/test ..................... ok
exec_name/test ....................... ok
fanotify/test ........................ ok
field_compare/test ................... ok
file_create/test ..................... ok
file_delete/test ..................... ok
file_permission/test ................. ok
file_rename/test ..................... ok
filter_exclude/test .................. ok
filter_exit/test ..................... ok
filter_saddr_fam/test ................ ok
filter_sessionid/test ................ ok
io_uring/test ........................ ok
login_tty/test ....................... ok
lost_reset/test ...................... ok
netfilter_pkt/test ................... ok
signal/test .......................... ok
syscalls_file/test ................... ok
syscall_module/test .................. ok
syscall_socketcall/test .............. ok
time_change/test ..................... ok
user_msg/test ........................ ok
All tests successful.
Files=25, Tests=282, 70 wallclock secs ( 0.09 usr 0.01 sys + 18.61
cusr 1.47 csys = 20.18 CPU)
Result: PASS