Skip to contentSkip to conversation

fs/locks: optimize locks_remove_posix

PATCH New Wentao Guan 1 participant 1 message Apr 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/locks: optimize locks_remove_posix

Found by reading the gdb disassemble func, remove the three lines in the hot path, and locks_init_lock init them by memset0:
lock.fl_start = 0;
lock.fl_ops = NULL;
lock.fl_lmops = NULL;

Tested in unixbench syscall mircobench mark, and perf locks_remove_posix from 1.32% to 1%. Improve the syscall bench from 1858 to 1873. call path:
99.08% main
- 17.07% __close
...
- 4.85% __arm64_sys_close
- 2.74% filp_flush
- 1.00$ locks_remove_posix

---
 fs/locks.c | 3 ---
 1 file changed, 3 deletions(-)
fs/locks.c +0 -3
index 44715c43460a1..14b6ee5e82ed4 100644
@@ -2554,13 +2554,10 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
 	locks_init_lock(&lock);
 	lock.fl_type = F_UNLCK;
 	lock.fl_flags = FL_POSIX | FL_CLOSE;
-	lock.fl_start = 0;
 	lock.fl_end = OFFSET_MAX;
 	lock.fl_owner = owner;
 	lock.fl_pid = current->tgid;
 	lock.fl_file = filp;
-	lock.fl_ops = NULL;
-	lock.fl_lmops = NULL;
 
 	error = vfs_lock_file(filp, F_SETLK, &lock, NULL);
 
Signature · 1 line
2.20.1