Skip to content

Commit c8afaa1

Browse files
mjguziktorvalds
authored andcommitted
locking: remove spin_lock_prefetch
The only remaining consumer is new_inode, where it showed up in 2001 as commit c37fa16 ("v2.4.9.9 -> v2.4.9.10") in a historical repo [1] 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 admit upfront I did not see value in benchmarking this change, but I can do it if that is deemed appropriate. Removal from new_inode and of the entire thing are in the same patch as requested by Linus, so whatever weird looks can be directed at that guy. Link: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/fs/inode.c?id=c37fa164f793735b32aa3f53154ff1a7659e6442 [1] Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3feecb1 commit c8afaa1

File tree

9 files changed

+1
-47
lines changed

9 files changed

+1
-47
lines changed

arch/alpha/include/asm/processor.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ unsigned long __get_wchan(struct task_struct *p);
4747

4848
#define ARCH_HAS_PREFETCH
4949
#define ARCH_HAS_PREFETCHW
50-
#define ARCH_HAS_SPINLOCK_PREFETCH
51-
52-
#ifndef CONFIG_SMP
53-
/* Nothing to prefetch. */
54-
#define spin_lock_prefetch(lock) do { } while (0)
55-
#endif
5650

5751
extern inline void prefetch(const void *ptr)
5852
{
@@ -64,11 +58,4 @@ extern inline void prefetchw(const void *ptr)
6458
__builtin_prefetch(ptr, 1, 3);
6559
}
6660

67-
#ifdef CONFIG_SMP
68-
extern inline void spin_lock_prefetch(const void *ptr)
69-
{
70-
__builtin_prefetch(ptr, 1, 3);
71-
}
72-
#endif
73-
7461
#endif /* __ASM_ALPHA_PROCESSOR_H */

arch/arm64/include/asm/processor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,6 @@ static inline void prefetchw(const void *ptr)
359359
asm volatile("prfm pstl1keep, %a0\n" : : "p" (ptr));
360360
}
361361

362-
#define ARCH_HAS_SPINLOCK_PREFETCH
363-
static inline void spin_lock_prefetch(const void *ptr)
364-
{
365-
asm volatile(ARM64_LSE_ATOMIC_INSN(
366-
"prfm pstl1strm, %a0",
367-
"nop") : : "p" (ptr));
368-
}
369-
370362
extern unsigned long __ro_after_init signal_minsigstksz; /* sigframe size */
371363
extern void __init minsigstksz_setup(void);
372364

arch/ia64/include/asm/processor.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ ia64_imva (void *addr)
634634

635635
#define ARCH_HAS_PREFETCH
636636
#define ARCH_HAS_PREFETCHW
637-
#define ARCH_HAS_SPINLOCK_PREFETCH
638637
#define PREFETCH_STRIDE L1_CACHE_BYTES
639638

640639
static inline void
@@ -649,8 +648,6 @@ prefetchw (const void *x)
649648
ia64_lfetch_excl(ia64_lfhint_none, x);
650649
}
651650

652-
#define spin_lock_prefetch(x) prefetchw(x)
653-
654651
extern unsigned long boot_option_idle_override;
655652

656653
enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,

arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
#define cpu_has_rixi (cpu_data[0].cputype != CPU_CAVIUM_OCTEON)
6060

61-
#define ARCH_HAS_SPINLOCK_PREFETCH 1
62-
#define spin_lock_prefetch(x) prefetch(x)
6361
#define PREFETCH_STRIDE 128
6462

6563
#ifdef __OCTEON__

arch/powerpc/include/asm/processor.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ int validate_sp_size(unsigned long sp, struct task_struct *p,
393393
*/
394394
#define ARCH_HAS_PREFETCH
395395
#define ARCH_HAS_PREFETCHW
396-
#define ARCH_HAS_SPINLOCK_PREFETCH
397396

398397
static inline void prefetch(const void *x)
399398
{
@@ -411,8 +410,6 @@ static inline void prefetchw(const void *x)
411410
__asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
412411
}
413412

414-
#define spin_lock_prefetch(x) prefetchw(x)
415-
416413
/* asm stubs */
417414
extern unsigned long isa300_idle_stop_noloss(unsigned long psscr_val);
418415
extern unsigned long isa300_idle_stop_mayloss(unsigned long psscr_val);

arch/sparc/include/asm/processor_64.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ unsigned long __get_wchan(struct task_struct *task);
213213
*/
214214
#define ARCH_HAS_PREFETCH
215215
#define ARCH_HAS_PREFETCHW
216-
#define ARCH_HAS_SPINLOCK_PREFETCH
217216

218217
static inline void prefetch(const void *x)
219218
{
@@ -239,8 +238,6 @@ static inline void prefetchw(const void *x)
239238
: "r" (x));
240239
}
241240

242-
#define spin_lock_prefetch(x) prefetchw(x)
243-
244241
#define HAVE_ARCH_PICK_MMAP_LAYOUT
245242

246243
int do_mathemu(struct pt_regs *regs, struct fpustate *f, bool illegal_insn_trap);

arch/x86/include/asm/processor.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ extern char ignore_fpu_irq;
586586

587587
#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
588588
#define ARCH_HAS_PREFETCHW
589-
#define ARCH_HAS_SPINLOCK_PREFETCH
590589

591590
#ifdef CONFIG_X86_32
592591
# define BASE_PREFETCH ""
@@ -620,11 +619,6 @@ static __always_inline void prefetchw(const void *x)
620619
"m" (*(const char *)x));
621620
}
622621

623-
static inline void spin_lock_prefetch(const void *x)
624-
{
625-
prefetchw(x);
626-
}
627-
628622
#define TOP_OF_INIT_STACK ((unsigned long)&init_stack + sizeof(init_stack) - \
629623
TOP_OF_KERNEL_STACK_PADDING)
630624

fs/inode.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/fsnotify.h>
1717
#include <linux/mount.h>
1818
#include <linux/posix_acl.h>
19-
#include <linux/prefetch.h>
2019
#include <linux/buffer_head.h> /* for inode_has_buffers */
2120
#include <linux/ratelimit.h>
2221
#include <linux/list_lru.h>
@@ -1041,8 +1040,6 @@ struct inode *new_inode(struct super_block *sb)
10411040
{
10421041
struct inode *inode;
10431042

1044-
spin_lock_prefetch(&sb->s_inode_list_lock);
1045-
10461043
inode = new_inode_pseudo(sb);
10471044
if (inode)
10481045
inode_sb_list_add(inode);

include/linux/prefetch.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ struct page;
2525
prefetch() should be defined by the architecture, if not, the
2626
#define below provides a no-op define.
2727
28-
There are 3 prefetch() macros:
28+
There are 2 prefetch() macros:
2929
3030
prefetch(x) - prefetches the cacheline at "x" for read
3131
prefetchw(x) - prefetches the cacheline at "x" for write
32-
spin_lock_prefetch(x) - prefetches the spinlock *x for taking
3332
3433
there is also PREFETCH_STRIDE which is the architecure-preferred
3534
"lookahead" size for prefetching streamed operations.
@@ -44,10 +43,6 @@ struct page;
4443
#define prefetchw(x) __builtin_prefetch(x,1)
4544
#endif
4645

47-
#ifndef ARCH_HAS_SPINLOCK_PREFETCH
48-
#define spin_lock_prefetch(x) prefetchw(x)
49-
#endif
50-
5146
#ifndef PREFETCH_STRIDE
5247
#define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
5348
#endif

0 commit comments

Comments
 (0)