Re: [patch] Real-Time Preemption, -RT-2.6.12-rc4-V0.7.47-06

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ingo Molnar wrote:
RT semaphores have stricter semantics than Linux semaphores. One property is that there always needs to be an owner of a semaphore. If a semaphore gets initialized as init_MUTEX_LOCKED, it is a fair indication
that the semaphore is really used as a completion object - with no
stable owner.  (e.g. at insmod time when the init_MUTEX_LOCKED is done,
the insmod thread will go away after some time, leaving the semaphore
'orphaned')

Thanks for the explanation. In that case calling init_MUTEX_LOCKED on an RT semaphore is obviously wrong. However, it only produces a warning during the compilation and is guaranteed to BUG when run. It would be better if it obviously failed to compile. How about the attached patch?
That makes the compilation fail like this:

drivers/cpufreq/cpufreq.c: In function `cpufreq_add_dev':
drivers/cpufreq/cpufreq.c:608: error: `there_is_no_init_MUTEX_LOCKED_for_RT_semaphores' undeclared (first use in this function) drivers/cpufreq/cpufreq.c:608: error: (Each undeclared identifier is reported only once
drivers/cpufreq/cpufreq.c:608: error: for each function it appears in.)
make[2]: *** [drivers/cpufreq/cpufreq.o] Error 1
make[1]: *** [drivers/cpufreq] Error 2
make: *** [drivers] Error 2

Michal
diff -Nurp -X linux-RT/Documentation/dontdiff linux-RT/include/linux/rt_lock.h linux-RT.mich/include/linux/rt_lock.h
--- linux-RT/include/linux/rt_lock.h	2005-05-30 10:42:47.000000000 +0200
+++ linux-RT.mich/include/linux/rt_lock.h	2005-05-30 11:32:12.000000000 +0200
@@ -201,11 +201,13 @@ extern void FASTCALL(__sema_init(struct 
 		__sema_init(sem, val, #sem, __FILE__, __LINE__)
 	
 extern void FASTCALL(__init_MUTEX(struct semaphore *sem, char *name, char *file, int line));
-extern void FASTCALL(__init_MUTEX_LOCKED(struct semaphore *sem, char *name, char *file, int line));
 #define rt_init_MUTEX(sem) \
 		__init_MUTEX(sem, #sem, __FILE__, __LINE__)
+/*
+ * No locked initialization for RT semaphores
+ */
 #define rt_init_MUTEX_LOCKED(sem) \
-		__init_MUTEX_LOCKED(sem, #sem, __FILE__, __LINE__)
+		there_is_no_init_MUTEX_LOCKED_for_RT_semaphores
 extern void FASTCALL(rt_down(struct semaphore *sem));
 extern int FASTCALL(rt_down_interruptible(struct semaphore *sem));
 extern int FASTCALL(rt_down_trylock(struct semaphore *sem));
@@ -259,6 +261,10 @@ do {									\
 	PICK_FUNC_1ARG(struct compat_semaphore, struct semaphore, \
 		compat_init_MUTEX, rt_init_MUTEX, sem)
 
+#define init_MUTEX_LOCKED(sem) \
+	PICK_FUNC_1ARG(struct compat_semaphore, struct semaphore, \
+		compat_init_MUTEX_LOCKED, rt_init_MUTEX_LOCKED, sem)
+
 #define down(sem) \
 	PICK_FUNC_1ARG(struct compat_semaphore, struct semaphore, \
 		compat_down, rt_down, sem)
@@ -284,11 +290,6 @@ do {									\
 		compat_sema_count, rt_sema_count, sem)
 
 /*
- * No locked initialization for RT semaphores:
- */
-#define init_MUTEX_LOCKED(sem) compat_init_MUTEX_LOCKED(sem)
-
-/*
  * rwsems:
  */
 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux