summaryrefslogtreecommitdiffstats
path: root/sched.h-make-kernel_sem-a-mutex.patch
blob: 17812fb0ef6673ca1c13ed0389dae890fcc8d849 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From 267ce968b183a0144e4864b84db7c0e36c7eb4d5 Mon Sep 17 00:00:00 2001
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Sun, 23 Jan 2011 13:10:12 -0500
Subject: [PATCH] sched.h: make kernel_sem a mutex

Also change all of its users.

This is one of several extractions from the merge up to 33-rc8.

See it in a git tip repo with:

   git diff 5f854cfc024622e4aae14d7cf422f6ff86278688^2 \
	5f854cfc024622e4aae14d7cf422f6ff86278688 \
	include/linux/sched.h

and similar for the other two files.

You can find the origin of this change in the tip merge commit:

     commit 5f854cfc024622e4aae14d7cf422f6ff86278688
     Merge: cc24da0 4ec62b2
     Author: Thomas Gleixner <tglx@linutronix.de>
     Date:   Sun Feb 21 20:17:22 2010 +0100

         Forward to 2.6.33-rc8

         Merge branch 'linus' into rt/head with a pile of conflicts.

         Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Normally there are not significant changes/additions in a merge commit that
are not from any other "normal" commit.  But in this case there are, so
break them out into separate explicit commits.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 include/linux/sched.h |    3 ++-
 kernel/rtmutex.c      |    4 ++--
 lib/kernel_lock.c     |   12 ++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index b515f13..e4b6a93 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -186,7 +186,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 {
 }
 #endif
-extern struct semaphore kernel_sem;
+
+extern struct mutex kernel_sem;
 
 /*
  * Task state bitmask. NOTE! These bits are also
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index ec2273b..16bfa1c 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -1028,7 +1028,7 @@ static inline int rt_release_bkl(struct rt_mutex *lock, unsigned long flags)
 	fixup_rt_mutex_waiters(lock);
 	raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
 
-	up(&kernel_sem);
+	mutex_unlock(&kernel_sem);
 
 	raw_spin_lock_irq(&lock->wait_lock);
 #endif
@@ -1038,7 +1038,7 @@ static inline int rt_release_bkl(struct rt_mutex *lock, unsigned long flags)
 static inline void rt_reacquire_bkl(int saved_lock_depth)
 {
 #ifdef CONFIG_LOCK_KERNEL
-	down(&kernel_sem);
+	mutex_lock(&kernel_sem);
 	current->lock_depth = saved_lock_depth;
 #endif
 }
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c
index a77306a..bc62ed8 100644
--- a/lib/kernel_lock.c
+++ b/lib/kernel_lock.c
@@ -7,7 +7,7 @@
  */
 #include <linux/module.h>
 #include <linux/kallsyms.h>
-#include <linux/semaphore.h>
+#include <linux/mutex.h>
 #include <linux/smp_lock.h>
 
 #define CREATE_TRACE_POINTS
@@ -27,7 +27,7 @@
  *
  * Don't use in new code.
  */
-struct semaphore kernel_sem;
+DEFINE_MUTEX(kernel_sem);
 
 /*
  * Re-acquire the kernel semaphore.
@@ -50,7 +50,7 @@ int __lockfunc __reacquire_kernel_lock(void)
 	current->lock_depth = -1;
 	local_irq_enable();
 
-	down(&kernel_sem);
+	mutex_lock(&kernel_sem);
 
 	local_irq_disable();
 	current->lock_depth = saved_lock_depth;
@@ -60,7 +60,7 @@ int __lockfunc __reacquire_kernel_lock(void)
 
 void __lockfunc __release_kernel_lock(void)
 {
-	up(&kernel_sem);
+	mutex_unlock(&kernel_sem);
 }
 
 /*
@@ -77,7 +77,7 @@ void __lockfunc _lock_kernel(const char *func, const char *file, int line)
 		/*
 		 * No recursion worries - we set up lock_depth _after_
 		 */
-		down(&kernel_sem);
+		mutex_lock(&kernel_sem);
 #ifdef CONFIG_DEBUG_RT_MUTEXES
 		current->last_kernel_lock = __builtin_return_address(0);
 #endif
@@ -94,7 +94,7 @@ void __lockfunc _unlock_kernel(const char *func, const char *file, int line)
 #ifdef CONFIG_DEBUG_RT_MUTEXES
 		current->last_kernel_lock = NULL;
 #endif
-		up(&kernel_sem);
+		mutex_unlock(&kernel_sem);
 	}
 	trace_unlock_kernel(func, file, line);
 }
-- 
1.7.0.4