aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-05-21 23:25:50 -0400
committerThomas Gleixner <tglx@linutronix.de>2014-06-21 16:05:30 -0400
commitc051b21f71d1ffdfd7ad406a1ef5ede5e5f974c5 (patch)
tree8ea9859d832e072ec2a8a4123ce46d67aec66f89 /kernel/locking
parent1ca7b86062ec8473d03c5cdfd336abc8b1c8098c (diff)
rtmutex: Confine deadlock logic to futex
The deadlock logic is only required for futexes. Remove the extra arguments for the public functions and also for the futex specific ones which get always called with deadlock detection enabled. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/rtmutex.c59
-rw-r--r--kernel/locking/rtmutex_common.h7
2 files changed, 33 insertions, 33 deletions
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 1e8fdabb19de..32906482edd1 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1228,16 +1228,15 @@ rt_mutex_slowunlock(struct rt_mutex *lock)
1228 */ 1228 */
1229static inline int 1229static inline int
1230rt_mutex_fastlock(struct rt_mutex *lock, int state, 1230rt_mutex_fastlock(struct rt_mutex *lock, int state,
1231 int detect_deadlock,
1232 int (*slowfn)(struct rt_mutex *lock, int state, 1231 int (*slowfn)(struct rt_mutex *lock, int state,
1233 struct hrtimer_sleeper *timeout, 1232 struct hrtimer_sleeper *timeout,
1234 int detect_deadlock)) 1233 int detect_deadlock))
1235{ 1234{
1236 if (!detect_deadlock && likely(rt_mutex_cmpxchg(lock, NULL, current))) { 1235 if (likely(rt_mutex_cmpxchg(lock, NULL, current))) {
1237 rt_mutex_deadlock_account_lock(lock, current); 1236 rt_mutex_deadlock_account_lock(lock, current);
1238 return 0; 1237 return 0;
1239 } else 1238 } else
1240 return slowfn(lock, state, NULL, detect_deadlock); 1239 return slowfn(lock, state, NULL, 0);
1241} 1240}
1242 1241
1243static inline int 1242static inline int
@@ -1284,54 +1283,59 @@ void __sched rt_mutex_lock(struct rt_mutex *lock)
1284{ 1283{
1285 might_sleep(); 1284 might_sleep();
1286 1285
1287 rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, 0, rt_mutex_slowlock); 1286 rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock);
1288} 1287}
1289EXPORT_SYMBOL_GPL(rt_mutex_lock); 1288EXPORT_SYMBOL_GPL(rt_mutex_lock);
1290 1289
1291/** 1290/**
1292 * rt_mutex_lock_interruptible - lock a rt_mutex interruptible 1291 * rt_mutex_lock_interruptible - lock a rt_mutex interruptible
1293 * 1292 *
1294 * @lock: the rt_mutex to be locked 1293 * @lock: the rt_mutex to be locked
1295 * @detect_deadlock: deadlock detection on/off
1296 * 1294 *
1297 * Returns: 1295 * Returns:
1298 * 0 on success 1296 * 0 on success
1299 * -EINTR when interrupted by a signal 1297 * -EINTR when interrupted by a signal
1300 * -EDEADLK when the lock would deadlock (when deadlock detection is on)
1301 */ 1298 */
1302int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock, 1299int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock)
1303 int detect_deadlock)
1304{ 1300{
1305 might_sleep(); 1301 might_sleep();
1306 1302
1307 return rt_mutex_fastlock(lock, TASK_INTERRUPTIBLE, 1303 return rt_mutex_fastlock(lock, TASK_INTERRUPTIBLE, rt_mutex_slowlock);
1308 detect_deadlock, rt_mutex_slowlock);
1309} 1304}
1310EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible); 1305EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible);
1311 1306
1307/*
1308 * Futex variant with full deadlock detection.
1309 */
1310int rt_mutex_timed_futex_lock(struct rt_mutex *lock,
1311 struct hrtimer_sleeper *timeout)
1312{
1313 might_sleep();
1314
1315 return rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout, 1,
1316 rt_mutex_slowlock);
1317}
1318
1312/** 1319/**
1313 * rt_mutex_timed_lock - lock a rt_mutex interruptible 1320 * rt_mutex_timed_lock - lock a rt_mutex interruptible
1314 * the timeout structure is provided 1321 * the timeout structure is provided
1315 * by the caller 1322 * by the caller
1316 * 1323 *
1317 * @lock: the rt_mutex to be locked 1324 * @lock: the rt_mutex to be locked
1318 * @timeout: timeout structure or NULL (no timeout) 1325 * @timeout: timeout structure or NULL (no timeout)
1319 * @detect_deadlock: deadlock detection on/off
1320 * 1326 *
1321 * Returns: 1327 * Returns:
1322 * 0 on success 1328 * 0 on success
1323 * -EINTR when interrupted by a signal 1329 * -EINTR when interrupted by a signal
1324 * -ETIMEDOUT when the timeout expired 1330 * -ETIMEDOUT when the timeout expired
1325 * -EDEADLK when the lock would deadlock (when deadlock detection is on)
1326 */ 1331 */
1327int 1332int
1328rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout, 1333rt_mutex_timed_lock(struct rt_mutex *lock, struct hrtimer_sleeper *timeout)
1329 int detect_deadlock)
1330{ 1334{
1331 might_sleep(); 1335 might_sleep();
1332 1336
1333 return rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout, 1337 return rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout, 0,
1334 detect_deadlock, rt_mutex_slowlock); 1338 rt_mutex_slowlock);
1335} 1339}
1336EXPORT_SYMBOL_GPL(rt_mutex_timed_lock); 1340EXPORT_SYMBOL_GPL(rt_mutex_timed_lock);
1337 1341
@@ -1437,7 +1441,6 @@ void rt_mutex_proxy_unlock(struct rt_mutex *lock,
1437 * @lock: the rt_mutex to take 1441 * @lock: the rt_mutex to take
1438 * @waiter: the pre-initialized rt_mutex_waiter 1442 * @waiter: the pre-initialized rt_mutex_waiter
1439 * @task: the task to prepare 1443 * @task: the task to prepare
1440 * @detect_deadlock: perform deadlock detection (1) or not (0)
1441 * 1444 *
1442 * Returns: 1445 * Returns:
1443 * 0 - task blocked on lock 1446 * 0 - task blocked on lock
@@ -1448,7 +1451,7 @@ void rt_mutex_proxy_unlock(struct rt_mutex *lock,
1448 */ 1451 */
1449int rt_mutex_start_proxy_lock(struct rt_mutex *lock, 1452int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1450 struct rt_mutex_waiter *waiter, 1453 struct rt_mutex_waiter *waiter,
1451 struct task_struct *task, int detect_deadlock) 1454 struct task_struct *task)
1452{ 1455{
1453 int ret; 1456 int ret;
1454 1457
@@ -1506,22 +1509,20 @@ struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock)
1506 * rt_mutex_finish_proxy_lock() - Complete lock acquisition 1509 * rt_mutex_finish_proxy_lock() - Complete lock acquisition
1507 * @lock: the rt_mutex we were woken on 1510 * @lock: the rt_mutex we were woken on
1508 * @to: the timeout, null if none. hrtimer should already have 1511 * @to: the timeout, null if none. hrtimer should already have
1509 * been started. 1512 * been started.
1510 * @waiter: the pre-initialized rt_mutex_waiter 1513 * @waiter: the pre-initialized rt_mutex_waiter
1511 * @detect_deadlock: perform deadlock detection (1) or not (0)
1512 * 1514 *
1513 * Complete the lock acquisition started our behalf by another thread. 1515 * Complete the lock acquisition started our behalf by another thread.
1514 * 1516 *
1515 * Returns: 1517 * Returns:
1516 * 0 - success 1518 * 0 - success
1517 * <0 - error, one of -EINTR, -ETIMEDOUT, or -EDEADLK 1519 * <0 - error, one of -EINTR, -ETIMEDOUT
1518 * 1520 *
1519 * Special API call for PI-futex requeue support 1521 * Special API call for PI-futex requeue support
1520 */ 1522 */
1521int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, 1523int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
1522 struct hrtimer_sleeper *to, 1524 struct hrtimer_sleeper *to,
1523 struct rt_mutex_waiter *waiter, 1525 struct rt_mutex_waiter *waiter)
1524 int detect_deadlock)
1525{ 1526{
1526 int ret; 1527 int ret;
1527 1528
diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h
index 7431a9c86f35..cd3ec209d0c8 100644
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -111,12 +111,11 @@ extern void rt_mutex_proxy_unlock(struct rt_mutex *lock,
111 struct task_struct *proxy_owner); 111 struct task_struct *proxy_owner);
112extern int rt_mutex_start_proxy_lock(struct rt_mutex *lock, 112extern int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
113 struct rt_mutex_waiter *waiter, 113 struct rt_mutex_waiter *waiter,
114 struct task_struct *task, 114 struct task_struct *task);
115 int detect_deadlock);
116extern int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, 115extern int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
117 struct hrtimer_sleeper *to, 116 struct hrtimer_sleeper *to,
118 struct rt_mutex_waiter *waiter, 117 struct rt_mutex_waiter *waiter);
119 int detect_deadlock); 118extern int rt_mutex_timed_futex_lock(struct rt_mutex *l, struct hrtimer_sleeper *to);
120 119
121#ifdef CONFIG_DEBUG_RT_MUTEXES 120#ifdef CONFIG_DEBUG_RT_MUTEXES
122# include "rtmutex-debug.h" 121# include "rtmutex-debug.h"