lkml.org 
[lkml]   [2008]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC 05/13] cpumask: add get_cpumask_var debug operations
  * Adds debugging to the get_cpumask_var operations.  It uses a primitive
per_cpu lock variable and will only discover nested get_cpumask_var
operations on the same variable.

Applies to linux-2.6.tip/master.

Signed-off-by: Mike Travis <travis@sgi.com>
---
arch/x86/Kconfig.debug | 12 ++++++++++++
include/linux/cpumask_ptr.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)

--- linux-2.6.tip.orig/arch/x86/Kconfig.debug
+++ linux-2.6.tip/arch/x86/Kconfig.debug
@@ -92,6 +92,18 @@ config DEBUG_PER_CPU_MAPS

Say N if unsure.

+config DEBUG_PER_CPUMASK_VAR
+ bool "Debug per_cpumask variables"
+ depends on DEBUG_KERNEL
+ depends on X86_SMP
+ default n
+ help
+ Say Y to verify that the per_cpumask variables being accessed
+ are available. Adds a fair amount of code to kernel memory
+ and decreases performance.
+
+ Say N if unsure.
+
config X86_PTDUMP
bool "Export kernel pagetable layout to userspace via debugfs"
depends on DEBUG_KERNEL
--- linux-2.6.tip.orig/include/linux/cpumask_ptr.h
+++ linux-2.6.tip/include/linux/cpumask_ptr.h
@@ -53,11 +53,45 @@ static inline void free_cpumask_ptr(cpum
{
kfree(*p);
}
+
+#ifndef CONFIG_DEBUG_CPUMASK_VAR
#define DEFINE_PER_CPUMASK(v) DEFINE_PER_CPU(cpumask_t, v)
#define DECLARE_PER_CPUMASK(v) DECLARE_PER_CPU(cpumask_t, v)
#define get_cpumask_var(p, v) _get_cpumask_ptr(&(p), &get_cpu_var(v))
#define put_cpumask_var(p, v) put_cpu_var(v)

+#else /* CONFIG_DEBUG_CPUMASK_VAR */
+#define DEFINE_PER_CPUMASK(v) DEFINE_PER_CPU(cpumask_t, v); \
+ DEFINE_PER_CPU(char, lock_##v)
+#define DECLARE_PER_CPUMASK(v) DECLARE_PER_CPU(cpumask_t, v); \
+ DECLARE_PER_CPU(char, lock_##v)
+
+#define get_cpumask_var(p, v) { \
+ char *lock = &get_cpu_var(lock_##v); \
+ if (*lock) { \
+ printk(KERN_NOTICE "get_cpumask_var(" v "): " \
+ "already locked!\n"); \
+ dump_stack(); \
+ BUG(); \
+ } \
+ *lock = 1; \
+ _get_cpumask_ptr(&(p), &get_cpu_var(v)) \
+ put_cpu_var(lock_##v); \
+}
+
+#define put_cpumask_var(p, v) { \
+ char *lock = &get_cpu_var(lock_##v); \
+ if (!*lock) { \
+ printk(KERN_NOTICE "put_cpumask_var(" v "): " \
+ "not locked!\n"); \
+ dump_stack(); \
+ } \
+ *lock = 0; \
+ put_cpu_var(lock_##v); \
+ put_cpu_var(v); \
+}
+#endif /* CONFIG_DEBUG_CPUMASK_VAR */
+
#endif /* NR_CPUS > BITS_PER_LONG */

#endif /* __LINUX_CPUMASK_PTR_H */
--


\
 
 \ /
  Last update: 2008-09-07 01:55    [W:0.131 / U:3.288 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site