Skip to content

Commit f12fb73

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
mm: delete checks for xor_unlock_is_negative_byte()
Architectures which don't define their own use the one in asm-generic/bitops/lock.h. Get rid of all the ifdefs around "maybe we don't have it". Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 12010aa commit f12fb73

File tree

10 files changed

+1
-48
lines changed

10 files changed

+1
-48
lines changed

arch/alpha/include/asm/bitops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
305305

306306
return (old & BIT(7)) != 0;
307307
}
308-
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
309308

310309
/*
311310
* ffz = Find First Zero in word. Undefined if no zero exists,

arch/m68k/include/asm/bitops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
339339
return result;
340340
#endif
341341
}
342-
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
343342

344343
/*
345344
* The true 68020 and more advanced processors support the "bfffo"

arch/mips/include/asm/bitops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
301301

302302
return res;
303303
}
304-
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
305304

306305
#undef __bit_op
307306
#undef __test_bit_op

arch/riscv/include/asm/bitops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
202202
: "memory");
203203
return (res & BIT(7)) != 0;
204204
}
205-
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
206205

207206
#undef __test_and_op_bit
208207
#undef __op_bit

include/asm-generic/bitops/instrumented-lock.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ static inline bool test_and_set_bit_lock(long nr, volatile unsigned long *addr)
5858
return arch_test_and_set_bit_lock(nr, addr);
5959
}
6060

61-
#if defined(arch_xor_unlock_is_negative_byte)
6261
/**
6362
* xor_unlock_is_negative_byte - XOR a single byte in memory and test if
6463
* it is negative, for unlock.
@@ -80,8 +79,4 @@ static inline bool xor_unlock_is_negative_byte(unsigned long mask,
8079
instrument_atomic_write(addr, sizeof(long));
8180
return arch_xor_unlock_is_negative_byte(mask, addr);
8281
}
83-
/* Let everybody know we have it. */
84-
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
85-
#endif
86-
8782
#endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_LOCK_H */

include/asm-generic/bitops/lock.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,
7575
old = raw_atomic_long_fetch_xor_release(mask, (atomic_long_t *)p);
7676
return !!(old & BIT(7));
7777
}
78-
#define arch_xor_unlock_is_negative_byte arch_xor_unlock_is_negative_byte
7978
#endif
8079

8180
#include <asm-generic/bitops/instrumented-lock.h>

kernel/kcsan/kcsan_test.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,9 @@ static void test_barrier_nothreads(struct kunit *test)
699699
KCSAN_EXPECT_RW_BARRIER(spin_unlock(&test_spinlock), true);
700700
KCSAN_EXPECT_RW_BARRIER(mutex_lock(&test_mutex), false);
701701
KCSAN_EXPECT_RW_BARRIER(mutex_unlock(&test_mutex), true);
702-
703-
#ifdef xor_unlock_is_negative_byte
704702
KCSAN_EXPECT_READ_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true);
705703
KCSAN_EXPECT_WRITE_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true);
706704
KCSAN_EXPECT_RW_BARRIER(xor_unlock_is_negative_byte(1, &test_var), true);
707-
#endif
708705
kcsan_nestable_atomic_end();
709706
}
710707

kernel/kcsan/selftest.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,9 @@ static bool __init test_barrier(void)
227227
KCSAN_CHECK_RW_BARRIER(arch_spin_unlock(&arch_spinlock));
228228
spin_lock(&test_spinlock);
229229
KCSAN_CHECK_RW_BARRIER(spin_unlock(&test_spinlock));
230-
231-
#ifdef xor_unlock_is_negative_byte
232230
KCSAN_CHECK_RW_BARRIER(xor_unlock_is_negative_byte(1, &test_var));
233231
KCSAN_CHECK_READ_BARRIER(xor_unlock_is_negative_byte(1, &test_var));
234232
KCSAN_CHECK_WRITE_BARRIER(xor_unlock_is_negative_byte(1, &test_var));
235-
#endif
236233
kcsan_nestable_atomic_end();
237234

238235
return ret;

mm/filemap.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,34 +1482,6 @@ void folio_add_wait_queue(struct folio *folio, wait_queue_entry_t *waiter)
14821482
}
14831483
EXPORT_SYMBOL_GPL(folio_add_wait_queue);
14841484

1485-
#ifdef xor_unlock_is_negative_byte
1486-
#define clear_bit_unlock_is_negative_byte(nr, p) \
1487-
xor_unlock_is_negative_byte(1 << nr, p)
1488-
#endif
1489-
1490-
#ifndef clear_bit_unlock_is_negative_byte
1491-
1492-
/*
1493-
* PG_waiters is the high bit in the same byte as PG_lock.
1494-
*
1495-
* On x86 (and on many other architectures), we can clear PG_lock and
1496-
* test the sign bit at the same time. But if the architecture does
1497-
* not support that special operation, we just do this all by hand
1498-
* instead.
1499-
*
1500-
* The read of PG_waiters has to be after (or concurrently with) PG_locked
1501-
* being cleared, but a memory barrier should be unnecessary since it is
1502-
* in the same byte as PG_locked.
1503-
*/
1504-
static inline bool clear_bit_unlock_is_negative_byte(long nr, volatile void *mem)
1505-
{
1506-
clear_bit_unlock(nr, mem);
1507-
/* smp_mb__after_atomic(); */
1508-
return test_bit(PG_waiters, mem);
1509-
}
1510-
1511-
#endif
1512-
15131485
/**
15141486
* folio_unlock - Unlock a locked folio.
15151487
* @folio: The folio.
@@ -1525,7 +1497,7 @@ void folio_unlock(struct folio *folio)
15251497
BUILD_BUG_ON(PG_waiters != 7);
15261498
BUILD_BUG_ON(PG_locked > 7);
15271499
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
1528-
if (clear_bit_unlock_is_negative_byte(PG_locked, folio_flags(folio, 0)))
1500+
if (xor_unlock_is_negative_byte(1 << PG_locked, folio_flags(folio, 0)))
15291501
folio_wake_bit(folio, PG_locked);
15301502
}
15311503
EXPORT_SYMBOL(folio_unlock);

mm/kasan/kasan_test.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,9 @@ static void kasan_bitops_test_and_modify(struct kunit *test, int nr, void *addr)
10981098
KUNIT_EXPECT_KASAN_FAIL(test, test_and_change_bit(nr, addr));
10991099
KUNIT_EXPECT_KASAN_FAIL(test, __test_and_change_bit(nr, addr));
11001100
KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = test_bit(nr, addr));
1101-
1102-
#if defined(xor_unlock_is_negative_byte)
11031101
if (nr < 7)
11041102
KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result =
11051103
xor_unlock_is_negative_byte(1 << nr, addr));
1106-
#endif
11071104
}
11081105

11091106
static void kasan_bitops_generic(struct kunit *test)

0 commit comments

Comments
 (0)