History

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

Pull locking updates from Ingo Molnar: - improve rwsem scalability - add uninitialized rwsem debugging check - reduce lockdep's stacktrace memory usage and add diagnostics - misc cleanups, code consolidation and constification * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: mutex: Fix up mutex_waiter usage locking/mutex: Use mutex flags macro instead of hard code locking/mutex: Make __mutex_owner static to mutex.c locking/qspinlock,x86: Clarify virt_spin_lock_key locking/rwsem: Check for operations on an uninitialized rwsem locking/rwsem: Make handoff writer optimistically spin on owner locking/lockdep: Report more stack trace statistics locking/lockdep: Reduce space occupied by stack traces stacktrace: Constify 'entries' arguments locking/lockdep: Make it clear that what lock_class::key points at is not modified

Linus Torvalds committed 7 years ago

Commit c7eba512 parents cc9b499 e57d14311 files · +241 −84Browse files

Showing the changes to include/linux (4 of 11 files). Show all

Unified · Split

4 files
  1. include/linux/lockdep.h +4 −7
  2. include/linux/mutex.h +3 −22
  3. include/linux/rwsem.h +10 −0
  4. include/linux/stacktrace.h +2 −2
include/linux/lockdep.h+4−7
@@ -66,10 +66,7 @@ struct lock_class_key { · 65 unmodified lines
6666
6767 extern struct lock_class_key __lockdep_no_validate__;
6868
69−struct lock_trace {
70− unsigned int nr_entries;
71− unsigned int offset;
72−};
69+struct lock_trace;
7370
7471 #define LOCKSTAT_POINTS 4
7572
@@ -97,7 +94,7 @@ struct lock_class { · 21 unmodified lines
9794 */
9895 struct list_head locks_after, locks_before;
9996
100− struct lockdep_subclass_key *key;
97+ const struct lockdep_subclass_key *key;
10198 unsigned int subclass;
10299 unsigned int dep_gen_id;
103100
@@ -105,7 +102,7 @@ struct lock_class { · 1 unmodified line
105102 * IRQ/softirq usage tracking bits:
106103 */
107104 unsigned long usage_mask;
108− struct lock_trace usage_traces[XXX_LOCK_USAGE_STATES];
105+ const struct lock_trace *usage_traces[XXX_LOCK_USAGE_STATES];
109106
110107 /*
111108 * Generation counter, when doing certain classes of graph walking,
@@ -193,7 +190,7 @@ struct lock_list { · 81 unmodified lines
193190 struct list_head entry;
194191 struct lock_class *class;
195192 struct lock_class *links_to;
196− struct lock_trace trace;
193+ const struct lock_trace *trace;
197194 int distance;
198195
199196 /*
include/linux/mutex.h+3−22
@@ -65,16 +65,6 @@ struct mutex { · 64 unmodified lines
6565 #endif
6666 };
6767
68−/*
69− * Internal helper function; C doesn't allow us to hide it :/
70− *
71− * DO NOT USE (outside of mutex code).
72− */
73−static inline struct task_struct *__mutex_owner(struct mutex *lock)
74−{
75− return (struct task_struct *)(atomic_long_read(&lock->owner) & ~0x07);
76−}
77−
7868 /*
7969 * This is the control structure for tasks blocked on mutex,
8070 * which resides on the blocked task's kernel stack:
@@ -144,10 +134,7 @@ extern void __mutex_init(struct mutex *lock, const char *name, · 63 unmodified lines
144134 *
145135 * Returns true if the mutex is locked, false if unlocked.
146136 */
147−static inline bool mutex_is_locked(struct mutex *lock)
148−{
149− return __mutex_owner(lock) != NULL;
150−}
137+extern bool mutex_is_locked(struct mutex *lock);
151138
152139 /*
153140 * See kernel/locking/mutex.c for detailed documentation of these APIs.
@@ -220,13 +207,7 @@ enum mutex_trylock_recursive_enum { · 66 unmodified lines
220207 * - MUTEX_TRYLOCK_SUCCESS - lock acquired,
221208 * - MUTEX_TRYLOCK_RECURSIVE - we already owned the lock.
222209 */
223−static inline /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
224−mutex_trylock_recursive(struct mutex *lock)
225−{
226− if (unlikely(__mutex_owner(lock) == current))
227− return MUTEX_TRYLOCK_RECURSIVE;
228−
229− return mutex_trylock(lock);
230−}
210+extern /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
211+mutex_trylock_recursive(struct mutex *lock);
231212
232213 #endif /* __LINUX_MUTEX_H */
include/linux/rwsem.h+10−0
@@ -45,6 +45,9 @@ struct rw_semaphore { · 44 unmodified lines
4545 #endif
4646 raw_spinlock_t wait_lock;
4747 struct list_head wait_list;
48+#ifdef CONFIG_DEBUG_RWSEMS
49+ void *magic;
50+#endif
4851 #ifdef CONFIG_DEBUG_LOCK_ALLOC
4952 struct lockdep_map dep_map;
5053 #endif
@@ -73,6 +76,12 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) · 22 unmodified lines
7376 # define __RWSEM_DEP_MAP_INIT(lockname)
7477 #endif
7578
79+#ifdef CONFIG_DEBUG_RWSEMS
80+# define __DEBUG_RWSEM_INITIALIZER(lockname) , .magic = &lockname
81+#else
82+# define __DEBUG_RWSEM_INITIALIZER(lockname)
83+#endif
84+
7685 #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
7786 #define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED
7887 #else
@@ -85,6 +94,7 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) · 6 unmodified lines
8594 .wait_list = LIST_HEAD_INIT((name).wait_list), \
8695 .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
8796 __RWSEM_OPT_INIT(name) \
97+ __DEBUG_RWSEM_INITIALIZER(name) \
8898 __RWSEM_DEP_MAP_INIT(name) }
8999
90100 #define DECLARE_RWSEM(name) \
include/linux/stacktrace.h+2−2
@@ -9,9 +9,9 @@ struct task_struct; · 8 unmodified lines
99 struct pt_regs;
1010
1111 #ifdef CONFIG_STACKTRACE
12−void stack_trace_print(unsigned long *trace, unsigned int nr_entries,
12+void stack_trace_print(const unsigned long *trace, unsigned int nr_entries,
1313 int spaces);
14−int stack_trace_snprint(char *buf, size_t size, unsigned long *entries,
14+int stack_trace_snprint(char *buf, size_t size, const unsigned long *entries,
1515 unsigned int nr_entries, int spaces);
1616 unsigned int stack_trace_save(unsigned long *store, unsigned int size,
1717 unsigned int skipnr);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t