From: Ben Hutchings <ben@decadent.org.uk>
To: stable@vger.kernel.org
Cc: Lee Jones <lee.jones@linaro.org>,
"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH 02/13] futex,rt_mutex: Introduce rt_mutex_init_waiter()
Date: Sun, 28 Mar 2021 22:41:33 +0200 [thread overview]
Message-ID: <YGDp/WL8DllYuErc@decadent.org.uk> (raw)
In-Reply-To: <YGDp1qJOCUJmE1Ty@decadent.org.uk>
[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]
From: Peter Zijlstra <peterz@infradead.org>
commit 50809358dd7199aa7ce232f6877dd09ec30ef374 upstream.
Since there's already two copies of this code, introduce a helper now
before adding a third one.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: xlpang@redhat.com
Cc: rostedt@goodmis.org
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: dvhart@infradead.org
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170322104151.950039479@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bwh: Backported to 4.9: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
kernel/futex.c | 5 +----
kernel/locking/rtmutex.c | 12 +++++++++---
kernel/locking/rtmutex_common.h | 1 +
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index e112a9d4c84f..cd8a9abadd69 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3234,10 +3234,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
* The waiter is allocated on our stack, manipulated by the requeue
* code while we sleep on uaddr.
*/
- debug_rt_mutex_init_waiter(&rt_waiter);
- RB_CLEAR_NODE(&rt_waiter.pi_tree_entry);
- RB_CLEAR_NODE(&rt_waiter.tree_entry);
- rt_waiter.task = NULL;
+ rt_mutex_init_waiter(&rt_waiter);
ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE);
if (unlikely(ret != 0))
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 6ff4156b3929..873c8c800e00 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1176,6 +1176,14 @@ void rt_mutex_adjust_pi(struct task_struct *task)
next_lock, NULL, task);
}
+void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
+{
+ debug_rt_mutex_init_waiter(waiter);
+ RB_CLEAR_NODE(&waiter->pi_tree_entry);
+ RB_CLEAR_NODE(&waiter->tree_entry);
+ waiter->task = NULL;
+}
+
/**
* __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop
* @lock: the rt_mutex to take
@@ -1258,9 +1266,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
unsigned long flags;
int ret = 0;
- debug_rt_mutex_init_waiter(&waiter);
- RB_CLEAR_NODE(&waiter.pi_tree_entry);
- RB_CLEAR_NODE(&waiter.tree_entry);
+ rt_mutex_init_waiter(&waiter);
/*
* Technically we could use raw_spin_[un]lock_irq() here, but this can
diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h
index bea5d677fe34..ba465c0192f3 100644
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
@@ -103,6 +103,7 @@ extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
struct task_struct *proxy_owner);
extern void rt_mutex_proxy_unlock(struct rt_mutex *lock);
+extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter);
extern int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
struct rt_mutex_waiter *waiter,
struct task_struct *task);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-03-28 20:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-28 20:40 [PATCH 01/13] futex: Use smp_store_release() in mark_wake_futex() Ben Hutchings
2021-03-28 20:41 ` Ben Hutchings [this message]
2021-03-28 20:41 ` [PATCH 03/13] futex: Rework futex_lock_pi() to use rt_mutex_*_proxy_lock() Ben Hutchings
2021-03-28 20:41 ` [PATCH 04/13] futex: Drop hb->lock before enqueueing on the rtmutex Ben Hutchings
2021-03-28 20:42 ` [PATCH 05/13] futex: Avoid freeing an active timer Ben Hutchings
2021-03-28 20:42 ` [PATCH 06/13] futex,rt_mutex: Fix rt_mutex_cleanup_proxy_lock() Ben Hutchings
2021-03-28 20:42 ` [PATCH 07/13] futex: Handle early deadlock return correctly Ben Hutchings
2021-03-28 20:42 ` [PATCH 08/13] futex: Fix (possible) missed wakeup Ben Hutchings
2021-03-28 20:42 ` [PATCH 09/13] locking/futex: Allow low-level atomic operations to return -EAGAIN Ben Hutchings
2021-03-28 20:42 ` [PATCH 10/13] arm64: futex: Bound number of LDXR/STXR loops in FUTEX_WAKE_OP Ben Hutchings
2021-03-28 20:42 ` [PATCH 11/13] futex: Prevent robust futex exit race Ben Hutchings
2021-03-28 20:43 ` [PATCH 12/13] futex: Fix incorrect should_fail_futex() handling Ben Hutchings
2021-03-28 20:43 ` [PATCH 13/13] futex: Handle transient "ownerless" rtmutex state correctly Ben Hutchings
2021-03-29 5:50 ` [PATCH 01/13] futex: Use smp_store_release() in mark_wake_futex() Greg KH
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=YGDp/WL8DllYuErc@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=f.fainelli@gmail.com \
--cc=lee.jones@linaro.org \
--cc=lgoncalv@redhat.com \
--cc=stable@vger.kernel.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