liblockdep: remove the need for liblockdep_init
PATCH v2 1/11 liblockdep: remove the need for liblockdep_init
Use a constructor in the library instead of making the user manually call liblockdep_init().
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)
tools/lib/lockdep/common.c +1 -1
@@ -10,7 +10,7 @@ __thread struct task_struct current_obj;bool debug_locks = true;bool debug_locks_silent; -void liblockdep_init (void ) +__attribute__((constructor))static void liblockdep_init (void ) {lockdep_init (); }
tools/lib/lockdep/include/liblockdep/common.h +0 -1
@@ -26,7 +26,6 @@ struct lockdep_map {#endif }; -void liblockdep_init (void );void liblockdep_set_thread (void );void lockdep_init_map (struct lockdep_map *lock,const char *name,struct lock_class_key *key,int subclass);
tools/lib/lockdep/tests/AA.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBCCA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBCCDDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCABC.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCDBCDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {liblockdep_pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();liblockdep_pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCDBDDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/WW.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_rwlock_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_rwlock_init (&a,NULL );
tools/lib/lockdep/tests/unlock_balance.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_mutex_t a; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/uinclude/linux/lockdep.h +0 -1
@@ -25,7 +25,6 @@ struct task_struct {extern __threadstruct task_struct current_obj;#define current (¤t_obj) -void liblockdep_init (void );void liblockdep_set_thread (void );#define debug_locks_off () 1
Signature · 1 line
1.8.1.2
PATCH v2 2/11 liblockdep: remove the need for liblockdep_set_thread
Generate the task_struct data on the fly when needed, instead on on thread creation.
--- tools/lib/lockdep/common.c | 8 +++++--- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 2 -- tools/lib/lockdep/tests/ABBA.c | 2 -- tools/lib/lockdep/tests/ABBCCA.c | 2 -- tools/lib/lockdep/tests/ABBCCDDA.c | 2 -- tools/lib/lockdep/tests/ABCABC.c | 2 -- tools/lib/lockdep/tests/ABCDBCDA.c | 2 -- tools/lib/lockdep/tests/ABCDBDDA.c | 2 -- tools/lib/lockdep/tests/WW.c | 2 -- tools/lib/lockdep/tests/unlock_balance.c | 2 -- tools/lib/lockdep/uinclude/linux/lockdep.h | 4 ++-- 12 files changed, 7 insertions(+), 24 deletions(-)
tools/lib/lockdep/common.c +5 -3
@@ -15,8 +15,10 @@ __attribute__((constructor)) static void liblockdep_init(void)lockdep_init (); } -void liblockdep_set_thread (void ) +struct task_struct *__curr (void ) { -prctl (PR_GET_NAME , current->comm); - current->pid =syscall (__NR_gettid); +prctl (PR_GET_NAME , current_obj.comm); + current_obj.pid =syscall (__NR_gettid); + +return ¤t_obj; }
tools/lib/lockdep/include/liblockdep/common.h +0 -1
@@ -26,7 +26,6 @@ struct lockdep_map {#endif }; -void liblockdep_set_thread (void );void lockdep_init_map (struct lockdep_map *lock,const char *name,struct lock_class_key *key,int subclass); void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
tools/lib/lockdep/tests/AA.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );
tools/lib/lockdep/tests/ABBA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );
tools/lib/lockdep/tests/ABBCCA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABBCCDDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCABC.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCDBCDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {liblockdep_pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -liblockdep_pthread_mutex_init (&a,NULL );liblockdep_pthread_mutex_init (&b,NULL );liblockdep_pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCDBDDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/WW.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_rwlock_t a, b; -liblockdep_set_thread (); -pthread_rwlock_init (&a,NULL );pthread_rwlock_init (&b,NULL );
tools/lib/lockdep/tests/unlock_balance.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_mutex_t a; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_lock (&a);
tools/lib/lockdep/uinclude/linux/lockdep.h +2 -2
@@ -23,9 +23,9 @@ struct task_struct { };extern __threadstruct task_struct current_obj; -#define current (¤t_obj) +extern struct task_struct *__curr (void ); -void liblockdep_set_thread (void ); +#define current (__curr())#define debug_locks_off () 1#define task_pid_nr (tsk) ((tsk)->pid)
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Remove the need for liblockdep_set_thread()
Commit-ID: 4d81b02bbc6aa485e9cf0bdb6951b7b1b4952bb8 Gitweb: http://git.kernel.org/tip/4d81b02bbc6aa485e9cf0bdb6951b7b1b4952bb8 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:32 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:36 +0100
liblockdep: Remove the need for liblockdep_set_thread()
Generate the task_struct data on the fly when needed, instead on on thread creation.
--- tools/lib/lockdep/common.c | 8 +++++--- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 2 -- tools/lib/lockdep/tests/ABBA.c | 2 -- tools/lib/lockdep/tests/ABBCCA.c | 2 -- tools/lib/lockdep/tests/ABBCCDDA.c | 2 -- tools/lib/lockdep/tests/ABCABC.c | 2 -- tools/lib/lockdep/tests/ABCDBCDA.c | 2 -- tools/lib/lockdep/tests/ABCDBDDA.c | 2 -- tools/lib/lockdep/tests/WW.c | 2 -- tools/lib/lockdep/tests/unlock_balance.c | 2 -- tools/lib/lockdep/uinclude/linux/lockdep.h | 4 ++-- 12 files changed, 7 insertions(+), 24 deletions(-)
tools/lib/lockdep/common.c +5 -3
@@ -15,8 +15,10 @@ __attribute__((constructor)) static void liblockdep_init(void)lockdep_init (); } -void liblockdep_set_thread (void ) +struct task_struct *__curr (void ) { -prctl (PR_GET_NAME , current->comm); - current->pid =syscall (__NR_gettid); +prctl (PR_GET_NAME , current_obj.comm); + current_obj.pid =syscall (__NR_gettid); + +return ¤t_obj; }
tools/lib/lockdep/include/liblockdep/common.h +0 -1
@@ -26,7 +26,6 @@ struct lockdep_map {#endif }; -void liblockdep_set_thread (void );void lockdep_init_map (struct lockdep_map *lock,const char *name,struct lock_class_key *key,int subclass); void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
tools/lib/lockdep/tests/AA.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );
tools/lib/lockdep/tests/ABBA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );
tools/lib/lockdep/tests/ABBCCA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABBCCDDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCABC.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCDBCDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {liblockdep_pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -liblockdep_pthread_mutex_init (&a,NULL );liblockdep_pthread_mutex_init (&b,NULL );liblockdep_pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/ABCDBDDA.c +0 -2
@@ -5,8 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_init (&b,NULL );pthread_mutex_init (&c,NULL );
tools/lib/lockdep/tests/WW.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_rwlock_t a, b; -liblockdep_set_thread (); -pthread_rwlock_init (&a,NULL );pthread_rwlock_init (&b,NULL );
tools/lib/lockdep/tests/unlock_balance.c +0 -2
@@ -4,8 +4,6 @@ void main(void) {pthread_mutex_t a; -liblockdep_set_thread (); -pthread_mutex_init (&a,NULL );pthread_mutex_lock (&a);
tools/lib/lockdep/uinclude/linux/lockdep.h +2 -2
@@ -23,9 +23,9 @@ struct task_struct { };extern __threadstruct task_struct current_obj; -#define current (¤t_obj) +extern struct task_struct *__curr (void ); -void liblockdep_set_thread (void ); +#define current (__curr())#define debug_locks_off () 1#define task_pid_nr (tsk) ((tsk)->pid)
PATCH v2 3/11 perf: stop using liblockdep_init and liblockdep_set_thread
In reply to Sasha LevinThese functions are no longer needed by liblockdep, drop them.
--- tools/perf/builtin-sched.c | 2 -- tools/perf/builtin-top.c | 4 ---- tools/perf/config/feature-tests.mak | 1 - tools/perf/perf.c | 3 --- tools/perf/util/liblockdep.h | 2 -- 5 files changed, 12 deletions(-)
tools/perf/builtin-sched.c +0 -2
@@ -468,8 +468,6 @@ static void *thread_func(void *ctx)char comm2[22 ];int fd; -liblockdep_set_thread (); -free (parms);sprintf (comm2,":%s" , this_task->comm);
tools/perf/builtin-top.c +0 -4
@@ -588,8 +588,6 @@ static void *display_thread_tui(void *arg) .refresh = top->delay_secs, }; -liblockdep_set_thread (); -perf_top__sort_new_samples (top);/*
@@ -615,8 +613,6 @@ static void *display_thread(void *arg)struct perf_top *top = arg;int delay_msecs, c; -liblockdep_set_thread (); -tcgetattr (0 , &save); tc = save; tc.c_lflag &= ~(ICANON |ECHO );
tools/perf/config/feature-tests.mak +0 -1
@@ -223,7 +223,6 @@ define SOURCE_LIBLOCKDEP int main(void) { - liblockdep_init(); return 0; } endef
tools/perf/perf.c +0 -3
@@ -446,9 +446,6 @@ int main(int argc, const char **argv) {const char *cmd; -liblockdep_init (); -liblockdep_set_thread (); - page_size =sysconf (_SC_PAGE_SIZE); cmd =perf_extract_argv0_path (argv[0 ]);
tools/perf/util/liblockdep.h +0 -2
@@ -5,7 +5,5 @@#else #define LIBLOCKDEP_PTHREAD_MUTEX_INITIALIZER (mtx) PTHREAD_MUTEX_INITIALIZER -#define liblockdep_init () -#define liblockdep_set_thread ()#endif
Signature · 1 line
1.8.1.2
[tip:core/locking] perf: Stop using liblockdep_init() and liblockdep_set_thread()
Commit-ID: bf48cfee5efb3f86c0620acd76b873a6f50bb11a Gitweb: http://git.kernel.org/tip/bf48cfee5efb3f86c0620acd76b873a6f50bb11a Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:33 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:37 +0100
perf: Stop using liblockdep_init() and liblockdep_set_thread()
These functions are no longer needed by liblockdep, drop them.
--- tools/perf/builtin-sched.c | 2 -- tools/perf/builtin-top.c | 4 ---- tools/perf/config/feature-tests.mak | 1 - tools/perf/perf.c | 3 --- tools/perf/util/liblockdep.h | 2 -- 5 files changed, 12 deletions(-)
tools/perf/builtin-sched.c +0 -2
@@ -468,8 +468,6 @@ static void *thread_func(void *ctx)char comm2[22 ];int fd; -liblockdep_set_thread (); -free (parms);sprintf (comm2,":%s" , this_task->comm);
tools/perf/builtin-top.c +0 -4
@@ -588,8 +588,6 @@ static void *display_thread_tui(void *arg) .refresh = top->delay_secs, }; -liblockdep_set_thread (); -perf_top__sort_new_samples (top);/*
@@ -615,8 +613,6 @@ static void *display_thread(void *arg)struct perf_top *top = arg;int delay_msecs, c; -liblockdep_set_thread (); -tcgetattr (0 , &save); tc = save; tc.c_lflag &= ~(ICANON |ECHO );
tools/perf/config/feature-tests.mak +0 -1
@@ -223,7 +223,6 @@ define SOURCE_LIBLOCKDEP int main(void) { - liblockdep_init(); return 0; } endef
tools/perf/perf.c +0 -3
@@ -446,9 +446,6 @@ int main(int argc, const char **argv) {const char *cmd; -liblockdep_init (); -liblockdep_set_thread (); - page_size =sysconf (_SC_PAGE_SIZE); cmd =perf_extract_argv0_path (argv[0 ]);
tools/perf/util/liblockdep.h +0 -2
@@ -5,7 +5,5 @@#else #define LIBLOCKDEP_PTHREAD_MUTEX_INITIALIZER (mtx) PTHREAD_MUTEX_INITIALIZER -#define liblockdep_init () -#define liblockdep_set_thread ()#endif
PATCH v2 4/11 liblockdep: fix AA test
In reply to Sasha LevinWe were accidently unlocking the dummy mutex in the test, which meant that we were testing unlock balance instead of AA deadlock.
--- tools/lib/lockdep/tests/AA.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/lockdep/tests/AA.c +1 -1
@@ -8,6 +8,6 @@ void main(void)pthread_mutex_init (&b,NULL );pthread_mutex_lock (&a); -pthread_mutex_unlock (&b); +pthread_mutex_lock (&b);pthread_mutex_lock (&a); }
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Fix the AA locking test
Commit-ID: 47283ee709d09e43cff7feaf8bb9ff24fb9e7fd5 Gitweb: http://git.kernel.org/tip/47283ee709d09e43cff7feaf8bb9ff24fb9e7fd5 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:34 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:37 +0100
liblockdep: Fix the AA locking test
We were accidently unlocking the dummy mutex in the test, which meant that we were testing unlock balance instead of AA deadlock.
--- tools/lib/lockdep/tests/AA.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/lockdep/tests/AA.c +1 -1
@@ -8,6 +8,6 @@ void main(void)pthread_mutex_init (&b,NULL );pthread_mutex_lock (&a); -pthread_mutex_unlock (&b); +pthread_mutex_lock (&b);pthread_mutex_lock (&a); }
PATCH v2 5/11 liblockdep: correct the ABCDBCDA test
In reply to Sasha LevinThere's no need to use liblockdep specific calls, they are wrapped for us.
--- tools/lib/lockdep/tests/ABCDBCDA.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/lib/lockdep/tests/ABCDBCDA.c +5 -5
@@ -3,12 +3,12 @@void main (void ) { -liblockdep_pthread_mutex_t a, b, c, d; +pthread_mutex_t a, b, c, d; -liblockdep_pthread_mutex_init (&a,NULL ); -liblockdep_pthread_mutex_init (&b,NULL ); -liblockdep_pthread_mutex_init (&c,NULL ); -liblockdep_pthread_mutex_init (&d,NULL ); +pthread_mutex_init (&a,NULL ); +pthread_mutex_init (&b,NULL ); +pthread_mutex_init (&c,NULL ); +pthread_mutex_init (&d,NULL );LOCK_UNLOCK_2 (a, b);LOCK_UNLOCK_2 (c, d);
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Correct the ABCDBCDA test
Commit-ID: 23e9e95acb727267e171a34e2bb65dbe0b188ee1 Gitweb: http://git.kernel.org/tip/23e9e95acb727267e171a34e2bb65dbe0b188ee1 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:35 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:38 +0100
liblockdep: Correct the ABCDBCDA test
There's no need to use liblockdep specific calls, they are wrapped for us.
--- tools/lib/lockdep/tests/ABCDBCDA.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/lib/lockdep/tests/ABCDBCDA.c +5 -5
@@ -3,12 +3,12 @@void main (void ) { -liblockdep_pthread_mutex_t a, b, c, d; +pthread_mutex_t a, b, c, d; -liblockdep_pthread_mutex_init (&a,NULL ); -liblockdep_pthread_mutex_init (&b,NULL ); -liblockdep_pthread_mutex_init (&c,NULL ); -liblockdep_pthread_mutex_init (&d,NULL ); +pthread_mutex_init (&a,NULL ); +pthread_mutex_init (&b,NULL ); +pthread_mutex_init (&c,NULL ); +pthread_mutex_init (&d,NULL );LOCK_UNLOCK_2 (a, b);LOCK_UNLOCK_2 (c, d);
PATCH v2 6/11 liblockdep: rbtree support
In reply to Sasha LevinWe re-use kernel's rbtree structure for the preload improvement in the following patches.
--- tools/lib/lockdep/rbtree.c | 1 + tools/lib/lockdep/uinclude/linux/rbtree.h | 1 + tools/lib/lockdep/uinclude/linux/rbtree_augmented.h | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 tools/lib/lockdep/rbtree.c create mode 100644 tools/lib/lockdep/uinclude/linux/rbtree.h create mode 100644 tools/lib/lockdep/uinclude/linux/rbtree_augmented.h
tools/lib/lockdep/rbtree.c new file +1 -0
@@ -0,0 +1 @@ +#include "../../../lib/rbtree.c"
tools/lib/lockdep/uinclude/linux/rbtree.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../../include/linux/rbtree.h"
tools/lib/lockdep/uinclude/linux/rbtree_augmented.h new file +2 -0
@@ -0,0 +1,2 @@ +#define __always_inline +#include "../../../include/linux/rbtree_augmented.h"
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Add rbtree support
Commit-ID: b91dbe96f6e72471bd00e74791507357e09cfbb5 Gitweb: http://git.kernel.org/tip/b91dbe96f6e72471bd00e74791507357e09cfbb5 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:36 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:39 +0100
liblockdep: Add rbtree support
We re-use kernel's rbtree structure for the preload improvement in the following patches.
--- tools/lib/lockdep/rbtree.c | 1 + tools/lib/lockdep/uinclude/linux/rbtree.h | 1 + tools/lib/lockdep/uinclude/linux/rbtree_augmented.h | 2 ++ 3 files changed, 4 insertions(+)
tools/lib/lockdep/rbtree.c new file +1 -0
@@ -0,0 +1 @@ +#include "../../../lib/rbtree.c"
tools/lib/lockdep/uinclude/linux/rbtree.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../../include/linux/rbtree.h"
tools/lib/lockdep/uinclude/linux/rbtree_augmented.h new file +2 -0
@@ -0,0 +1,2 @@ +#define __always_inline +#include "../../../include/linux/rbtree_augmented.h"
PATCH v2 7/11 liblockdep: prevent multiple declarations of CALLER_ADDR0
In reply to Sasha LevinThey are declared once in the public and once in the private headers, prevent declaring them twice if both headers are used.
--- tools/lib/lockdep/include/liblockdep/common.h | 3 +++ tools/lib/lockdep/uinclude/linux/kernel.h | 2 ++ 2 files changed, 5 insertions(+)
tools/lib/lockdep/include/liblockdep/common.h +3 -0
@@ -3,8 +3,11 @@#include <pthread.h> +#ifndef CALLER_ADDR0 #define CALLER_ADDR0 (__builtin_return_address(0))#define _THIS_IP_ CALLER_ADDR0 +#endif +#define NR_LOCKDEP_CACHING_CLASSES 2#define MAX_LOCKDEP_SUBCLASSES 8UL
tools/lib/lockdep/uinclude/linux/kernel.h +2 -0
@@ -28,7 +28,9 @@#define noinline#define list_add_tail_rcu list_add_tail +#ifndef CALLER_ADDR0 #define _THIS_IP_ CALLER_ADDR0#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) +#endif #endif
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Prevent multiple declarations of CALLER_ADDR0
Commit-ID: 8299c063bfa238da87fbdd15b1c3a31ca6e8ff74 Gitweb: http://git.kernel.org/tip/8299c063bfa238da87fbdd15b1c3a31ca6e8ff74 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:37 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:39 +0100
liblockdep: Prevent multiple declarations of CALLER_ADDR0
They are declared once in the public and once in the private headers, prevent declaring them twice if both headers are used.
--- tools/lib/lockdep/include/liblockdep/common.h | 3 +++ tools/lib/lockdep/uinclude/linux/kernel.h | 2 ++ 2 files changed, 5 insertions(+)
tools/lib/lockdep/include/liblockdep/common.h +3 -0
@@ -3,8 +3,11 @@#include <pthread.h> +#ifndef CALLER_ADDR0 #define CALLER_ADDR0 (__builtin_return_address(0))#define _THIS_IP_ CALLER_ADDR0 +#endif +#define NR_LOCKDEP_CACHING_CLASSES 2#define MAX_LOCKDEP_SUBCLASSES 8UL
tools/lib/lockdep/uinclude/linux/kernel.h +2 -0
@@ -28,7 +28,9 @@#define noinline#define list_add_tail_rcu list_add_tail +#ifndef CALLER_ADDR0 #define _THIS_IP_ CALLER_ADDR0#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) +#endif #endif
PATCH v2 8/11 liblockdep: keep headers declarations even if lib is disabled
In reply to Sasha LevinWe need the public headers in the core module code for the preload thing.
--- tools/lib/lockdep/include/liblockdep/mutex.h | 4 ++-- tools/lib/lockdep/include/liblockdep/rwlock.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/lockdep/include/liblockdep/mutex.h +2 -2
@@ -1,8 +1,6 @@#ifndef _LIBLOCKDEP_MUTEX_H#define _LIBLOCKDEP_MUTEX_H -#ifdef __USE_LIBLOCKDEP -#include <pthread.h> #include "common.h"
@@ -61,6 +59,8 @@ static inline int liblockdep_pthread_mutex_destroy(liblockdep_pthread_mutex_t *lreturn pthread_mutex_destroy (&lock->mutex); } +#ifdef __USE_LIBLOCKDEP +#define pthread_mutex_t liblockdep_pthread_mutex_t#define pthread_mutex_init liblockdep_pthread_mutex_init#define pthread_mutex_lock liblockdep_pthread_mutex_lock
tools/lib/lockdep/include/liblockdep/rwlock.h +2 -2
@@ -1,8 +1,6 @@#ifndef _LIBLOCKDEP_RWLOCK_H#define _LIBLOCKDEP_RWLOCK_H -#ifdef __USE_LIBLOCKDEP -#include <pthread.h> #include "common.h"
@@ -77,6 +75,8 @@ static inline int liblockdep_rwlock_destroy(liblockdep_pthread_rwlock_t *lock)return pthread_rwlock_destroy (&lock->rwlock); } +#ifdef __USE_LIBLOCKDEP +#define pthread_rwlock_t liblockdep_pthread_rwlock_t#define pthread_rwlock_init liblockdep_pthread_rwlock_init#define pthread_rwlock_rdlock liblockdep_pthread_rwlock_rdlock
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Keep header declarations even if the library is disabled
Commit-ID: fab0398231a1fff5a3d0ded5f7416c9d2e3d48d1 Gitweb: http://git.kernel.org/tip/fab0398231a1fff5a3d0ded5f7416c9d2e3d48d1 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:38 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:40 +0100
liblockdep: Keep header declarations even if the library is disabled
We need the public headers in the core module code for the preload thing.
--- tools/lib/lockdep/include/liblockdep/mutex.h | 4 ++-- tools/lib/lockdep/include/liblockdep/rwlock.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/lockdep/include/liblockdep/mutex.h +2 -2
@@ -1,8 +1,6 @@#ifndef _LIBLOCKDEP_MUTEX_H#define _LIBLOCKDEP_MUTEX_H -#ifdef __USE_LIBLOCKDEP -#include <pthread.h> #include "common.h"
@@ -61,6 +59,8 @@ static inline int liblockdep_pthread_mutex_destroy(liblockdep_pthread_mutex_t *lreturn pthread_mutex_destroy (&lock->mutex); } +#ifdef __USE_LIBLOCKDEP +#define pthread_mutex_t liblockdep_pthread_mutex_t#define pthread_mutex_init liblockdep_pthread_mutex_init#define pthread_mutex_lock liblockdep_pthread_mutex_lock
tools/lib/lockdep/include/liblockdep/rwlock.h +2 -2
@@ -1,8 +1,6 @@#ifndef _LIBLOCKDEP_RWLOCK_H#define _LIBLOCKDEP_RWLOCK_H -#ifdef __USE_LIBLOCKDEP -#include <pthread.h> #include "common.h"
@@ -77,6 +75,8 @@ static inline int liblockdep_rwlock_destroy(liblockdep_pthread_rwlock_t *lock)return pthread_rwlock_destroy (&lock->rwlock); } +#ifdef __USE_LIBLOCKDEP +#define pthread_rwlock_t liblockdep_pthread_rwlock_t#define pthread_rwlock_init liblockdep_pthread_rwlock_init#define pthread_rwlock_rdlock liblockdep_pthread_rwlock_rdlock
PATCH v2 9/11 liblockdep: support using LD_PRELOAD
In reply to Sasha LevinThis allows lockdep to be used without being compiled in the original program.
Usage is quite simple:
LD_PRELOAD=/path/to/liblockdep.so /path/to/my/program
And magically, you'll have lockdep in your program!
--- tools/lib/lockdep/Makefile | 4 +- tools/lib/lockdep/preload.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 tools/lib/lockdep/preload.c
tools/lib/lockdep/Makefile +2 -2
@@ -143,7 +143,7 @@ do_app_build = \ do_compile_shared_library = \ ($(print_shared_lib_compile) \ - $(CC) --shared $^ -o $@) + $(CC) --shared -ldl $^ -o $@) do_build_static_lib = \ ($(print_static_lib_build) \
@@ -161,7 +161,7 @@ $(obj)/%.o: $(src)/%.c %.o: $(src)/%.c $(Q)$(call do_compile) -PEVENT_LIB_OBJS = common.o lockdep.o +PEVENT_LIB_OBJS = common.o lockdep.o preload.o rbtree.o ALL_OBJS = $(PEVENT_LIB_OBJS)
tools/lib/lockdep/preload.c new file +209 -0
209 lines not on this page · raw message
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Support using LD_PRELOAD
Commit-ID: eb1aa2ea7da68149bd9ec4491379a81277127ac0 Gitweb: http://git.kernel.org/tip/eb1aa2ea7da68149bd9ec4491379a81277127ac0 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:39 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:40 +0100
liblockdep: Support using LD_PRELOAD
This allows lockdep to be used without being compiled in the original program.
Usage is quite simple:
LD_PRELOAD=/path/to/liblockdep.so /path/to/my/program
And magically, you'll have lockdep checking in your program!
--- tools/lib/lockdep/Makefile | 4 +- tools/lib/lockdep/preload.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+), 2 deletions(-)
tools/lib/lockdep/Makefile +2 -2
@@ -143,7 +143,7 @@ do_app_build = \ do_compile_shared_library = \ ($(print_shared_lib_compile) \ - $(CC) --shared $^ -o $@) + $(CC) --shared -ldl $^ -o $@) do_build_static_lib = \ ($(print_static_lib_build) \
@@ -161,7 +161,7 @@ $(obj)/%.o: $(src)/%.c %.o: $(src)/%.c $(Q)$(call do_compile) -PEVENT_LIB_OBJS = common.o lockdep.o +PEVENT_LIB_OBJS = common.o lockdep.o preload.o rbtree.o ALL_OBJS = $(PEVENT_LIB_OBJS)
tools/lib/lockdep/preload.c new file +209 -0
209 lines not on this page · raw message
PATCH v2 10/11 liblockdep: add tests for the LD_PRELOAD feature
In reply to Sasha LevinUse same tests, but without compiling with liblockdep in the first place.
--- tools/lib/lockdep/run_tests.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/lib/lockdep/run_tests.sh +12 -0
@@ -13,3 +13,15 @@ for i in `ls tests/*.c`; do fi rm tests/$testname done + +for i in `ls tests/*.c`; do + testname=$(basename -s .c "$i") + gcc -o tests/$testname -lpthread -Iinclude $i &> /dev/null + echo -ne "(PRELOAD) $testname... " + if [ $(LD_PRELOAD=./liblockdep.so timeout 1 ./tests/$testname | wc -l) -gt 0 ]; then + echo "PASSED!" + else + echo "FAILED!" + fi + rm tests/$testname +done
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Add tests for the LD_PRELOAD feature
Commit-ID: 36c2dd52a2740ea6b87fc51713531e560d135c5c Gitweb: http://git.kernel.org/tip/36c2dd52a2740ea6b87fc51713531e560d135c5c Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:40 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:41 +0100
liblockdep: Add tests for the LD_PRELOAD feature
Use same tests, but without compiling with liblockdep in the first place.
--- tools/lib/lockdep/run_tests.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/lib/lockdep/run_tests.sh +12 -0
@@ -13,3 +13,15 @@ for i in `ls tests/*.c`; do fi rm tests/$testname done + +for i in `ls tests/*.c`; do + testname=$(basename -s .c "$i") + gcc -o tests/$testname -lpthread -Iinclude $i &> /dev/null + echo -ne "(PRELOAD) $testname... " + if [ $(LD_PRELOAD=./liblockdep.so timeout 1 ./tests/$testname | wc -l) -gt 0 ]; then + echo "PASSED!" + else + echo "FAILED!" + fi + rm tests/$testname +done
PATCH v2 11/11 liblockdep: preload helper
In reply to Sasha LevinThis is a simple wrapper to make using liblockdep on existing applications much easier.
After running 'make && make install', it becomes quite simple to test things with liblockdep. For example, to try it on perf:
lockdep perf
No other integration required.
--- tools/lib/lockdep/Makefile | 12 ++++++++---- tools/lib/lockdep/lockdep | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100755 tools/lib/lockdep/lockdep
tools/lib/lockdep/Makefile +8 -4
@@ -34,7 +34,9 @@ DESTDIR ?= DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' prefix ?= /usr/local -bindir_relative = lib +libdir_relative = lib +libdir = $(prefix)/$(libdir_relative) +bindir_relative = bin bindir = $(prefix)/$(bindir_relative) export DESTDIR DESTDIR_SQ INSTALL
@@ -90,13 +92,14 @@ objtree := $(CURDIR) src := $(srctree) obj := $(objtree) -export prefix bindir src obj +export prefix libdir bindir src obj # Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) bindir_SQ = $(subst ','\'',$(bindir)) -bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) LIB_FILE = liblockdep.a liblockdep.so +BIN_FILE = lockdep CONFIG_INCLUDES = CONFIG_LIBS =
@@ -229,7 +232,8 @@ define do_install endef install_lib: all_cmd - $(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ)) + $(Q)$(call do_install,$(LIB_FILE),$(libdir_SQ)) + $(Q)$(call do_install,$(BIN_FILE),$(bindir_SQ)) install: install_lib
tools/lib/lockdep/lockdep new file +3 -0
@@ -0,0 +1,3 @@ +#! /bin/bash + +LD_PRELOAD="liblockdep.so $LD_PRELOAD" "$@"
Signature · 1 line
1.8.1.2
[tip:core/locking] liblockdep: Add the 'lockdep' user-space utility
Commit-ID: c2823ae46fb1641cc691c3dcc0eeb4356fce267a Gitweb: http://git.kernel.org/tip/c2823ae46fb1641cc691c3dcc0eeb4356fce267a Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:41 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:41 +0100
liblockdep: Add the 'lockdep' user-space utility
This is a simple wrapper to make using liblockdep on existing applications much easier.
After running 'make && make install', it becomes quite simple to test things with liblockdep. For example, to try it on perf:
lockdep perf
No other integration required.
--- tools/lib/lockdep/Makefile | 12 ++++++++---- tools/lib/lockdep/lockdep | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-)
tools/lib/lockdep/Makefile +8 -4
@@ -34,7 +34,9 @@ DESTDIR ?= DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' prefix ?= /usr/local -bindir_relative = lib +libdir_relative = lib +libdir = $(prefix)/$(libdir_relative) +bindir_relative = bin bindir = $(prefix)/$(bindir_relative) export DESTDIR DESTDIR_SQ INSTALL
@@ -90,13 +92,14 @@ objtree := $(CURDIR) src := $(srctree) obj := $(objtree) -export prefix bindir src obj +export prefix libdir bindir src obj # Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) bindir_SQ = $(subst ','\'',$(bindir)) -bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) LIB_FILE = liblockdep.a liblockdep.so +BIN_FILE = lockdep CONFIG_INCLUDES = CONFIG_LIBS =
@@ -229,7 +232,8 @@ define do_install endef install_lib: all_cmd - $(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ)) + $(Q)$(call do_install,$(LIB_FILE),$(libdir_SQ)) + $(Q)$(call do_install,$(BIN_FILE),$(bindir_SQ)) install: install_lib
tools/lib/lockdep/lockdep new file +3 -0
@@ -0,0 +1,3 @@ +#! /bin/bash + +LD_PRELOAD="liblockdep.so $LD_PRELOAD" "$@"
[tip:core/locking] liblockdep: Remove the need for liblockdep_init()
In reply to Sasha LevinCommit-ID: 62347c63f0646e76a36dc7039d395e0faa880c79 Gitweb: http://git.kernel.org/tip/62347c63f0646e76a36dc7039d395e0faa880c79 Author: Sasha Levin <[email protected]> AuthorDate: Sat, 9 Feb 2013 19:39:31 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 11 Feb 2013 10:12:36 +0100
liblockdep: Remove the need for liblockdep_init()
Use a constructor in the library instead of making the user manually call liblockdep_init().
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)
tools/lib/lockdep/common.c +1 -1
@@ -10,7 +10,7 @@ __thread struct task_struct current_obj;bool debug_locks = true;bool debug_locks_silent; -void liblockdep_init (void ) +__attribute__((constructor))static void liblockdep_init (void ) {lockdep_init (); }
tools/lib/lockdep/include/liblockdep/common.h +0 -1
@@ -26,7 +26,6 @@ struct lockdep_map {#endif }; -void liblockdep_init (void );void liblockdep_set_thread (void );void lockdep_init_map (struct lockdep_map *lock,const char *name,struct lock_class_key *key,int subclass);
tools/lib/lockdep/tests/AA.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBCCA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABBCCDDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCABC.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCDBCDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {liblockdep_pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();liblockdep_pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/ABCDBDDA.c +0 -1
@@ -5,7 +5,6 @@ void main(void) {pthread_mutex_t a, b, c, d; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/tests/WW.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_rwlock_t a, b; -liblockdep_init ();liblockdep_set_thread ();pthread_rwlock_init (&a,NULL );
tools/lib/lockdep/tests/unlock_balance.c +0 -1
@@ -4,7 +4,6 @@ void main(void) {pthread_mutex_t a; -liblockdep_init ();liblockdep_set_thread ();pthread_mutex_init (&a,NULL );
tools/lib/lockdep/uinclude/linux/lockdep.h +0 -1
@@ -25,7 +25,6 @@ struct task_struct {extern __threadstruct task_struct current_obj;#define current (¤t_obj) -void liblockdep_init (void );void liblockdep_set_thread (void );#define debug_locks_off () 1
Quoted 4 lines · Sasha Levin
Use a constructor in the library instead of making the user manually call
liblockdep_init().Signed-off-by Sasha Levin <[email protected]>
Quoted 14 lines
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)
Note that due to the heavy objections in the kvmtool thread I have removed the tools/lib/lockdep library and tooling commits from the locking tree - to be able to merge the other locking commits upstream.
I'm pretty sad about this outcome as your code really brought new development life into lockdep - if you still want to pursue this approach then you might want to try it via the tools/kvm tree, or via a separate project.
Thanks,
Ingo
Quoted 22 lines · Ingo Molnar
Quoted 4 lines · Sasha Levin
Use a constructor in the library instead of making the user manually call
liblockdep_init().Signed-off-by Sasha Levin <[email protected]>Quoted 14 lines
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)
Quoted 4 lines
Note that due to the heavy objections in the kvmtool thread I have removed the
tools/lib/lockdeplibrary and tooling commits from the locking tree - to be able to merge the other locking commits upstream.
Understood.
Quoted 4 lines
I'm pretty sad about this outcome as your code really brought new development life into lockdep - if you still want to pursue this approach then you might want to try it via the
tools/kvmtree, or via a separate project.
I'm most likely to just fold it into a standalone project since I'm not quite certain the purpose of tools/ at this point.
Thanks,
Sasha
Quoted 30 lines · Sasha Levin
Quoted 22 lines · Ingo Molnar
Quoted 4 lines · Sasha Levin
Use a constructor in the library instead of making the user manually call
liblockdep_init().Signed-off-by Sasha Levin <[email protected]>Quoted 14 lines
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)Quoted 4 lines
Note that due to the heavy objections in the kvmtool thread I have removed the
tools/lib/lockdeplibrary and tooling commits from the locking tree - to be able to merge the other locking commits upstream.Understood.
Quoted 8 lines
Quoted 4 lines
I'm pretty sad about this outcome as your code really brought new development life into lockdep - if you still want to pursue this approach then you might want to try it via the
tools/kvmtree, or via a separate project.I'm most likely to just fold it into a standalone project since I'm not quite certain the purpose of
tools/at this point.
You could also tempt Linus with a standalone pull request - altough at this point I'm not sure he'd take it.
Sharing the source code between user-space and kernel space makes quite a bit of sense, and copying files, while it works, just encourages needless forking. The impact of your changes on kernel/lockdep.c was minimal:
47dd80e801c3 lockdep: Be nice about building from userspace
kernel/lockdep.c | 4 ++++ 1 file changed, 4 insertions(+)
So I don't see any substantial 'drag' or downside on the kernel lockdep subsystem - and I see a lot of upsides from exposing user-space to the lockdep code.
Have you tried to check the locking of something more complex, such as Firefox? (assuming it uses pthread mutexes and rwlocks - I'm not sure about that.)
Thanks,
Ingo
Quoted 38 lines · Ingo Molnar
Quoted 35 lines · Sasha Levin
Quoted 22 lines · Ingo Molnar
Quoted 4 lines · Sasha Levin
Use a constructor in the library instead of making the user manually call
liblockdep_init().Signed-off-by Sasha Levin <[email protected]>Quoted 14 lines
--- tools/lib/lockdep/common.c | 2 +- tools/lib/lockdep/include/liblockdep/common.h | 1 - tools/lib/lockdep/tests/AA.c | 1 - tools/lib/lockdep/tests/ABBA.c | 1 - tools/lib/lockdep/tests/ABBCCA.c | 1 - tools/lib/lockdep/tests/ABBCCDDA.c | 1 - tools/lib/lockdep/tests/ABCABC.c | 1 - tools/lib/lockdep/tests/ABCDBCDA.c | 1 - tools/lib/lockdep/tests/ABCDBDDA.c | 1 - tools/lib/lockdep/tests/WW.c | 1 - tools/lib/lockdep/tests/unlock_balance.c | 1 - tools/lib/lockdep/uinclude/linux/lockdep.h | 1 - 12 files changed, 1 insertion(+), 12 deletions(-)Quoted 4 lines
Note that due to the heavy objections in the kvmtool thread I have removed the
tools/lib/lockdeplibrary and tooling commits from the locking tree - to be able to merge the other locking commits upstream.Understood.
Quoted 4 lines
I'm pretty sad about this outcome as your code really brought new development life into lockdep - if you still want to pursue this approach then you might want to try it via the
tools/kvmtree, or via a separate project.
Quoted 6 lines
Quoted 3 lines
I'm most likely to just fold it into a standalone project since I'm not quite certain the purpose of
tools/at this point.You could also tempt Linus with a standalone pull request - altough at this point I'm not sure he'd take it.
So I've gone though the kvmtool thread and while liblockdep was referenced several times Linus didn't share his opinion on it.
Linus, would you be interested in adding liblockdep to your tree? I'm not looking to start another threadnaught about pros and cons of userspace code in the kernel, I just want to know how to proceed with liblockdep. Thanks!
Quoted 9 lines
Sharing the source code between user-space and kernel space makes quite a bit of sense, and copying files, while it works, just encourages needless forking. The impact of your changes on
kernel/lockdep.cwas minimal:
47dd80e801c3lockdep: Be nice about building from userspacekernel/lockdep.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 7 lines
So I don't see any substantial 'drag' or downside on the kernel lockdep subsystem - and I see a lot of upsides from exposing user-space to the lockdep code.
Have you tried to check the locking of something more complex, such as Firefox? (assuming it uses pthread mutexes and rwlocks - I'm not sure about that.)
Yup! I was actually working on that the day before you've sent this mail :)
firefox does use pthread locks.
firefox/thunderbird use their own wrappers for malloc, which take locks on the allocation path - this is quite problematic for the current liblockdep code since it tries to allocate lock objects to store the extra lockdep data - which results in a deadlock. The fix is quite trivial, the discovery of this deadlock was quite interesting though :)
Once I got firefox to work properly with liblockdep there was one spew showing up after browsing for a bit but I haven't dug into it yet - waiting for a quiet weekend to do that.
Thanks,
Sasha