mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode
@ 2023-08-12 12:37 Mateusz Guzik
  2023-08-12 15:28 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Guzik @ 2023-08-12 12:37 UTC (permalink / raw)
  To: brauner; +Cc: viro, torvalds, linux-kernel, linux-fsdevel, Mateusz Guzik

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(-)

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);
-- 
2.39.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode
  2023-08-12 12:37 [PATCH] vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode Mateusz Guzik
@ 2023-08-12 15:28 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2023-08-12 15:28 UTC (permalink / raw)
  To: Mateusz Guzik; +Cc: brauner, viro, linux-kernel, linux-fsdevel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-12 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-12 12:37 [PATCH] vfs: remove spin_lock_prefetch(&sb->s_inode_list_lock) from new_inode Mateusz Guzik
2023-08-12 15:28 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®