From a4d08351aacc56e79b03c85fc9bbcb03567309fa Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sat, 27 Oct 2007 15:47:22 -0400 Subject: cleanup: tidy up code before release This gets rid of quite a few FIXMEs and TODOs, as well as some cruft. --- include/linux/litmus.h | 23 +------------ include/linux/pfair_math.h | 3 ++ include/linux/sched_plugin.h | 8 ----- kernel/litmus.c | 15 ++++---- kernel/sched.c | 11 +++--- kernel/sched_adaptive.c | 4 +-- kernel/sched_edf_hsb.c | 81 +------------------------------------------- kernel/sched_global_edf.c | 12 ------- kernel/sched_part_edf.c | 11 +++--- kernel/sched_pfair.c | 2 -- kernel/sched_plugin.c | 53 ----------------------------- kernel/sched_psn_edf.c | 29 ---------------- 12 files changed, 22 insertions(+), 230 deletions(-) diff --git a/include/linux/litmus.h b/include/linux/litmus.h index dc39ecbf7e..259594e922 100644 --- a/include/linux/litmus.h +++ b/include/linux/litmus.h @@ -35,7 +35,6 @@ typedef enum { typedef enum { LITMUS_RESERVED_RANGE = 1024, - ENABLE_WEIGHT_CHANGE_SIGNAL } sched_setup_cmd_t; /* Runtime modes */ @@ -49,30 +48,14 @@ enum rt_mode_t { #define PLUGIN_PFAIR "pfair" #define PLUGIN_PART_EDF "part_edf" #define PLUGIN_GLOBAL_EDF "global_edf" -#define PLUGIN_PFAIR_STAGGER "stagger" -#define PLUGIN_PFAIR_DESYNC "desync" #define PLUGIN_GLOBAL_EDF_NP "global_edf_np" #define PLUGIN_EDF_HSB "edf_hsb" #define PLUGIN_GSN_EDF "gsn_edf" #define PLUGIN_PSN_EDF "psn_edf" #define PLUGIN_ADAPTIVE "adaptive" -/* Additional clone flags - Indicates that the thread is to be used in - realtime mode, therefore it should not be - woken up in a linux manner, - we just set its state to TASK_STOPPED - It must be prepared and added to the ready queue explicitly -*/ - -/* Type definition for our quantums */ -typedef unsigned long long quantum_t; - extern spolicy sched_policy; -extern unsigned long slot_size; -extern unsigned long stagger_offset; - /* RT mode start time */ extern volatile unsigned long rt_start_time; @@ -82,10 +65,6 @@ extern atomic_t rt_mode; #define get_rt_mode() (atomic_read(&rt_mode)) #define set_rt_mode(a) atomic_set(&rt_mode,(a)) -/* CLEANUP: Should be queue_lock, does it really belong here? */ -extern spinlock_t litmus_task_set_lock; - - #define TRACE(fmt, args...) \ sched_trace_log_message("%d: " fmt, raw_smp_processor_id(), ## args) @@ -99,7 +78,7 @@ extern spinlock_t litmus_task_set_lock; do { if (cond) TRACE("BUG_ON(%s) at %s:%d " \ "called from %p current=%s/%d state=%d " \ "flags=%x mode=%d partition=%d cpu=%d rtflags=%d"\ - " job=%u knp=%d timeslice=%u\n", \ + " job=%u knp=%d timeslice=%u\n", \ #cond, __FILE__, __LINE__, __builtin_return_address(0), current->comm, \ current->pid, current->state, current->flags, get_rt_mode(), \ get_partition(current), smp_processor_id(), get_rt_flags(current), \ diff --git a/include/linux/pfair_math.h b/include/linux/pfair_math.h index dab1778f0b..b2a14e4c54 100644 --- a/include/linux/pfair_math.h +++ b/include/linux/pfair_math.h @@ -7,6 +7,9 @@ #include #include +/* Type definition for our quantums */ +typedef unsigned long long quantum_t; + /* * This file defines mathematical functions "ceiling", "floor", * and PFAIR specific functions for computing the release and diff --git a/include/linux/sched_plugin.h b/include/linux/sched_plugin.h index fa0716f0eb..1ea8178b25 100644 --- a/include/linux/sched_plugin.h +++ b/include/linux/sched_plugin.h @@ -33,13 +33,6 @@ struct pi_semaphore { */ typedef void runqueue_t; -/********************* real-time callbacks ********************/ - -/* Special plugin shutdown hook that clear plugin data structures - Currently is not supported -*/ -typedef void (*plugin_shutdown_hook_t) (void); - /********************* scheduler invocation ******************/ @@ -105,7 +98,6 @@ struct sched_plugin { int ready_to_use; /* management interface */ - plugin_shutdown_hook_t shutdown_hook; /*currently unsupported */ mode_change_t mode_change; /* scheduler invocation */ diff --git a/kernel/litmus.c b/kernel/litmus.c index ee1e09a627..8f238ba979 100644 --- a/kernel/litmus.c +++ b/kernel/litmus.c @@ -19,25 +19,22 @@ spolicy sched_policy = SCHED_DEFAULT; int sched_options = 0; -/* avoid races with multiple task wake-ups */ -DEFINE_SPINLOCK(litmus_task_set_lock); /* This is a flag for switching the system into RT mode when it is booted up - * In RT-mode non-realtime tasks are shut down and scheduled as spare - * time available + * In RT-mode non-realtime tasks are scheduled as background tasks. */ -/* The system is booting in non-realtime mode */ +/* The system is booting in non-realtime mode */ atomic_t rt_mode = ATOMIC_INIT(MODE_NON_RT); -/* Here we specify a mode change to be made */ +/* Here we specify a mode change to be made */ atomic_t new_mode = ATOMIC_INIT(MODE_NON_RT); -/* Number of RT tasks that exist in the system */ +/* Number of RT tasks that exist in the system */ atomic_t n_rt_tasks = ATOMIC_INIT(0); -/* Only one process can perform mode change */ +/* Only one CPU may perform a mode change. */ static queuelock_t mode_change_lock; -/* A time instant when we switched to RT mode */ +/* The time instant when we switched to RT mode */ volatile jiffie_t rt_start_time = 0; /* To send signals from the scheduler diff --git a/kernel/sched.c b/kernel/sched.c index d7fd42a431..5ad4276e4b 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -61,9 +61,11 @@ #include #include #include - #include +/* LITMUS: avoid races with multiple task wake-ups */ +DEFINE_SPINLOCK(litmus_task_set_lock); + /* * Convert user-nice values [ -20 ... 0 ... 19 ] * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], @@ -1693,7 +1695,6 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags) if (clone_flags & CLONE_REALTIME) { /* just mark the task as stopped */ - /* CLEANUP: Do we have to remove the task from the rq? */ p->state = TASK_STOPPED; return; } @@ -5541,7 +5542,7 @@ static struct notifier_block __cpuinitdata migration_notifier = { .priority = 10 }; -int __init linux_migration_init(void) +int __init migration_init(void) { void *cpu = (void *)(long)smp_processor_id(); int err; @@ -7003,7 +7004,7 @@ static int update_sched_domains(struct notifier_block *nfb, return NOTIFY_OK; } -void __init linux_sched_init_smp(void) +void __init sched_init_smp(void) { cpumask_t non_isolated_cpus; @@ -7036,7 +7037,7 @@ int in_sched_functions(unsigned long addr) && addr < (unsigned long)__sched_text_end); } -void __init linux_sched_init(void) +void __init sched_init(void) { int i, j, k; diff --git a/kernel/sched_adaptive.c b/kernel/sched_adaptive.c index 97d06b1ad4..319ebbc11c 100644 --- a/kernel/sched_adaptive.c +++ b/kernel/sched_adaptive.c @@ -838,8 +838,6 @@ static noinline void preempt(cpu_entry_t *entry) } else /* in case that it is a remote CPU we have to defer the * the decision to the remote CPU - * FIXME: We could save a few IPI's here if we leave the flag - * set when we are waiting for a np_exit(). */ if (!test_will_schedule(entry->cpu)) smp_send_reschedule(entry->cpu); @@ -1432,7 +1430,7 @@ sched_plugin_t *__init init_adaptive_plugin(void) fc_b = _frac( 303, 1000); optimizer_period = 1000; - optimizer_min_invocation_sep = 50; + optimizer_min_invocation_sep = 200; task_error_threshold = _frac(1, 2); if (!s_plugin.ready_to_use) diff --git a/kernel/sched_edf_hsb.c b/kernel/sched_edf_hsb.c index c2a4c6c679..a2f670d994 100644 --- a/kernel/sched_edf_hsb.c +++ b/kernel/sched_edf_hsb.c @@ -1077,52 +1077,6 @@ static struct task_struct* null_heuristic(struct task_struct *prev, return NULL; } -/*static struct task_struct* history_heuristic(struct task_struct *prev, rt_domain_t* edf) -{ - struct list_head *pos; - struct task_struct* tsk = NULL; - struct task_struct* cur; - - if (is_realtime(prev) && is_running(prev) && - get_rt_flags(prev) != RT_F_SLEEP) - tsk = prev; - list_for_each(pos, &edf->ready_queue) { - cur = list_entry(pos, struct task_struct, rt_list); - if (!tsk || - tsk->rt_param.stats.nontardy_jobs_ctr > - cur->rt_param.stats.nontardy_jobs_ctr) - tsk = cur; - } - if (tsk && tsk->rt_param.stats.nontardy_jobs_ctr < 5) - return tsk; - else - return NULL; -} -*/ -/* TODO: write slack heuristic.*/ -/*static struct task_struct* slack_heuristic(struct task_struct *prev, rt_domain_t* edf) -{ - struct list_head *pos; - struct task_struct* tsk = NULL; - struct task_struct* cur; - - if (is_realtime(prev) && is_running(prev) && - get_rt_flags(prev) != RT_F_SLEEP) - tsk = prev; - list_for_each(pos, &edf->ready_queue) { - cur = list_entry(pos, struct task_struct, rt_list); - if (!tsk || - tsk->rt_param.stats.nontardy_job_ctr > - cur->rt_param.stats.nontardy_job_ctr) - tsk = cur; - } - if (tsk && tsk->rt_param.stats.nontardy_job_ctr < 5) - return tsk; - else - return NULL; -}*/ - - /* caller holds all locks */ @@ -1229,7 +1183,7 @@ static int schedule_srt_be_cap(struct task_struct *prev, int deactivate = 1; be_server_t* bes; cpu_state_t* state; - int type; /* FIXME: Initialize? */ + int type = BG; reschedule: write_lock_irqsave(&srt.ready_lock, flags); @@ -1531,9 +1485,6 @@ static void hsb_wake_up_task(struct task_struct *task) } else if (task->time_slice) { /* came back in time before deadline - * TODO: clip budget to fit into period, otherwise it could - * cause a deadline overrun in the next period, i.e. - * over allocation in the next period. */ set_rt_flags(task, RT_F_RUNNING); hsb_add_ready(task); @@ -1546,43 +1497,16 @@ static void hsb_wake_up_task(struct task_struct *task) static void hsb_task_blocks(struct task_struct *t) { - /* CLEANUP: The BUG_ON actually triggerd in a really weierd case if a - * BEST_EFFORT gets caught in a migration right after execv - * The next version of Litmus should deal with this more gracefully. - */ - - /*BUG_ON(!is_realtime(t));*/ /* not really anything to do since it can only block if * it is running, and when it is not running it is not in any * queue anyway. - * - * TODO: Check whether the assumption is correct for SIGKILL and - * SIGSTOP. */ TRACE("task %d blocks with budget=%d\n", t->pid, t->time_slice); - /*BUG_ON(t->rt_list.next != LIST_POISON1);*/ - /*BUG_ON(t->rt_list.prev != LIST_POISON2);*/ - if (is_be(t)) sched_trace_job_completion(t); } -/* When _tear_down is called, the task should not be in any queue any more - * as it must have blocked first. We don't have any internal state for the task, - * it is all in the task_struct. - */ -static long hsb_tear_down(struct task_struct * t) -{ - /* CLEANUP: see hsb_task_blocks */ - /*BUG_ON(!is_realtime(t)); - TRACE("edf-hsb: tear down called for %d \n", t->pid); - BUG_ON(t->array); - BUG_ON(t->rt_list.next != LIST_POISON1); - BUG_ON(t->rt_list.prev != LIST_POISON2);*/ - return 0; -} - static int hsb_mode_change(int new_mode) { int cpu; @@ -1769,8 +1693,6 @@ static sched_plugin_t s_plugin __cacheline_aligned_in_smp = { .scheduler_tick = hsb_scheduler_tick,\ .prepare_task = hsb_prepare_task,\ .sleep_next_period = edf_sleep_next_period,\ - .tear_down = hsb_tear_down,\ - .shutdown_hook = 0,\ .schedule = hsb_schedule,\ .finish_switch = hsb_finish_switch,\ .mode_change = hsb_mode_change,\ @@ -1789,7 +1711,6 @@ sched_plugin_t *__init init_edf_hsb_plugin(void) capacity_queue_init(&cap_queue); edf_domain_init(&srt, srt_check_resched); edf_domain_init(&be, be_check_resched); - /* TODO: Re-implement FIFO time slicing, was 50ms. */ fifo_domain_init(&hsb_fifo, NULL); for (i = 0; i < NR_CPUS; i++) { diff --git a/kernel/sched_global_edf.c b/kernel/sched_global_edf.c index 6e3928b7df..4b36bc5a48 100644 --- a/kernel/sched_global_edf.c +++ b/kernel/sched_global_edf.c @@ -64,7 +64,6 @@ static void adjust_cpu_queue(int exec_rt, jiffie_t deadline) entry->executes_realtime = exec_rt; entry->cur_deadline = deadline; - /* TODO: move instead of del+reinsert */ list_del(&entry->list); /* if we do not execute real-time jobs we just move * to the end of the queue @@ -94,10 +93,6 @@ static void adjust_cpu_queue(int exec_rt, jiffie_t deadline) * kick the next if necessary, and so on. The caller is responsible for making * sure that it is not the last entry or that a reschedule is not necessary. * - * TODO: This function is probably way too trigger happy. It should only send - * IPIs if the other CPU is not going to reschedule anyway. But that is - * hard to detect reliably. Too many schedules will hurt performance - * but do not cause incorrect schedules. */ static int gedf_check_resched(rt_domain_t *edf) { @@ -336,9 +331,6 @@ static void gedf_wake_up_task(struct task_struct *task) } else if (task->time_slice) { /* came back in time before deadline - * TODO: clip budget to fit into period, otherwise it could - * cause a deadline overrun in the next period, i.e. - * over allocation in the next period. */ set_rt_flags(task, RT_F_RUNNING); add_ready(&gedf, task); @@ -356,8 +348,6 @@ static void gedf_task_blocks(struct task_struct *t) * it is running, and when it is not running it is not in any * queue anyway. * - * TODO: Check whether the assumption is correct for SIGKILL and - * SIGSTOP. */ TRACE("task %d blocks with budget=%d\n", t->pid, t->time_slice); BUG_ON(t->rt_list.next != LIST_POISON1); @@ -433,7 +423,6 @@ static sched_plugin_t s_plugin __cacheline_aligned_in_smp = { .prepare_task = gedf_prepare_task,\ .sleep_next_period = edf_sleep_next_period,\ .tear_down = gedf_tear_down,\ - .shutdown_hook = 0,\ .schedule = gedf_schedule,\ .finish_switch = gedf_finish_switch,\ .mode_change = gedf_mode_change,\ @@ -538,7 +527,6 @@ static int gedf_np_check_resched(rt_domain_t *edf) .prepare_task = gedf_prepare_task,\ .sleep_next_period = edf_sleep_next_period,\ .tear_down = gedf_tear_down,\ - .shutdown_hook = 0,\ .schedule = gedf_schedule,\ .finish_switch = gedf_finish_switch,\ .mode_change = gedf_mode_change,\ diff --git a/kernel/sched_part_edf.c b/kernel/sched_part_edf.c index 8166c8f4c6..a792ac5d03 100644 --- a/kernel/sched_part_edf.c +++ b/kernel/sched_part_edf.c @@ -241,10 +241,10 @@ static void part_edf_wake_up_task(struct task_struct *task) add_ready(edf, task); } else if (task->time_slice) { - /* came back in time before deadline - * TODO: clip budget to fit into period, otherwise it could - * cause a deadline overrun in the next period, i.e. - * over allocation in the next period. + /* Came back in time before deadline. This may cause + * deadline overruns, but since we don't handle suspensions + * in the analytical model, we don't care since we can't + * guarantee anything at all if tasks block. */ set_rt_flags(task, RT_F_RUNNING); add_ready(edf, task); @@ -262,8 +262,6 @@ static void part_edf_task_blocks(struct task_struct *t) * it is running, and when it is not running it is not in any * queue anyway. * - * TODO: Check whether the assumption is correct for SIGKILL and - * SIGSTOP. */ TRACE("task %d blocks with budget=%d\n", t->pid, t->time_slice); BUG_ON(in_list(&t->rt_list)); @@ -313,7 +311,6 @@ static sched_plugin_t s_plugin __cacheline_aligned_in_smp = { .prepare_task = part_edf_prepare_task,\ .sleep_next_period = edf_sleep_next_period,\ .tear_down = part_edf_tear_down,\ - .shutdown_hook = NULL,\ .schedule = part_edf_schedule,\ .finish_switch = part_edf_finish_switch,\ .mode_change = part_edf_mode_change,\ diff --git a/kernel/sched_pfair.c b/kernel/sched_pfair.c index 20a7526a0a..1a6a790fb7 100644 --- a/kernel/sched_pfair.c +++ b/kernel/sched_pfair.c @@ -480,9 +480,7 @@ static sched_plugin_t s_plugin __cacheline_aligned_in_smp = { .ready_to_use = 1,\ .scheduler_tick = pfair_scheduler_tick,\ .prepare_task = pfair_prepare_task,\ - .sleep_next_period = 0,\ .tear_down = pfair_tear_down,\ - .shutdown_hook = 0,\ .schedule = pfair_schedule,\ .finish_switch = pfair_finish_task_switch,\ .mode_change = pfair_mode_change,\ diff --git a/kernel/sched_plugin.c b/kernel/sched_plugin.c index 3c7d6c0842..1f759b7c9f 100644 --- a/kernel/sched_plugin.c +++ b/kernel/sched_plugin.c @@ -9,14 +9,6 @@ #include -/* These are the original Linux initialization functions. - * We replace them here with our initialization code and call them - * after setting up LITMUS. - */ -void linux_sched_init(void); -void linux_sched_init_smp(void); -int linux_migration_init(void); - /************************************************************* * Dummy plugin functions * *************************************************************/ @@ -99,7 +91,6 @@ sched_plugin_t linux_sched_plugin = { .wake_up_task = litmus_dummy_wake_up_task, .task_blocks = litmus_dummy_task_blocks, .sleep_next_period = litmus_dummy_sleep_next_period, - .shutdown_hook = 0, .schedule = litmus_dummy_schedule, .finish_switch = litmus_dummy_finish_switch, .scheduler_setup = litmus_dummy_scheduler_setup, @@ -115,47 +106,3 @@ sched_plugin_t linux_sched_plugin = { */ sched_plugin_t *curr_sched_plugin = &linux_sched_plugin; - -/* At sched-init */ -void __init sched_init(void) -{ - printk("Entering custom sched init, plugin %s\n", - curr_sched_plugin->plugin_name); - /* Init tracing facility before plugin functions are called */ - - /* CLEANUP: reenable this if needed - pstats = INIT_PSTATS; - - */ - - /* Call linux sched init tasks */ - linux_sched_init(); - printk("Sched init complete\n"); -} - -void __init sched_init_smp(void) -{ - printk("Entering custom SMP init, plugin %s\n", - curr_sched_plugin->plugin_name); - /* Call linux smp initializer */ - linux_sched_init_smp(); - /* Enable tracing facilities here */ - /* - CLEANUP: Reenable if needed. - if (smp_processor_id() == 0) { - if (init_trace()) { - printk("Tracing disabled\n"); - } else { - printk("Default tracing enabled\n"); - } - } */ - printk("Sched init SMP complete\n"); -} - -int __init migration_init(void) -{ - printk("Entering migration init\n"); - - /* Call linux migration init as it was before */ - return linux_migration_init(); -} diff --git a/kernel/sched_psn_edf.c b/kernel/sched_psn_edf.c index 32f9b23829..9e4f4abd52 100644 --- a/kernel/sched_psn_edf.c +++ b/kernel/sched_psn_edf.c @@ -301,39 +301,11 @@ static void psnedf_wake_up_task(struct task_struct *task) TRACE("psnedf: %d unsuspends with budget=%d\n", task->pid, task->time_slice); - /* After fixing the litmus_controlled bug, * this should hold again. */ BUG_ON(in_list(&task->rt_list)); - /* FIXME: - * There exists a race between this function, suspensions due to IO, - * and switching in and out of real-time mode. For some reason, the - * BUG_ON triggered after a task system warm-up phase. - * - * BUG_ON(in_list(&task->rt_list)); - * - * Replaced by an if to gather more information. - */ -/* - if (unlikely(in_list(&task->rt_list))) { - TRACE(KERN_CRIT "wake_up_task: Why is %s/%d in rt list? " - "state=%ld next=%p prev=%p flags=0x%8lx mode=%d " - "partition=%d cpu=%d deadline=%ld now=%ld release=%ld" - "rtflags=%d timeslice=%d job=%u knp=%d", - task->comm, task->pid, - task->state, task->rt_list.next, task->rt_list.prev, - task->flags, get_rt_mode(), - get_partition(task), smp_processor_id(), - get_deadline(task), jiffies, get_release(task), - get_rt_flags(task), task->time_slice, - task->rt_param.times.job_no, task->rt_param.kernel_np); - task->state = TASK_RUNNING; - return; - } -*/ - task->state = TASK_RUNNING; /* We need to take suspensions because of semaphores into @@ -520,7 +492,6 @@ static sched_plugin_t s_plugin __cacheline_aligned_in_smp = { .prepare_task = psnedf_prepare_task,\ .sleep_next_period = edf_sleep_next_period,\ .tear_down = psnedf_tear_down,\ - .shutdown_hook = NULL,\ .schedule = psnedf_schedule,\ .mode_change = psnedf_mode_change,\ .wake_up_task = psnedf_wake_up_task,\ -- cgit v1.2.2