From 9bddb58d92af43a8b0518835ee237e6f058cff95 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Mon, 4 Apr 2005 03:53:32 +0000 Subject: [PATCH] Re-schedule the timeout here instead of in on_timer(). Sun Apr 3 23:28:45 2005 Soeren Sandmann * sysprof-module.c (do_generate): Re-schedule the timeout here instead of in on_timer(). * sysprof-module.c (on_timer): Only block tasks in the TASK_RUNNING state. --- ChangeLog | 8 +++++++ TODO | 10 ++++----- sysprof-module.c | 56 ++++++++++++++---------------------------------- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index da3e1d6d..1bab9ad1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Apr 3 23:28:45 2005 Soeren Sandmann + + * sysprof-module.c (do_generate): Re-schedule the timeout here + instead of in on_timer(). + + * sysprof-module.c (on_timer): Only block tasks in the + TASK_RUNNING state. + Sun Apr 3 17:03:33 2005 Soeren Sandmann * sysprof-module.c (queue_generate_stack_trace): Put current diff --git a/TODO b/TODO index 2160d5d4..6f4e794e 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,7 @@ Before 1.0: - grep FIXME +- When the module is unloaded, kill all processes blocking in read - Need to make "make install" work (how do you know where to install kernel modules?) - Find out what distributions it actually works on @@ -18,7 +19,7 @@ Before 1.0: - hook up menu items view/start etc (or possibly get rid of them or move them) - give profiles on the command line -- autoconfuscate? +- auto*? - .desktop file - Consider expanding a few more levels of a new descendants tree @@ -81,10 +82,6 @@ Before 1.2: - hide internal stuff in ProfileDescendant -- kernel module should put process to sleep before sampling. Should get us - more accurate data - - Later: - Figure out how Google's pprof script works. Then add real call graph @@ -154,6 +151,9 @@ Later: DONE: +- kernel module should put process to sleep before sampling. Should get us + more accurate data + - Make sure samples label shows correct nunber after Open - Move "samples" label to the toolbar, then get rid of statusbar. diff --git a/sysprof-module.c b/sysprof-module.c index 3915d6bc..f7438136 100644 --- a/sysprof-module.c +++ b/sysprof-module.c @@ -261,8 +261,6 @@ generate_stack_trace(struct task_struct *task, } struct work_struct work; -static int in_queue; -static int saved_state; DECLARE_WAIT_QUEUE_HEAD (wait_to_be_scanned); @@ -271,8 +269,11 @@ do_generate (void *data) { struct task_struct *task = data; struct task_struct *g, *p; - + /* Make sure the thread still exists */ + /* FIXME: this is probably not necessary anymore, now that + * we make the process sleep + */ do_each_thread (g, p) { if (p == task) { generate_stack_trace(task, head); @@ -281,34 +282,14 @@ do_generate (void *data) head = &stack_traces[0]; wake_up (&wait_for_trace); - + wake_up_process (task); + goto out; } } while_each_thread (g, p); out: - wake_up_process (task); - in_queue = 0; -} - -static void -queue_generate_stack_trace (struct task_struct *cur) -{ - if (in_queue) - return; - -#if 0 - printk(KERN_ALERT "qst: current: %d\n", current? current->pid : -1); -#endif - - INIT_WORK (&work, do_generate, cur); - - in_queue = 1; - - schedule_work (&work); - - saved_state = cur->state; - set_task_state (cur, TASK_UNINTERRUPTIBLE); + add_timeout (INTERVAL, on_timer); } static void @@ -321,21 +302,16 @@ on_timer(unsigned long dong) ; #endif - if (current && current->pid != 0) { -#if 0 - printk(KERN_ALERT "current: %d\n", current->pid); -#endif - queue_generate_stack_trace (current); - } -#if 0 - else if (!current) - printk(KERN_ALERT "no current\n"); - else - printk(KERN_ALERT "current is 0\n"); -#endif + if (current && current->state == TASK_RUNNING && current->pid != 0) { + INIT_WORK (&work, do_generate, current); - - add_timeout (INTERVAL, on_timer); + set_current_state (TASK_UNINTERRUPTIBLE); + + schedule_work (&work); + } + else { + add_timeout (INTERVAL, on_timer); + } } static int