From 3e41d4826b0aa175c3f194548fa6ab20cd1cc32d Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Sun, 4 Mar 2012 21:20:45 -0500 Subject: Clean up PAI. --- litmus/sched_cedf.c | 179 +------------------------------------------------ litmus/sched_gsn_edf.c | 170 ++++------------------------------------------ 2 files changed, 15 insertions(+), 334 deletions(-) diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 3251fb1602f8..394caf9329b4 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c @@ -466,79 +466,8 @@ static void __do_lit_tasklet(struct tasklet_struct* tasklet, unsigned long flush } -static void __extract_tasklets(cedf_domain_t* cluster, struct task_struct* task, struct tasklet_head* task_tasklets) -{ - struct tasklet_struct* step; - struct tasklet_struct* tasklet; - struct tasklet_struct* prev; - - task_tasklets->head = NULL; - task_tasklets->tail = &(task_tasklets->head); - - prev = NULL; - for(step = cluster->pending_tasklets.head; step != NULL; step = step->next) - { - if(step->owner == task) - { - TRACE("%s: Found tasklet to flush: %d\n", __FUNCTION__, step->owner->pid); - - tasklet = step; - - if(prev) { - prev->next = tasklet->next; - } - else if(cluster->pending_tasklets.head == tasklet) { - // we're at the head. - cluster->pending_tasklets.head = tasklet->next; - } - - if(cluster->pending_tasklets.tail == &tasklet) { - // we're at the tail - if(prev) { - cluster->pending_tasklets.tail = &prev; - } - else { - cluster->pending_tasklets.tail = &(cluster->pending_tasklets.head); - } - } - - tasklet->next = NULL; - *(task_tasklets->tail) = tasklet; - task_tasklets->tail = &(tasklet->next); - } - else { - prev = step; - } - } -} - static void flush_tasklets(cedf_domain_t* cluster, struct task_struct* task) { -#if 0 - unsigned long flags; - struct tasklet_head task_tasklets; - struct tasklet_struct* step; - - raw_spin_lock_irqsave(&cluster->cluster_lock, flags); - __extract_tasklets(cluster, task, &task_tasklets); - raw_spin_unlock_irqrestore(&cluster->cluster_lock, flags); - - if(cluster->pending_tasklets.head != NULL) { - TRACE("%s: Flushing tasklets for %d...\n", __FUNCTION__, task->pid); - } - - // now execute any flushed tasklets. - for(step = cluster->pending_tasklets.head; step != NULL; /**/) - { - struct tasklet_struct* temp = step->next; - - step->next = NULL; - __do_lit_tasklet(step, 1ul); - - step = temp; - } -#endif - // lazy flushing. // just change ownership to NULL and let an idle processor // take care of it. :P @@ -548,10 +477,8 @@ static void flush_tasklets(cedf_domain_t* cluster, struct task_struct* task) raw_spin_lock_irqsave(&cluster->cluster_lock, flags); - for(step = cluster->pending_tasklets.head; step != NULL; step = step->next) - { - if(step->owner == task) - { + for(step = cluster->pending_tasklets.head; step != NULL; step = step->next) { + if(step->owner == task) { TRACE("%s: Found tasklet to flush: %d\n", __FUNCTION__, step->owner->pid); step->owner = NULL; } @@ -565,7 +492,6 @@ static void do_lit_tasklets(cedf_domain_t* cluster, struct task_struct* sched_ta { int work_to_do = 1; struct tasklet_struct *tasklet = NULL; - //struct tasklet_struct *step; unsigned long flags; while(work_to_do) { @@ -575,17 +501,6 @@ static void do_lit_tasklets(cedf_domain_t* cluster, struct task_struct* sched_ta // remove tasklet at head of list if it has higher priority. raw_spin_lock_irqsave(&cluster->cluster_lock, flags); -/* - step = cluster->pending_tasklets.head; - TRACE("%s: (BEFORE) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(cluster->pending_tasklets.tail), (*(cluster->pending_tasklets.tail) != NULL) ? (*(cluster->pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - if(cluster->pending_tasklets.head != NULL) { // remove tasklet at head. tasklet = cluster->pending_tasklets.head; @@ -612,21 +527,8 @@ static void do_lit_tasklets(cedf_domain_t* cluster, struct task_struct* sched_ta TRACE("%s: Tasklet queue is empty.\n", __FUNCTION__); } - - /* - step = cluster->pending_tasklets.head; - TRACE("%s: (AFTER) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(cluster->pending_tasklets.tail), (*(cluster->pending_tasklets.tail) != NULL) ? (*(cluster->pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - raw_spin_unlock_irqrestore(&cluster->cluster_lock, flags); - TS_NV_SCHED_BOTISR_END; if(tasklet) { @@ -637,8 +539,6 @@ static void do_lit_tasklets(cedf_domain_t* cluster, struct task_struct* sched_ta work_to_do = 0; } } - - //TRACE("%s: exited.\n", __FUNCTION__); } @@ -646,28 +546,6 @@ static void run_tasklets(struct task_struct* sched_task) { cedf_domain_t* cluster; -#if 0 - int task_is_rt = is_realtime(sched_task); - cedf_domain_t* cluster; - - if(is_realtime(sched_task)) { - cluster = task_cpu_cluster(sched_task); - } - else { - cluster = remote_cluster(get_cpu()); - } - - if(cluster && cluster->pending_tasklets.head != NULL) { - TRACE("%s: There are tasklets to process.\n", __FUNCTION__); - - do_lit_tasklets(cluster, sched_task); - } - - if(!task_is_rt) { - put_cpu_no_resched(); - } -#else - preempt_disable(); cluster = (is_realtime(sched_task)) ? @@ -680,8 +558,6 @@ static void run_tasklets(struct task_struct* sched_task) } preempt_enable_no_resched(); - -#endif } @@ -689,18 +565,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet, cedf_domain_t* clu { struct tasklet_struct* step; - /* - step = cluster->pending_tasklets.head; - TRACE("%s: (BEFORE) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(cluster->pending_tasklets.tail), (*(cluster->pending_tasklets.tail) != NULL) ? (*(cluster->pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - - tasklet->next = NULL; // make sure there are no old values floating around step = cluster->pending_tasklets.head; @@ -720,8 +584,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet, cedf_domain_t* clu } else { - //WARN_ON(1 == 1); - // insert the tasklet somewhere in the middle. TRACE("%s: tasklet belongs somewhere in the middle.\n", __FUNCTION__); @@ -753,22 +615,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet, cedf_domain_t* clu cluster->pending_tasklets.head = tasklet; } } - - /* - step = cluster->pending_tasklets.head; - TRACE("%s: (AFTER) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(cluster->pending_tasklets.tail), (*(cluster->pending_tasklets.tail) != NULL) ? (*(cluster->pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - -// TODO: Maintain this list in priority order. -// tasklet->next = NULL; -// *(cluster->pending_tasklets.tail) = tasklet; -// cluster->pending_tasklets.tail = &tasklet->next; } static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) @@ -792,7 +638,6 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) thisCPU = smp_processor_id(); -#if 1 #ifdef CONFIG_SCHED_CPU_AFFINITY { cpu_entry_t* affinity = NULL; @@ -812,7 +657,6 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) targetCPU = affinity; } -#endif #endif if (targetCPU == NULL) { @@ -859,24 +703,7 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) return(1); // success } - -#endif - - - - - - - - - - - - - - - - +#endif // PAI /* Getting schedule() right is a bit tricky. schedule() may not make any * assumptions on the state of the current task since it may be called for a diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index 3ddab5875c8c..0d86587915c5 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c @@ -448,76 +448,23 @@ static void __do_lit_tasklet(struct tasklet_struct* tasklet, unsigned long flush } -static void __extract_tasklets(struct task_struct* task, struct tasklet_head* task_tasklets) +static void flush_tasklets(struct task_struct* task) { + // lazy flushing. + // just change ownership to NULL and let idel processor + // take care of it. :P + struct tasklet_struct* step; - struct tasklet_struct* tasklet; - struct tasklet_struct* prev; - - task_tasklets->head = NULL; - task_tasklets->tail = &(task_tasklets->head); - - prev = NULL; - for(step = gsnedf_pending_tasklets.head; step != NULL; step = step->next) - { - if(step->owner == task) - { + unsigned long flags; + + raw_spin_lock_irqsave(&gsnedf_lock, flags); + for(step = gsnedf_pending_tasklets.head; step != NULL; step = step->next) { + if(step->owner == task) { TRACE("%s: Found tasklet to flush: %d\n", __FUNCTION__, step->owner->pid); - - tasklet = step; - - if(prev) { - prev->next = tasklet->next; - } - else if(gsnedf_pending_tasklets.head == tasklet) { - // we're at the head. - gsnedf_pending_tasklets.head = tasklet->next; - } - - if(gsnedf_pending_tasklets.tail == &tasklet) { - // we're at the tail - if(prev) { - gsnedf_pending_tasklets.tail = &prev; - } - else { - gsnedf_pending_tasklets.tail = &(gsnedf_pending_tasklets.head); - } - } - - tasklet->next = NULL; - *(task_tasklets->tail) = tasklet; - task_tasklets->tail = &(tasklet->next); - } - else { - prev = step; + step->owner = NULL; } } -} - -static void flush_tasklets(struct task_struct* task) -{ - unsigned long flags; - struct tasklet_head task_tasklets; - struct tasklet_struct* step; - - raw_spin_lock_irqsave(&gsnedf_lock, flags); - __extract_tasklets(task, &task_tasklets); raw_spin_unlock_irqrestore(&gsnedf_lock, flags); - - if(gsnedf_pending_tasklets.head != NULL) { - TRACE("%s: Flushing tasklets for %d...\n", __FUNCTION__, task->pid); - } - - // now execute any flushed tasklets. - for(step = gsnedf_pending_tasklets.head; step != NULL; /**/) - { - struct tasklet_struct* temp = step->next; - - step->next = NULL; - __do_lit_tasklet(step, 1ul); - - step = temp; - } } @@ -535,18 +482,6 @@ static void do_lit_tasklets(struct task_struct* sched_task) // remove tasklet at head of list if it has higher priority. raw_spin_lock_irqsave(&gsnedf_lock, flags); - /* - step = gsnedf_pending_tasklets.head; - TRACE("%s: (BEFORE) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(gsnedf_pending_tasklets.tail), (*(gsnedf_pending_tasklets.tail) != NULL) ? (*(gsnedf_pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - - if(gsnedf_pending_tasklets.head != NULL) { // remove tasklet at head. tasklet = gsnedf_pending_tasklets.head; @@ -573,18 +508,6 @@ static void do_lit_tasklets(struct task_struct* sched_task) TRACE("%s: Tasklet queue is empty.\n", __FUNCTION__); } - - /* - step = gsnedf_pending_tasklets.head; - TRACE("%s: (AFTER) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(gsnedf_pending_tasklets.tail), (*(gsnedf_pending_tasklets.tail) != NULL) ? (*(gsnedf_pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - raw_spin_unlock_irqrestore(&gsnedf_lock, flags); TS_NV_SCHED_BOTISR_END; @@ -604,28 +527,6 @@ static void do_lit_tasklets(struct task_struct* sched_task) static void run_tasklets(struct task_struct* sched_task) { -#if 0 - int task_is_rt = is_realtime(sched_task); - cedf_domain_t* cluster; - - if(is_realtime(sched_task)) { - cluster = task_cpu_cluster(sched_task); - } - else { - cluster = remote_cluster(get_cpu()); - } - - if(cluster && gsnedf_pending_tasklets.head != NULL) { - TRACE("%s: There are tasklets to process.\n", __FUNCTION__); - - do_lit_tasklets(cluster, sched_task); - } - - if(!task_is_rt) { - put_cpu_no_resched(); - } -#else - preempt_disable(); if(gsnedf_pending_tasklets.head != NULL) { @@ -634,8 +535,6 @@ static void run_tasklets(struct task_struct* sched_task) } preempt_enable_no_resched(); - -#endif } @@ -643,18 +542,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet) { struct tasklet_struct* step; - /* - step = gsnedf_pending_tasklets.head; - TRACE("%s: (BEFORE) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(gsnedf_pending_tasklets.tail), (*(gsnedf_pending_tasklets.tail) != NULL) ? (*(gsnedf_pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - - tasklet->next = NULL; // make sure there are no old values floating around step = gsnedf_pending_tasklets.head; @@ -673,9 +560,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet) gsnedf_pending_tasklets.tail = &(tasklet->next); } else { - - //WARN_ON(1 == 1); - // insert the tasklet somewhere in the middle. TRACE("%s: tasklet belongs somewhere in the middle.\n", __FUNCTION__); @@ -698,22 +582,6 @@ static void __add_pai_tasklet(struct tasklet_struct* tasklet) gsnedf_pending_tasklets.head = tasklet; } } - - /* - step = gsnedf_pending_tasklets.head; - TRACE("%s: (AFTER) dumping tasklet queue...\n", __FUNCTION__); - while(step != NULL){ - TRACE("%s: %p (%d)\n", __FUNCTION__, step, step->owner->pid); - step = step->next; - } - TRACE("%s: tail = %p (%d)\n", __FUNCTION__, *(gsnedf_pending_tasklets.tail), (*(gsnedf_pending_tasklets.tail) != NULL) ? (*(gsnedf_pending_tasklets.tail))->owner->pid : -1); - TRACE("%s: done.\n", __FUNCTION__); - */ - - // TODO: Maintain this list in priority order. - // tasklet->next = NULL; - // *(gsnedf_pending_tasklets.tail) = tasklet; - // gsnedf_pending_tasklets.tail = &tasklet->next; } static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) @@ -735,7 +603,6 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) thisCPU = smp_processor_id(); -#if 1 #ifdef CONFIG_SCHED_CPU_AFFINITY { cpu_entry_t* affinity = NULL; @@ -759,7 +626,6 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) targetCPU = affinity; } -#endif #endif if (targetCPU == NULL) { @@ -806,19 +672,7 @@ static int enqueue_pai_tasklet(struct tasklet_struct* tasklet) return(1); // success } - -#endif - - - - - - - - - - - +#endif // end PAI /* Getting schedule() right is a bit tricky. schedule() may not make any -- cgit v1.2.2