aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2018-04-05 03:20:34 -0400
committerIngo Molnar <mingo@kernel.org>2018-04-05 03:20:34 -0400
commitea2a6af517714c52a1209795a03e863e96b460bb (patch)
tree3bd443bc9b23ceeaf3743eaf2d6d35ec63c620c9 /kernel/locking
parent1b5d43cfb69759d8ef8d30469cea31d0c037aed5 (diff)
parent642e7fd23353e22290e3d51719fcb658dc252342 (diff)
Merge branch 'linus' into sched/urgent, to pick up fixes and updates
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/lockdep.c26
-rw-r--r--kernel/locking/rtmutex.c3
-rw-r--r--kernel/locking/rtmutex_common.h11
-rw-r--r--kernel/locking/rwsem.c4
-rw-r--r--kernel/locking/rwsem.h8
5 files changed, 31 insertions, 21 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 89b5f83f1969..023386338269 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -556,9 +556,9 @@ static void print_lock(struct held_lock *hlock)
556 return; 556 return;
557 } 557 }
558 558
559 printk(KERN_CONT "%p", hlock->instance);
559 print_lock_name(lock_classes + class_idx - 1); 560 print_lock_name(lock_classes + class_idx - 1);
560 printk(KERN_CONT ", at: [<%p>] %pS\n", 561 printk(KERN_CONT ", at: %pS\n", (void *)hlock->acquire_ip);
561 (void *)hlock->acquire_ip, (void *)hlock->acquire_ip);
562} 562}
563 563
564static void lockdep_print_held_locks(struct task_struct *curr) 564static void lockdep_print_held_locks(struct task_struct *curr)
@@ -808,7 +808,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
808 if (verbose(class)) { 808 if (verbose(class)) {
809 graph_unlock(); 809 graph_unlock();
810 810
811 printk("\nnew class %p: %s", class->key, class->name); 811 printk("\nnew class %px: %s", class->key, class->name);
812 if (class->name_version > 1) 812 if (class->name_version > 1)
813 printk(KERN_CONT "#%d", class->name_version); 813 printk(KERN_CONT "#%d", class->name_version);
814 printk(KERN_CONT "\n"); 814 printk(KERN_CONT "\n");
@@ -1407,7 +1407,7 @@ static void print_lock_class_header(struct lock_class *class, int depth)
1407 } 1407 }
1408 printk("%*s }\n", depth, ""); 1408 printk("%*s }\n", depth, "");
1409 1409
1410 printk("%*s ... key at: [<%p>] %pS\n", 1410 printk("%*s ... key at: [<%px>] %pS\n",
1411 depth, "", class->key, class->key); 1411 depth, "", class->key, class->key);
1412} 1412}
1413 1413
@@ -2340,7 +2340,7 @@ cache_hit:
2340 2340
2341 if (very_verbose(class)) { 2341 if (very_verbose(class)) {
2342 printk("\nhash chain already cached, key: " 2342 printk("\nhash chain already cached, key: "
2343 "%016Lx tail class: [%p] %s\n", 2343 "%016Lx tail class: [%px] %s\n",
2344 (unsigned long long)chain_key, 2344 (unsigned long long)chain_key,
2345 class->key, class->name); 2345 class->key, class->name);
2346 } 2346 }
@@ -2349,7 +2349,7 @@ cache_hit:
2349 } 2349 }
2350 2350
2351 if (very_verbose(class)) { 2351 if (very_verbose(class)) {
2352 printk("\nnew hash chain, key: %016Lx tail class: [%p] %s\n", 2352 printk("\nnew hash chain, key: %016Lx tail class: [%px] %s\n",
2353 (unsigned long long)chain_key, class->key, class->name); 2353 (unsigned long long)chain_key, class->key, class->name);
2354 } 2354 }
2355 2355
@@ -2676,16 +2676,16 @@ check_usage_backwards(struct task_struct *curr, struct held_lock *this,
2676void print_irqtrace_events(struct task_struct *curr) 2676void print_irqtrace_events(struct task_struct *curr)
2677{ 2677{
2678 printk("irq event stamp: %u\n", curr->irq_events); 2678 printk("irq event stamp: %u\n", curr->irq_events);
2679 printk("hardirqs last enabled at (%u): [<%p>] %pS\n", 2679 printk("hardirqs last enabled at (%u): [<%px>] %pS\n",
2680 curr->hardirq_enable_event, (void *)curr->hardirq_enable_ip, 2680 curr->hardirq_enable_event, (void *)curr->hardirq_enable_ip,
2681 (void *)curr->hardirq_enable_ip); 2681 (void *)curr->hardirq_enable_ip);
2682 printk("hardirqs last disabled at (%u): [<%p>] %pS\n", 2682 printk("hardirqs last disabled at (%u): [<%px>] %pS\n",
2683 curr->hardirq_disable_event, (void *)curr->hardirq_disable_ip, 2683 curr->hardirq_disable_event, (void *)curr->hardirq_disable_ip,
2684 (void *)curr->hardirq_disable_ip); 2684 (void *)curr->hardirq_disable_ip);
2685 printk("softirqs last enabled at (%u): [<%p>] %pS\n", 2685 printk("softirqs last enabled at (%u): [<%px>] %pS\n",
2686 curr->softirq_enable_event, (void *)curr->softirq_enable_ip, 2686 curr->softirq_enable_event, (void *)curr->softirq_enable_ip,
2687 (void *)curr->softirq_enable_ip); 2687 (void *)curr->softirq_enable_ip);
2688 printk("softirqs last disabled at (%u): [<%p>] %pS\n", 2688 printk("softirqs last disabled at (%u): [<%px>] %pS\n",
2689 curr->softirq_disable_event, (void *)curr->softirq_disable_ip, 2689 curr->softirq_disable_event, (void *)curr->softirq_disable_ip,
2690 (void *)curr->softirq_disable_ip); 2690 (void *)curr->softirq_disable_ip);
2691} 2691}
@@ -3207,7 +3207,7 @@ static void __lockdep_init_map(struct lockdep_map *lock, const char *name,
3207 * Sanity check, the lock-class key must be persistent: 3207 * Sanity check, the lock-class key must be persistent:
3208 */ 3208 */
3209 if (!static_obj(key)) { 3209 if (!static_obj(key)) {
3210 printk("BUG: key %p not in .data!\n", key); 3210 printk("BUG: key %px not in .data!\n", key);
3211 /* 3211 /*
3212 * What it says above ^^^^^, I suggest you read it. 3212 * What it says above ^^^^^, I suggest you read it.
3213 */ 3213 */
@@ -3322,7 +3322,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
3322 } 3322 }
3323 atomic_inc((atomic_t *)&class->ops); 3323 atomic_inc((atomic_t *)&class->ops);
3324 if (very_verbose(class)) { 3324 if (very_verbose(class)) {
3325 printk("\nacquire class [%p] %s", class->key, class->name); 3325 printk("\nacquire class [%px] %s", class->key, class->name);
3326 if (class->name_version > 1) 3326 if (class->name_version > 1)
3327 printk(KERN_CONT "#%d", class->name_version); 3327 printk(KERN_CONT "#%d", class->name_version);
3328 printk(KERN_CONT "\n"); 3328 printk(KERN_CONT "\n");
@@ -4376,7 +4376,7 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
4376 pr_warn("WARNING: held lock freed!\n"); 4376 pr_warn("WARNING: held lock freed!\n");
4377 print_kernel_ident(); 4377 print_kernel_ident();
4378 pr_warn("-------------------------\n"); 4378 pr_warn("-------------------------\n");
4379 pr_warn("%s/%d is freeing memory %p-%p, with a lock still held there!\n", 4379 pr_warn("%s/%d is freeing memory %px-%px, with a lock still held there!\n",
4380 curr->comm, task_pid_nr(curr), mem_from, mem_to-1); 4380 curr->comm, task_pid_nr(curr), mem_from, mem_to-1);
4381 print_lock(hlock); 4381 print_lock(hlock);
4382 lockdep_print_held_locks(curr); 4382 lockdep_print_held_locks(curr);
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 940633c63254..4f014be7a4b8 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1268,8 +1268,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
1268 1268
1269 if (unlikely(ret)) { 1269 if (unlikely(ret)) {
1270 __set_current_state(TASK_RUNNING); 1270 __set_current_state(TASK_RUNNING);
1271 if (rt_mutex_has_waiters(lock)) 1271 remove_waiter(lock, &waiter);
1272 remove_waiter(lock, &waiter);
1273 rt_mutex_handle_deadlock(ret, chwalk, &waiter); 1272 rt_mutex_handle_deadlock(ret, chwalk, &waiter);
1274 } 1273 }
1275 1274
diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h
index 68686b3ec3c1..d1d62f942be2 100644
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -52,12 +52,13 @@ static inline int rt_mutex_has_waiters(struct rt_mutex *lock)
52static inline struct rt_mutex_waiter * 52static inline struct rt_mutex_waiter *
53rt_mutex_top_waiter(struct rt_mutex *lock) 53rt_mutex_top_waiter(struct rt_mutex *lock)
54{ 54{
55 struct rt_mutex_waiter *w; 55 struct rb_node *leftmost = rb_first_cached(&lock->waiters);
56 56 struct rt_mutex_waiter *w = NULL;
57 w = rb_entry(lock->waiters.rb_leftmost,
58 struct rt_mutex_waiter, tree_entry);
59 BUG_ON(w->lock != lock);
60 57
58 if (leftmost) {
59 w = rb_entry(leftmost, struct rt_mutex_waiter, tree_entry);
60 BUG_ON(w->lock != lock);
61 }
61 return w; 62 return w;
62} 63}
63 64
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index f549c552dbf1..30465a2f2b6c 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -117,6 +117,7 @@ EXPORT_SYMBOL(down_write_trylock);
117void up_read(struct rw_semaphore *sem) 117void up_read(struct rw_semaphore *sem)
118{ 118{
119 rwsem_release(&sem->dep_map, 1, _RET_IP_); 119 rwsem_release(&sem->dep_map, 1, _RET_IP_);
120 DEBUG_RWSEMS_WARN_ON(sem->owner != RWSEM_READER_OWNED);
120 121
121 __up_read(sem); 122 __up_read(sem);
122} 123}
@@ -129,6 +130,7 @@ EXPORT_SYMBOL(up_read);
129void up_write(struct rw_semaphore *sem) 130void up_write(struct rw_semaphore *sem)
130{ 131{
131 rwsem_release(&sem->dep_map, 1, _RET_IP_); 132 rwsem_release(&sem->dep_map, 1, _RET_IP_);
133 DEBUG_RWSEMS_WARN_ON(sem->owner != current);
132 134
133 rwsem_clear_owner(sem); 135 rwsem_clear_owner(sem);
134 __up_write(sem); 136 __up_write(sem);
@@ -142,6 +144,7 @@ EXPORT_SYMBOL(up_write);
142void downgrade_write(struct rw_semaphore *sem) 144void downgrade_write(struct rw_semaphore *sem)
143{ 145{
144 lock_downgrade(&sem->dep_map, _RET_IP_); 146 lock_downgrade(&sem->dep_map, _RET_IP_);
147 DEBUG_RWSEMS_WARN_ON(sem->owner != current);
145 148
146 rwsem_set_reader_owned(sem); 149 rwsem_set_reader_owned(sem);
147 __downgrade_write(sem); 150 __downgrade_write(sem);
@@ -211,6 +214,7 @@ EXPORT_SYMBOL(down_write_killable_nested);
211 214
212void up_read_non_owner(struct rw_semaphore *sem) 215void up_read_non_owner(struct rw_semaphore *sem)
213{ 216{
217 DEBUG_RWSEMS_WARN_ON(sem->owner != RWSEM_READER_OWNED);
214 __up_read(sem); 218 __up_read(sem);
215} 219}
216 220
diff --git a/kernel/locking/rwsem.h b/kernel/locking/rwsem.h
index a883b8f1fdc6..a17cba8d94bb 100644
--- a/kernel/locking/rwsem.h
+++ b/kernel/locking/rwsem.h
@@ -16,6 +16,12 @@
16 */ 16 */
17#define RWSEM_READER_OWNED ((struct task_struct *)1UL) 17#define RWSEM_READER_OWNED ((struct task_struct *)1UL)
18 18
19#ifdef CONFIG_DEBUG_RWSEMS
20# define DEBUG_RWSEMS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
21#else
22# define DEBUG_RWSEMS_WARN_ON(c)
23#endif
24
19#ifdef CONFIG_RWSEM_SPIN_ON_OWNER 25#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
20/* 26/*
21 * All writes to owner are protected by WRITE_ONCE() to make sure that 27 * All writes to owner are protected by WRITE_ONCE() to make sure that
@@ -41,7 +47,7 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem)
41 * do a write to the rwsem cacheline when it is really necessary 47 * do a write to the rwsem cacheline when it is really necessary
42 * to minimize cacheline contention. 48 * to minimize cacheline contention.
43 */ 49 */
44 if (sem->owner != RWSEM_READER_OWNED) 50 if (READ_ONCE(sem->owner) != RWSEM_READER_OWNED)
45 WRITE_ONCE(sem->owner, RWSEM_READER_OWNED); 51 WRITE_ONCE(sem->owner, RWSEM_READER_OWNED);
46} 52}
47 53