From 9374a7c30b6906d01c548833fb8a7b65ba4b5ccc Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Thu, 14 Mar 2013 12:22:41 -0400 Subject: Make lock name alloc dynamic --- include/litmus/locking.h | 3 +-- litmus/fifo_lock.c | 14 ++++++++++---- litmus/prioq_lock.c | 13 +++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/litmus/locking.h b/include/litmus/locking.h index 02cc9cf4bb55..3ae6692dbe95 100644 --- a/include/litmus/locking.h +++ b/include/litmus/locking.h @@ -48,8 +48,7 @@ struct litmus_lock { #endif struct litmus_lock_proc_ops *proc; - struct proc_dir_entry *proc_entry; - char name[LOCK_NAME_LEN]; + char *name; }; #ifdef CONFIG_LITMUS_DGL_SUPPORT diff --git a/litmus/fifo_lock.c b/litmus/fifo_lock.c index b3e956f5a93a..0cbba2424701 100644 --- a/litmus/fifo_lock.c +++ b/litmus/fifo_lock.c @@ -878,14 +878,20 @@ static int fifo_proc_print(char *page, char **start, off_t off, int count, int * static void fifo_proc_add(struct litmus_lock* l) { + if (!l->name) + l->name = kmalloc(LOCK_NAME_LEN*sizeof(char), GFP_KERNEL); snprintf(l->name, LOCK_NAME_LEN, "fifo-%d", l->ident); - - l->proc_entry = litmus_add_proc_lock(l, fifo_proc_print); + litmus_add_proc_lock(l, fifo_proc_print); } static void fifo_proc_remove(struct litmus_lock* l) { - litmus_remove_proc_lock(l); + if (l->name) { + litmus_remove_proc_lock(l); + + kfree(l->name); + l->name = NULL; + } } static struct litmus_lock_proc_ops fifo_proc_ops = @@ -905,7 +911,7 @@ struct litmus_lock* fifo_mutex_new(struct litmus_lock_ops* ops) memset(mutex, 0, sizeof(*mutex)); mutex->litmus_lock.ops = ops; - mutex->owner = NULL; + mutex->owner = NULL; mutex->hp_waiter = NULL; init_waitqueue_head(&mutex->wait); diff --git a/litmus/prioq_lock.c b/litmus/prioq_lock.c index 142f56fe9099..c9ffab1564c3 100644 --- a/litmus/prioq_lock.c +++ b/litmus/prioq_lock.c @@ -1454,14 +1454,20 @@ static int prioq_proc_print(char *page, char **start, off_t off, int count, int static void prioq_proc_add(struct litmus_lock* l) { + if (!l->name) + l->name = kmalloc(LOCK_NAME_LEN*sizeof(char), GFP_KERNEL); snprintf(l->name, LOCK_NAME_LEN, "prioq-%d", l->ident); - - l->proc_entry = litmus_add_proc_lock(l, prioq_proc_print); + litmus_add_proc_lock(l, prioq_proc_print); } static void prioq_proc_remove(struct litmus_lock* l) { - litmus_remove_proc_lock(l); + if (l->name) { + litmus_remove_proc_lock(l); + + kfree(l->name); + l->name = NULL; + } } static struct litmus_lock_proc_ops prioq_proc_ops = @@ -1485,7 +1491,6 @@ struct litmus_lock* prioq_mutex_new(struct litmus_lock_ops* ops) mutex->hp_waiter = NULL; init_waitqueue_head(&mutex->wait); - #ifdef CONFIG_DEBUG_SPINLOCK { __raw_spin_lock_init(&mutex->lock, -- cgit v1.2.2