lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 13 Jul 2021 17:11:27 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Will Deacon <will@...nel.org>,
        Waiman Long <longman@...hat.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Davidlohr Bueso <dave@...olabs.net>
Subject: [patch 33/50] locking/mutex: Introduce _mutex_t

From: Thomas Gleixner <tglx@...utronix.de>

PREEMPT_RT replaces 'struct mutex' with a rtmutex based variant so all
mutex operations are included into the priority inheritance scheme.

But a complete replacement of the mutex implementation would require to
reimplement ww_mutex on top of the rtmutex based variant. That has been
tried, but the outcome was suboptimal.

As ww_mutex is mostly used in DRM and the code pathes are not really
relevant to typical RT applications, it's also hard to argue for a full
reimplementation which can't even share code with the regular ww_mutex code
adding the risk of diversion and different bugs in both code bases.

The alternative solution is to make it possible to compile the ww_mutex
specific part of the regular mutex implementation as is on RT and have a
rtmutex based 'struct mutex' variant.

As the regular mutex and ww_mutex implementation are tightly coupled
(ww_mutex has a 'struct mutex' inside) and share a lot of code (ww_mutex is
mostly an extension) a simple replacement of 'struct mutex' does not work.

To solve this attach a typedef to 'struct mutex': _mutex_t

This new type is then used to replace 'struct mutex' in 'struct ww_mutex',
in a few helper functions and in the actual regular mutex code. None of the
actual usage sites of mutexes are affected.

That allows in the final step to have a RT specific 'struct mutex' and the
regular _mutex_t type.

Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
 include/linux/mutex.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 0bbc872ba72b..87dafe179ed2 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -48,7 +48,13 @@
  * - detects multi-task circular deadlocks and prints out all affected
  *   locks and tasks (and only those tasks)
  */
-struct mutex {
+
+/*
+ * Typedef _mutex_t for ww_mutex and core code to allow ww_mutex being
+ * built on the regular mutex code in RT kernels while mutex itself is
+ * substituted by a rt_mutex.
+ */
+typedef struct mutex {
 	atomic_long_t		owner;
 	raw_spinlock_t		wait_lock;
 #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
@@ -61,7 +67,7 @@ struct mutex {
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 	struct lockdep_map	dep_map;
 #endif
-};
+} _mutex_t;
 
 #ifdef CONFIG_DEBUG_MUTEXES
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ