diff options
| author | Sasha Levin <sasha.levin@oracle.com> | 2013-06-13 18:41:17 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-11-27 05:55:21 -0500 |
| commit | 5634bd7d2ab14fbf736b62b0788fb68e2cb0fde2 (patch) | |
| tree | 1199737c610e0d0402a32c013927df27fd3cbe94 /tools/lib/lockdep/uinclude/linux | |
| parent | 8dce7a9a6f4ca7163161a80a4603b66c88c5de8e (diff) | |
liblockdep: Wrap kernel/locking/lockdep.c to allow usage from userspace
kernel/locking/lockdep.c deals with validating locking scenarios for
various architectures supported by the kernel. There isn't
anything kernel specific going on in lockdep, and when we
compare userspace to other architectures that don't have to deal
with irqs such as s390, they become all too similar.
We wrap kernel/locking/lockdep.c and include/linux/lockdep.h with
several headers which allow us to build and use lockdep from
userspace. We don't touch the kernel code itself which means
that any work done on lockdep in the kernel will automatically
benefit userspace lockdep as well!
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: torvalds@linux-foundation.org
Link: http://lkml.kernel.org/r/1371163284-6346-3-git-send-email-sasha.levin@oracle.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/lib/lockdep/uinclude/linux')
31 files changed, 422 insertions, 0 deletions
diff --git a/tools/lib/lockdep/uinclude/linux/bitops.h b/tools/lib/lockdep/uinclude/linux/bitops.h new file mode 100644 index 000000000000..fab00ff936d1 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/bitops.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | /* empty file */ | ||
| 3 | |||
diff --git a/tools/lib/lockdep/uinclude/linux/compiler.h b/tools/lib/lockdep/uinclude/linux/compiler.h new file mode 100644 index 000000000000..7ac838a1f196 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/compiler.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_LINUX_COMPILER_H_ | ||
| 2 | #define _LIBLOCKDEP_LINUX_COMPILER_H_ | ||
| 3 | |||
| 4 | #define __used __attribute__((__unused__)) | ||
| 5 | #define unlikely | ||
| 6 | |||
| 7 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/debug_locks.h b/tools/lib/lockdep/uinclude/linux/debug_locks.h new file mode 100644 index 000000000000..f38eb64df794 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/debug_locks.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_DEBUG_LOCKS_H_ | ||
| 2 | #define _LIBLOCKDEP_DEBUG_LOCKS_H_ | ||
| 3 | |||
| 4 | #include <stddef.h> | ||
| 5 | #include <linux/compiler.h> | ||
| 6 | |||
| 7 | #define DEBUG_LOCKS_WARN_ON(x) (x) | ||
| 8 | |||
| 9 | extern bool debug_locks; | ||
| 10 | extern bool debug_locks_silent; | ||
| 11 | |||
| 12 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/delay.h b/tools/lib/lockdep/uinclude/linux/delay.h new file mode 100644 index 000000000000..fab00ff936d1 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/delay.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | /* empty file */ | ||
| 3 | |||
diff --git a/tools/lib/lockdep/uinclude/linux/export.h b/tools/lib/lockdep/uinclude/linux/export.h new file mode 100644 index 000000000000..6bdf3492c535 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/export.h | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_LINUX_EXPORT_H_ | ||
| 2 | #define _LIBLOCKDEP_LINUX_EXPORT_H_ | ||
| 3 | |||
| 4 | #define EXPORT_SYMBOL(sym) | ||
| 5 | #define EXPORT_SYMBOL_GPL(sym) | ||
| 6 | |||
| 7 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/ftrace.h b/tools/lib/lockdep/uinclude/linux/ftrace.h new file mode 100644 index 000000000000..fab00ff936d1 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/ftrace.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | /* empty file */ | ||
| 3 | |||
diff --git a/tools/lib/lockdep/uinclude/linux/gfp.h b/tools/lib/lockdep/uinclude/linux/gfp.h new file mode 100644 index 000000000000..fab00ff936d1 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/gfp.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | /* empty file */ | ||
| 3 | |||
diff --git a/tools/lib/lockdep/uinclude/linux/hardirq.h b/tools/lib/lockdep/uinclude/linux/hardirq.h new file mode 100644 index 000000000000..c8f3f8f58729 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/hardirq.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_LINUX_HARDIRQ_H_ | ||
| 2 | #define _LIBLOCKDEP_LINUX_HARDIRQ_H_ | ||
| 3 | |||
| 4 | #define SOFTIRQ_BITS 0UL | ||
| 5 | #define HARDIRQ_BITS 0UL | ||
| 6 | #define SOFTIRQ_SHIFT 0UL | ||
| 7 | #define HARDIRQ_SHIFT 0UL | ||
| 8 | #define hardirq_count() 0UL | ||
| 9 | #define softirq_count() 0UL | ||
| 10 | |||
| 11 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/hash.h b/tools/lib/lockdep/uinclude/linux/hash.h new file mode 100644 index 000000000000..0f8479858dc0 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/hash.h | |||
| @@ -0,0 +1 @@ | |||
| #include "../../../include/linux/hash.h" | |||
diff --git a/tools/lib/lockdep/uinclude/linux/interrupt.h b/tools/lib/lockdep/uinclude/linux/interrupt.h new file mode 100644 index 000000000000..fab00ff936d1 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/interrupt.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | /* empty file */ | ||
| 3 | |||
diff --git a/tools/lib/lockdep/uinclude/linux/irqflags.h b/tools/lib/lockdep/uinclude/linux/irqflags.h new file mode 100644 index 000000000000..6cc296f0fad0 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/irqflags.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_LINUX_TRACE_IRQFLAGS_H_ | ||
| 2 | #define _LIBLOCKDEP_LINUX_TRACE_IRQFLAGS_H_ | ||
| 3 | |||
| 4 | # define trace_hardirq_context(p) 0 | ||
| 5 | # define trace_softirq_context(p) 0 | ||
| 6 | # define trace_hardirqs_enabled(p) 0 | ||
| 7 | # define trace_softirqs_enabled(p) 0 | ||
| 8 | # define trace_hardirq_enter() do { } while (0) | ||
| 9 | # define trace_hardirq_exit() do { } while (0) | ||
| 10 | # define lockdep_softirq_enter() do { } while (0) | ||
| 11 | # define lockdep_softirq_exit() do { } while (0) | ||
| 12 | # define INIT_TRACE_IRQFLAGS | ||
| 13 | |||
| 14 | # define stop_critical_timings() do { } while (0) | ||
| 15 | # define start_critical_timings() do { } while (0) | ||
| 16 | |||
| 17 | #define raw_local_irq_disable() do { } while (0) | ||
| 18 | #define raw_local_irq_enable() do { } while (0) | ||
| 19 | #define raw_local_irq_save(flags) ((flags) = 0) | ||
| 20 | #define raw_local_irq_restore(flags) do { } while (0) | ||
| 21 | #define raw_local_save_flags(flags) ((flags) = 0) | ||
| 22 | #define raw_irqs_disabled_flags(flags) do { } while (0) | ||
| 23 | #define raw_irqs_disabled() 0 | ||
| 24 | #define raw_safe_halt() | ||
| 25 | |||
| 26 | #define local_irq_enable() do { } while (0) | ||
| 27 | #define local_irq_disable() do { } while (0) | ||
| 28 | #define local_irq_save(flags) ((flags) = 0) | ||
| 29 | #define local_irq_restore(flags) do { } while (0) | ||
| 30 | #define local_save_flags(flags) ((flags) = 0) | ||
| 31 | #define irqs_disabled() (1) | ||
| 32 | #define irqs_disabled_flags(flags) (0) | ||
| 33 | #define safe_halt() do { } while (0) | ||
| 34 | |||
| 35 | #define trace_lock_release(x, y) | ||
| 36 | #define trace_lock_acquire(a, b, c, d, e, f, g) | ||
| 37 | |||
| 38 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/kallsyms.h b/tools/lib/lockdep/uinclude/linux/kallsyms.h new file mode 100644 index 000000000000..b0f2dbdf1a15 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/kallsyms.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #ifndef _LIBLOCKDEP_LINUX_KALLSYMS_H_ | ||
| 2 | #define _LIBLOCKDEP_LINUX_KALLSYMS_H_ | ||
| 3 | |||
| 4 | #include <linux/kernel.h> | ||
| 5 | #include <stdio.h> | ||
| 6 | |||
| 7 | #define KSYM_NAME_LEN 128 | ||
| 8 | |||
| 9 | struct module; | ||
| 10 | |||
| 11 | static inline const char *kallsyms_lookup(unsigned long addr, | ||
| 12 | unsigned long *symbolsize, | ||
| 13 | unsigned long *offset, | ||
| 14 | char **modname, char *namebuf) | ||
| 15 | { | ||
| 16 | return NULL; | ||
| 17 | } | ||
| 18 | |||
| 19 | #include <execinfo.h> | ||
| 20 | #include <stdlib.h> | ||
| 21 | static inline void print_ip_sym(unsigned long ip) | ||
| 22 | { | ||
| 23 | char **name; | ||
| 24 | |||
| 25 | name = backtrace_symbols((void **)&ip, 1); | ||
| 26 | |||
| 27 | printf("%s\n", *name); | ||
| 28 | |||
| 29 | free(name); | ||
| 30 | } | ||
| 31 | |||
| 32 | #endif | ||
diff --git a/tools/lib/lockdep/uinclude/linux/kern_levels.h b/tools/lib/lockdep/uinclude/linux/kern_levels.h new file mode 100644 index 000000000000..3b9bade28698 --- /dev/null +++ b/tools/lib/lockdep/uinclude/linux/kern_levels.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #ifndef __KERN_LEVELS_H__ | ||
| 2 | #define __KERN_LEVELS_H__ | ||
| 3 | |||
