diff mbox series

vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode

Message ID 20230812123757.1666664-1-mjguzik@gmail.com (mailing list archive)
State New, archived
Headers show
Series vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode | expand

Commit Message

Mateusz Guzik Aug. 12, 2023, 12:37 p.m. UTC
It showed up in 2001, in the following commit in a historical repo [1]:

commit c37fa164f793735b32aa3f53154ff1a7659e6442
Author: linus1 <torvalds@athlon.transmeta.com>
Date:   Thu Aug 16 11:00:00 2001 -0800

    v2.4.9.9 -> v2.4.9.10

with a changelog which does not mention it.

Since then the line got only touched up to keep compiling.

While it may have been of benefit back in the day, it is guaranteed to
at best not get in the way in the multicore setting -- as the code
performs *a lot* of work between the prefetch and actual lock acquire,
any contention means the cacheline is already invalid by the time the
routine calls spin_lock(). It adds spurious traffic, for short.

On top of it prefetch is notoriously tricky to use for single-threaded
purposes, making it questionable from the get go.

As such, remove it.

I concede upfront I did not see value in benchmarking this change, but I
can do it if that is deemed appropriate.

Also worth nothing is that this was the only remaining consumer.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/fs/inode.c?id=c37fa164f793735b32aa3f53154ff1a7659e6442
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 fs/inode.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Linus Torvalds Aug. 12, 2023, 3:28 p.m. UTC | #1
On Sat, 12 Aug 2023 at 05:38, Mateusz Guzik <mjguzik@gmail.com> wrote:
>
> Also worth nothing is that this was the only remaining consumer.

Send a patch that also includes just removing the definition of that
thing, and I'll happily apply it.

                   Linus
diff mbox series

Patch

diff --git a/fs/inode.c b/fs/inode.c
index 8fefb69e1f84..67611a360031 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -16,7 +16,6 @@ 
 #include <linux/fsnotify.h>
 #include <linux/mount.h>
 #include <linux/posix_acl.h>
-#include <linux/prefetch.h>
 #include <linux/buffer_head.h> /* for inode_has_buffers */
 #include <linux/ratelimit.h>
 #include <linux/list_lru.h>
@@ -1041,8 +1040,6 @@  struct inode *new_inode(struct super_block *sb)
 {
 	struct inode *inode;
 
-	spin_lock_prefetch(&sb->s_inode_list_lock);
-
 	inode = new_inode_pseudo(sb);
 	if (inode)
 		inode_sb_list_add(inode);