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

six locks: Single instance of six_lock_vals

Since we're not generating different versions of the lock functions for
each lock type, the constant propagation we were trying to do before is
no longer useful - this is now a small code size decrease.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+20 -25
+20 -25
fs/bcachefs/six.c
··· 70 70 enum six_lock_type unlock_wakeup; 71 71 }; 72 72 73 - #define LOCK_VALS { \ 74 - [SIX_LOCK_read] = { \ 75 - .lock_val = 1ULL << SIX_STATE_READ_OFFSET, \ 76 - .lock_fail = SIX_LOCK_HELD_write, \ 77 - .held_mask = SIX_LOCK_HELD_read, \ 78 - .unlock_wakeup = SIX_LOCK_write, \ 79 - }, \ 80 - [SIX_LOCK_intent] = { \ 81 - .lock_val = SIX_STATE_INTENT_HELD, \ 82 - .lock_fail = SIX_LOCK_HELD_intent, \ 83 - .held_mask = SIX_LOCK_HELD_intent, \ 84 - .unlock_wakeup = SIX_LOCK_intent, \ 85 - }, \ 86 - [SIX_LOCK_write] = { \ 87 - .lock_val = SIX_LOCK_HELD_write, \ 88 - .lock_fail = SIX_LOCK_HELD_read, \ 89 - .held_mask = SIX_LOCK_HELD_write, \ 90 - .unlock_wakeup = SIX_LOCK_read, \ 91 - }, \ 92 - } 73 + static const struct six_lock_vals l[] = { 74 + [SIX_LOCK_read] = { 75 + .lock_val = 1ULL << SIX_STATE_READ_OFFSET, 76 + .lock_fail = SIX_LOCK_HELD_write, 77 + .held_mask = SIX_LOCK_HELD_read, 78 + .unlock_wakeup = SIX_LOCK_write, 79 + }, 80 + [SIX_LOCK_intent] = { 81 + .lock_val = SIX_STATE_INTENT_HELD, 82 + .lock_fail = SIX_LOCK_HELD_intent, 83 + .held_mask = SIX_LOCK_HELD_intent, 84 + .unlock_wakeup = SIX_LOCK_intent, 85 + }, 86 + [SIX_LOCK_write] = { 87 + .lock_val = SIX_LOCK_HELD_write, 88 + .lock_fail = SIX_LOCK_HELD_read, 89 + .held_mask = SIX_LOCK_HELD_write, 90 + .unlock_wakeup = SIX_LOCK_read, 91 + }, 92 + }; 93 93 94 94 static inline u32 six_state_seq(u64 state) 95 95 { ··· 144 144 static int __do_six_trylock(struct six_lock *lock, enum six_lock_type type, 145 145 struct task_struct *task, bool try) 146 146 { 147 - const struct six_lock_vals l[] = LOCK_VALS; 148 147 int ret; 149 148 u64 old, new, v; 150 149 ··· 624 625 __always_inline 625 626 static void do_six_unlock_type(struct six_lock *lock, enum six_lock_type type) 626 627 { 627 - const struct six_lock_vals l[] = LOCK_VALS; 628 628 u64 state; 629 629 630 630 if (type == SIX_LOCK_intent) ··· 710 712 */ 711 713 bool six_lock_tryupgrade(struct six_lock *lock) 712 714 { 713 - const struct six_lock_vals l[] = LOCK_VALS; 714 715 u64 old, new, v = atomic64_read(&lock->state); 715 716 716 717 do { ··· 777 780 */ 778 781 void six_lock_increment(struct six_lock *lock, enum six_lock_type type) 779 782 { 780 - const struct six_lock_vals l[] = LOCK_VALS; 781 - 782 783 six_acquire(&lock->dep_map, 0, type == SIX_LOCK_read, _RET_IP_); 783 784 784 785 /* XXX: assert already locked, and that we don't overflow: */