From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: RT-users <linux-rt-users@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Sebastian Siewior <bigeasy@linutronix.de>,
Julia Cartwright <julia@ni.com>, Wargreen <wargreen@lebib.org>
Subject: [patch RT 2/4] rtmutex: Provide rt_mutex_lock_state()
Date: Sat, 01 Apr 2017 12:51:00 +0200 [thread overview]
Message-ID: <20170401112758.130515859@linutronix.de> (raw)
In-Reply-To: 20170401105058.958246042@linutronix.de
[-- Attachment #1: rtmutex-Provide-rt_mutex_lock_state-.patch --]
[-- Type: text/plain, Size: 3009 bytes --]
Allow rtmutex to be locked with arbitrary states. Preparatory patch for the
rt rwsem rework.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/rtmutex.h | 1 +
kernel/locking/rtmutex.c | 44 +++++++++++++++++++++++++-------------------
2 files changed, 26 insertions(+), 19 deletions(-)
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -105,6 +105,7 @@ extern void __rt_mutex_init(struct rt_mu
extern void rt_mutex_destroy(struct rt_mutex *lock);
extern void rt_mutex_lock(struct rt_mutex *lock);
+extern int rt_mutex_lock_state(struct rt_mutex *lock, int state);
extern int rt_mutex_lock_interruptible(struct rt_mutex *lock);
extern int rt_mutex_lock_killable(struct rt_mutex *lock);
extern int rt_mutex_timed_lock(struct rt_mutex *lock,
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -2011,21 +2011,32 @@ rt_mutex_fastunlock(struct rt_mutex *loc
}
/**
+ * rt_mutex_lock_state - lock a rt_mutex with a given state
+ *
+ * @lock: The rt_mutex to be locked
+ * @state: The state to set when blocking on the rt_mutex
+ */
+int __sched rt_mutex_lock_state(struct rt_mutex *lock, int state)
+{
+ might_sleep();
+
+ return rt_mutex_fastlock(lock, state, NULL, rt_mutex_slowlock);
+}
+
+/**
* rt_mutex_lock - lock a rt_mutex
*
* @lock: the rt_mutex to be locked
*/
void __sched rt_mutex_lock(struct rt_mutex *lock)
{
- might_sleep();
-
- rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, NULL, rt_mutex_slowlock);
+ rt_mutex_lock_state(lock, TASK_UNINTERRUPTIBLE);
}
EXPORT_SYMBOL_GPL(rt_mutex_lock);
/**
* rt_mutex_lock_interruptible - lock a rt_mutex interruptible
- *
+ **
* @lock: the rt_mutex to be locked
*
* Returns:
@@ -2034,20 +2045,10 @@ EXPORT_SYMBOL_GPL(rt_mutex_lock);
*/
int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock)
{
- might_sleep();
-
- return rt_mutex_fastlock(lock, TASK_INTERRUPTIBLE, NULL, rt_mutex_slowlock);
+ return rt_mutex_lock_state(lock, TASK_INTERRUPTIBLE);
}
EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible);
-/*
- * Futex variant, must not use fastpath.
- */
-int __sched rt_mutex_futex_trylock(struct rt_mutex *lock)
-{
- return rt_mutex_slowtrylock(lock);
-}
-
/**
* rt_mutex_lock_killable - lock a rt_mutex killable
*
@@ -2057,16 +2058,21 @@ int __sched rt_mutex_futex_trylock(struc
* Returns:
* 0 on success
* -EINTR when interrupted by a signal
- * -EDEADLK when the lock would deadlock (when deadlock detection is on)
*/
int __sched rt_mutex_lock_killable(struct rt_mutex *lock)
{
- might_sleep();
-
- return rt_mutex_fastlock(lock, TASK_KILLABLE, NULL, rt_mutex_slowlock);
+ return rt_mutex_lock_state(lock, TASK_KILLABLE);
}
EXPORT_SYMBOL_GPL(rt_mutex_lock_killable);
+/*
+ * Futex variant, must not use fastpath.
+ */
+int __sched rt_mutex_futex_trylock(struct rt_mutex *lock)
+{
+ return rt_mutex_slowtrylock(lock);
+}
+
/**
* rt_mutex_timed_lock - lock a rt_mutex interruptible
* the timeout structure is provided
next prev parent reply other threads:[~2017-04-01 10:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 10:50 [patch RT 0/4] rwsem/rt: Lift the single reader restriction Thomas Gleixner
2017-04-01 10:50 ` [patch RT 1/4] rtmutex: Make lock_killable work Thomas Gleixner
2017-04-03 15:21 ` Steven Rostedt
2017-04-04 7:13 ` Peter Zijlstra
2017-04-04 13:20 ` Steven Rostedt
2017-04-01 10:51 ` Thomas Gleixner [this message]
2017-04-01 10:51 ` [patch RT 3/4] rtmutex: Provide locked slowpath Thomas Gleixner
2017-04-01 10:51 ` [patch RT 4/4] rwsem/rt: Lift single reader restriction Thomas Gleixner
2017-04-04 14:01 ` [patch RT 0/4] rwsem/rt: Lift the " Sebastian Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170401112758.130515859@linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=julia@ni.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=wargreen@lebib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).