Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fixes from Ingo Molnar:
"Misc fixes: lockstat fix, futex fix on !MMU systems, big endian fix
for qrwlocks and a race fix for pvqspinlocks"

* 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
locking/pvqspinlock: Fix a bug in qstat_read()
locking/pvqspinlock: Fix double hash race
locking/qrwlock: Fix write unlock bug on big endian systems
futex: Assume all mappings are private on !MMU systems

+48 -5
+25 -2
include/asm-generic/qrwlock.h
··· 25 25 #include <asm-generic/qrwlock_types.h> 26 26 27 27 /* 28 - * Writer states & reader shift and bias 28 + * Writer states & reader shift and bias. 29 + * 30 + * | +0 | +1 | +2 | +3 | 31 + * ----+----+----+----+----+ 32 + * LE | 78 | 56 | 34 | 12 | 0x12345678 33 + * ----+----+----+----+----+ 34 + * | wr | rd | 35 + * +----+----+----+----+ 36 + * 37 + * ----+----+----+----+----+ 38 + * BE | 12 | 34 | 56 | 78 | 0x12345678 39 + * ----+----+----+----+----+ 40 + * | rd | wr | 41 + * +----+----+----+----+ 29 42 */ 30 43 #define _QW_WAITING 1 /* A writer is waiting */ 31 44 #define _QW_LOCKED 0xff /* A writer holds the lock */ ··· 147 134 } 148 135 149 136 /** 137 + * __qrwlock_write_byte - retrieve the write byte address of a queue rwlock 138 + * @lock : Pointer to queue rwlock structure 139 + * Return: the write byte address of a queue rwlock 140 + */ 141 + static inline u8 *__qrwlock_write_byte(struct qrwlock *lock) 142 + { 143 + return (u8 *)lock + 3 * IS_BUILTIN(CONFIG_CPU_BIG_ENDIAN); 144 + } 145 + 146 + /** 150 147 * queued_write_unlock - release write lock of a queue rwlock 151 148 * @lock : Pointer to queue rwlock structure 152 149 */ 153 150 static inline void queued_write_unlock(struct qrwlock *lock) 154 151 { 155 - smp_store_release((u8 *)&lock->cnts, 0); 152 + smp_store_release(__qrwlock_write_byte(lock), 0); 156 153 } 157 154 158 155 /*
+22 -1
kernel/futex.c
··· 179 179 * Futex flags used to encode options to functions and preserve them across 180 180 * restarts. 181 181 */ 182 - #define FLAGS_SHARED 0x01 182 + #ifdef CONFIG_MMU 183 + # define FLAGS_SHARED 0x01 184 + #else 185 + /* 186 + * NOMMU does not have per process address space. Let the compiler optimize 187 + * code away. 188 + */ 189 + # define FLAGS_SHARED 0x00 190 + #endif 183 191 #define FLAGS_CLOCKRT 0x02 184 192 #define FLAGS_HAS_TIMEOUT 0x04 185 193 ··· 413 405 if (!key->both.ptr) 414 406 return; 415 407 408 + /* 409 + * On MMU less systems futexes are always "private" as there is no per 410 + * process address space. We need the smp wmb nevertheless - yes, 411 + * arch/blackfin has MMU less SMP ... 412 + */ 413 + if (!IS_ENABLED(CONFIG_MMU)) { 414 + smp_mb(); /* explicit smp_mb(); (B) */ 415 + return; 416 + } 417 + 416 418 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { 417 419 case FUT_OFF_INODE: 418 420 ihold(key->shared.inode); /* implies smp_mb(); (B) */ ··· 453 435 WARN_ON_ONCE(1); 454 436 return; 455 437 } 438 + 439 + if (!IS_ENABLED(CONFIG_MMU)) 440 + return; 456 441 457 442 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { 458 443 case FUT_OFF_INODE:
+1 -1
kernel/locking/qspinlock_paravirt.h
··· 450 450 goto gotlock; 451 451 } 452 452 } 453 - WRITE_ONCE(pn->state, vcpu_halted); 453 + WRITE_ONCE(pn->state, vcpu_hashed); 454 454 qstat_inc(qstat_pv_wait_head, true); 455 455 qstat_inc(qstat_pv_wait_again, waitcnt); 456 456 pv_wait(&l->locked, _Q_SLOW_VAL);
-1
kernel/locking/qspinlock_stat.h
··· 153 153 */ 154 154 if ((counter == qstat_pv_latency_kick) || 155 155 (counter == qstat_pv_latency_wake)) { 156 - stat = 0; 157 156 if (kicks) 158 157 stat = DIV_ROUND_CLOSEST_ULL(stat, kicks); 159 158 }