summaryrefslogtreecommitdiffstats
path: root/rt-locks-implement-rt_downgrade_write.patch
blob: 7bd90cba1e4fa91986141747fcc0c009b52ca340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From e33d2a9f612d0a64253eb105742961048a9c448c Mon Sep 17 00:00:00 2001
From: Steven Rostedt <rostedt@goodmis.org>
Date: Fri, 3 Jul 2009 13:16:26 -0500
Subject: [PATCH] rt-locks: implement rt_downgrade_write

commit 86ed1c888ff040e26603e48ff56c163df9c2cd59 in tip.

The current code of rt_downgrade_write simply does a BUG(). There
are places in the kernel that uses this code, and will crash a runnning
preempt-rt kernel.

The rt_downgrade_write converts a rwsem held for write into a rwsem
held for read without ever releasing the semaphore. In -rt, the rwsems
are simply a mutex. There is nothing different between a rwsem held
for write, and one held for read. The difference is that one held for
read can nest.

This patch changes the BUG_ON() to simply BUG if the caller is not
the owner of the semaphore.

This patch comes from my rt-git repo, and has been tested there.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Clark Williams <clark.williams@gmail.com>
Cc: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
LKML-Reference: <alpine.DEB.2.00.0904151142420.31828@gandalf.stny.rr.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 kernel/rt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/rt.c b/kernel/rt.c
index df30930..6dd475a 100644
--- a/kernel/rt.c
+++ b/kernel/rt.c
@@ -315,7 +315,7 @@ EXPORT_SYMBOL(rt_up_read);
  */
 void  rt_downgrade_write(struct rw_semaphore *rwsem)
 {
-	BUG();
+	BUG_ON(rt_mutex_real_owner(&rwsem->lock) != current);
 }
 EXPORT_SYMBOL(rt_downgrade_write);
 
-- 
1.7.0.4