Skip to contentSkip to conversation

Do not use DEFINE_RWLOCK Macro

PATCH In review Ben Guthro 2 participants 3 messages Aug 29, 2007

lore
Share & tools
lore

Ben Guthro

author
#0 lore raw

PATCH 1/3 Do not use DEFINE_RWLOCK Macro

Do not use the DEFINE_RWLOCK macro, as it is not available when compiled against older kernels, such as SLES9's 2.6.5

unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c +3 -1
diff -r ef25e071a074 unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c
@@ -15,8 +15,10 @@ struct ap_suspend_info {
 /*
  * Use a rwlock to protect the hypercall page from being executed in AP context
  * while the BSP is re-initializing it after restore.
+ * Do not use the DEFINE_RWLOCK macro, as it is not available when compiled against
+ *  older kernels
  */
-static DEFINE_RWLOCK(suspend_lock);
+static rwlock_t suspend_lock = RW_LOCK_UNLOCKED;
 
 /*
  * Spinning prevents, for example, APs touching grant table entries while

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 2 lines · Ben Guthro

Do not use the DEFINE_RWLOCK macro, as it is not available when compiled against older kernels, such as SLES9's 2.6.5

Things like this should generally be done by adding a suitably guarded definition of DEFINE_RWLOCK to the platform-compat.h header in unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h.

Ian.

author
#2 lore raw

Revised patch attached.

Note that I did run into a problem with a buggy kernel in RHEL4-U3.
It seems that in this macro, rw_lock_t was used instead of rwlock_t. I added a line to platform-compat.h to account for this.

Ben

Quoted 12 lines · Ian Campbell
Quoted 2 lines · Ben Guthro

Do not use the DEFINE_RWLOCK macro, as it is not available when compiled against older kernels, such as SLES9's 2.6.5

Things like this should generally be done by adding a suitably guarded definition of DEFINE_RWLOCK to the platform-compat.h header in unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h.

Ian.

unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h +9 -0
diff -r a381118a247a unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
@@ -116,4 +116,13 @@ extern char *kasprintf(gfp_t gfp, const 
 #define DEFINE_SEQLOCK(x) seqlock_t x = SEQLOCK_UNLOCKED
 #endif
 
+#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_RWLOCK)
+#define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED
 #endif
+
+/* Bug in RHEL4-U3 rw_lock_t is mistakenly defined in this macro */
+#if defined(__LINUX_SPINLOCK_H) && defined(DEFINE_RWLOCK)
+#define rw_lock_t rwlock_t
+#endif
+
+#endif

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel