From 13d469f659b8515214ecd6523db5c0d58fe01ff8 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Mon, 1 Jun 2009 16:02:10 +0300 Subject: [PATCH] Removed all unecessary prints from the mutex test and the kernel - removed (%d) Sleeping print from contended kernel mutexes. - removed (%d) Waiting print from WAIT_EVENT used by the pager for suspending tasks. - removed prints from the mutex_control syscall and user mutex test. --- include/l4/lib/wait.h | 2 +- src/api/mutex.c | 2 -- src/generic/kmalloc.c | 2 +- src/lib/mutex.c | 2 +- src/lib/wait.c | 14 +++++++------- tasks/test0/src/mutextest.c | 36 +++++++++++++++--------------------- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/include/l4/lib/wait.h b/include/l4/lib/wait.h index 6dc7af6..d43ae5a 100644 --- a/include/l4/lib/wait.h +++ b/include/l4/lib/wait.h @@ -59,7 +59,7 @@ do { \ task_set_wqh(current, wqh, &wq); \ (wqh)->sleepers++; \ list_add_tail(&wq.task_list, &(wqh)->task_list);\ - printk("(%d) waiting...\n", current->tid); \ + /* printk("(%d) waiting...\n", current->tid);*/ \ sched_prepare_sleep(); \ spin_unlock(&(wqh)->slock); \ schedule(); \ diff --git a/src/api/mutex.c b/src/api/mutex.c index ef3d482..f5bdbdd 100644 --- a/src/api/mutex.c +++ b/src/api/mutex.c @@ -263,11 +263,9 @@ int sys_mutex_control(syscall_context_t *regs) switch (mutex_op) { case MUTEX_CONTROL_LOCK: - printk("(%d): MUTEX_LOCK\n", current->tid); ret = mutex_control_lock(mutex_physical); break; case MUTEX_CONTROL_UNLOCK: - printk("(%d): MUTEX_UNLOCK\n", current->tid); ret = mutex_control_unlock(mutex_physical); break; default: diff --git a/src/generic/kmalloc.c b/src/generic/kmalloc.c index dac666e..9d4482e 100644 --- a/src/generic/kmalloc.c +++ b/src/generic/kmalloc.c @@ -88,7 +88,7 @@ void *__kmalloc(int size) BUG_ON(size >= PAGE_SIZE); BUG_ON(!(cache = mem_cache_init(alloc_page(), PAGE_SIZE, size, 0))); - printk("%s: Created new cache for size %d\n", __FUNCTION__, size); + // printk("%s: Created new cache for size %d\n", __FUNCTION__, size); list_add(&cache->list, &km_pool.pool_head[index].cache_list); km_pool.pool_head[index].occupied = 1; km_pool.pool_head[index].total_caches++; diff --git a/src/lib/mutex.c b/src/lib/mutex.c index 4212cc6..f4af0e0 100644 --- a/src/lib/mutex.c +++ b/src/lib/mutex.c @@ -126,7 +126,7 @@ int mutex_lock(struct mutex *mutex) mutex->wqh.sleepers++; sched_prepare_sleep(); spin_unlock(&mutex->wqh.slock); - printk("(%d) sleeping...\n", current->tid); + // printk("(%d) sleeping...\n", current->tid); schedule(); /* Did we wake up normally or get interrupted */ diff --git a/src/lib/wait.c b/src/lib/wait.c index 3e8da73..1d1f670 100644 --- a/src/lib/wait.c +++ b/src/lib/wait.c @@ -65,8 +65,8 @@ int wait_on_prepare(struct waitqueue_head *wqh, struct waitqueue *wq) list_add_tail(&wq->task_list, &wqh->task_list); task_set_wqh(current, wqh, wq); sched_prepare_sleep(); - printk("(%d) waiting on wqh at: 0x%p\n", - current->tid, wqh); + //printk("(%d) waiting on wqh at: 0x%p\n", + // current->tid, wqh); spin_unlock(&wqh->slock); return 0; @@ -81,8 +81,8 @@ int wait_on(struct waitqueue_head *wqh) list_add_tail(&wq.task_list, &wqh->task_list); task_set_wqh(current, wqh, &wq); sched_prepare_sleep(); - printk("(%d) waiting on wqh at: 0x%p\n", - current->tid, wqh); + //printk("(%d) waiting on wqh at: 0x%p\n", + // current->tid, wqh); spin_unlock(&wqh->slock); schedule(); @@ -95,7 +95,7 @@ int wait_on(struct waitqueue_head *wqh) return 0; } -/* Wake up all */ +/* Wake up all - FIXME: this is buggy with double spin_unlock */ void wake_up_all(struct waitqueue_head *wqh, unsigned int flags) { BUG_ON(wqh->sleepers < 0); @@ -111,7 +111,7 @@ void wake_up_all(struct waitqueue_head *wqh, unsigned int flags) wqh->sleepers--; if (flags & WAKEUP_INTERRUPT) sleeper->flags |= TASK_INTERRUPTED; - printk("(%d) Waking up (%d)\n", current->tid, sleeper->tid); + // printk("(%d) Waking up (%d)\n", current->tid, sleeper->tid); spin_unlock(&wqh->slock); if (flags & WAKEUP_SYNC) @@ -138,7 +138,7 @@ void wake_up(struct waitqueue_head *wqh, unsigned int flags) task_unset_wqh(sleeper); if (flags & WAKEUP_INTERRUPT) sleeper->flags |= TASK_INTERRUPTED; - printk("(%d) Waking up (%d)\n", current->tid, sleeper->tid); + // printk("(%d) Waking up (%d)\n", current->tid, sleeper->tid); spin_unlock(&wqh->slock); if (flags & WAKEUP_SYNC) diff --git a/tasks/test0/src/mutextest.c b/tasks/test0/src/mutextest.c index aff9f47..d920c6e 100644 --- a/tasks/test0/src/mutextest.c +++ b/tasks/test0/src/mutextest.c @@ -52,7 +52,7 @@ int user_mutex_test(void) __FUNCTION__, (int)base); goto out_err; } else - printf("mmap: Anonymous shared buffer at %p\n", base); + test_printf("mmap: Anonymous shared buffer at %p\n", base); shared_page = base; @@ -64,32 +64,29 @@ int user_mutex_test(void) /* Fork the current task */ if ((child = fork()) < 0) { - printf("%s: Fork failed with %d\n", __FUNCTION__, errno); + test_printf("%s: Fork failed with %d\n", __FUNCTION__, errno); goto out_err; } if (child) - printf("%d: Created child with pid %d\n", getpid(), child); + test_printf("%d: Created child with pid %d\n", getpid(), child); else - printf("Child %d running.\n", getpid()); + test_printf("Child %d running.\n", getpid()); /* Child locks and produces */ if (child == 0) { - for (int x = 0; x < 10000; x++) { + for (int x = 0; x < 2000; x++) { int temp; /* Lock page */ - printf("Child locking page.\n"); + test_printf("Child locking page.\n"); l4_mutex_lock(&shared_page->mutex); /* Read variable */ - printf("Child locked page.\n"); + test_printf("Child locked page.\n"); temp = shared_page->shared_var; - /* Thread switch */ - l4_thread_switch(0); - /* Update local copy */ temp++; @@ -99,11 +96,11 @@ int user_mutex_test(void) /* Write back the result */ shared_page->shared_var = temp; - printf("Child modified. Unlocking...\n"); + test_printf("Child modified. Unlocking...\n"); /* Unlock */ l4_mutex_unlock(&shared_page->mutex); - printf("Child unlocked page.\n"); + test_printf("Child unlocked page.\n"); /* Thread switch */ l4_thread_switch(0); @@ -114,20 +111,17 @@ int user_mutex_test(void) /* Parent locks and consumes */ } else { - for (int x = 0; x < 10000; x++) { + for (int x = 0; x < 2000; x++) { int temp; /* Lock page */ - printf("Parent locking page.\n"); + test_printf("Parent locking page.\n"); l4_mutex_lock(&shared_page->mutex); /* Read variable */ - printf("Parent locked page.\n"); + test_printf("Parent locked page.\n"); temp = shared_page->shared_var; - /* Thread switch */ - l4_thread_switch(0); - /* Update local copy */ temp--; @@ -137,11 +131,11 @@ int user_mutex_test(void) /* Write back the result */ shared_page->shared_var = temp; - printf("Parent modified. Unlocking...\n"); + test_printf("Parent modified. Unlocking...\n"); /* Unlock */ l4_mutex_unlock(&shared_page->mutex); - printf("Parent unlocked page.\n"); + test_printf("Parent unlocked page.\n"); /* Thread switch */ l4_thread_switch(0); @@ -149,7 +143,7 @@ int user_mutex_test(void) /* Sync with the child */ l4_receive(child); - printf("Parent checking validity of value.\n"); + test_printf("Parent checking validity of value.\n"); if (shared_page->shared_var != 0) goto out_err;