Microstate Accounting:
Add hooks into the scheduler to track state changes.
Arrange for parent process's child times to be updated at process exit. 


 kernel/sched.c |    8 ++++++++
 kernel/exit.c  |    3 +++

Index: linux-2.6-ustate/kernel/sched.c
===================================================================
--- linux-2.6-ustate.orig/kernel/sched.c        2005-03-11 09:59:31.109628035 
+1100
+++ linux-2.6-ustate/kernel/sched.c     2005-03-11 09:59:31.116463921 +1100
@@ -635,6 +635,7 @@
  */
 static inline void __activate_task(task_t *p, runqueue_t *rq)
 {
+       msa_set_timer(p, ONACTIVEQUEUE);
        enqueue_task(p, rq->active);
        rq->nr_running++;
 }
@@ -1238,6 +1239,7 @@
                        if (unlikely(!current->array))
                                __activate_task(p, rq);
                        else {
+                               msa_set_timer(p, ONACTIVEQUEUE);
                                p->prio = current->prio;
                                list_add_tail(&p->run_list, &current->run_list);
                                p->array = current->array;
@@ -2422,6 +2424,7 @@
                if (!rq->expired_timestamp)
                        rq->expired_timestamp = jiffies;
                if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
+                       msa_next_state(p, ONEXPIREDQUEUE);
                        enqueue_task(p, rq->expired);
                        if (p->static_prio < rq->best_expired_prio)
                                rq->best_expired_prio = p->static_prio;
@@ -2733,6 +2736,7 @@
                array = rq->active;
                rq->expired_timestamp = 0;
                rq->best_expired_prio = MAX_PRIO;
+               msa_flip_expired(prev);
        } else
                schedstat_inc(rq, sched_noswitch);
 
@@ -2773,6 +2777,8 @@
                rq->curr = next;
                ++*switch_count;
 
+               msa_switch(prev, next);
+
                prepare_arch_switch(rq, next);
                prev = context_switch(rq, prev, next);
                barrier();
@@ -3693,6 +3699,8 @@
         */
        if (rt_task(current))
                target = rq->active;
+       else
+               msa_next_state(current, ONEXPIREDQUEUE);
 
        if (current->array->nr_active == 1) {
                schedstat_inc(rq, yld_act_empty);


Index: linux-2.6-ustate/kernel/exit.c
===================================================================
--- linux-2.6-ustate.orig/kernel/exit.c 2005-03-11 09:59:36.360564796 +1100
+++ linux-2.6-ustate/kernel/exit.c      2005-03-11 09:59:36.364471017 +1100
@@ -93,6 +93,9 @@
        }
 
        sched_exit(p);
+
+       msa_update_parent(p->parent, p);
+
        write_unlock_irq(&tasklist_lock);
        spin_unlock(&p->proc_lock);
        proc_pid_flush(proc_dentry);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to