From b4c52e27caa701a16e120b43a0e70ca6529a58a4 Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Wed, 22 Jun 2011 01:30:25 -0400 Subject: C-EDF: Make migration affinity work with Release Master Needed to update C-EDF to handle release master. Also updated get_nearest_available_cpu() to take NO_CPU instead of -1 to indicate that there is no release master. While NO_CPU is 0xffffffff (-1 in two's complement), we still translate this value to -1 in case NO_CPU changes. Signed-off-by: Andrea Bastoni --- include/litmus/affinity.h | 15 ++++++++------- litmus/affinity.c | 6 ++---- litmus/sched_cedf.c | 16 +++++++++++----- litmus/sched_gsn_edf.c | 10 +++++----- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/litmus/affinity.h b/include/litmus/affinity.h index 5eee0eaa170d..ca2e442eb547 100644 --- a/include/litmus/affinity.h +++ b/include/litmus/affinity.h @@ -24,12 +24,12 @@ void init_topology(void); /* called by Litmus module's _init_litmus() */ /* Works like: void get_nearest_available_cpu( - cpu_entry_t* nearest, - cpu_entry_t* start, - cpu_entry_t* entries, + cpu_entry_t **nearest, + cpu_entry_t *start, + cpu_entry_t *entries, int release_master) -Set release_master = -1 for no RM. +Set release_master = NO_CPU for no Release Master. We use a macro here to exploit the fact that C-EDF and G-EDF have similar structures for their cpu_entry_t structs, even though @@ -48,13 +48,14 @@ dissertation.) } else { \ int __level; \ int __cpu; \ - struct neighborhood* __neighbors = &neigh_info[(start)->cpu]; \ + int __release_master = ((release_master) == NO_CPU) ? -1 : (release_master); \ + struct neighborhood *__neighbors = &neigh_info[(start)->cpu]; \ \ for (__level = 0; (__level < NUM_CACHE_LEVELS) && !(nearest); ++__level) { \ if (__neighbors->size[__level] > 1) { \ for_each_cpu(__cpu, __neighbors->neighbors[__level]) { \ - if (__cpu != (release_master)) { \ - cpu_entry_t* __entry = &per_cpu((entries), __cpu); \ + if (__cpu != __release_master) { \ + cpu_entry_t *__entry = &per_cpu((entries), __cpu); \ if (!__entry->linked) { \ (nearest) = __entry; \ break; \ diff --git a/litmus/affinity.c b/litmus/affinity.c index 9adab7a3bcd7..3fa6dd789400 100644 --- a/litmus/affinity.c +++ b/litmus/affinity.c @@ -16,8 +16,6 @@ void init_topology(void) { for_each_online_cpu(cpu) { for (i = 0; i < depth; ++i) { - long unsigned int firstbits; - chk = get_shared_cpu_map((struct cpumask *)&neigh_info[cpu].neighbors[i], cpu, i); if (chk) { /* failed */ @@ -27,9 +25,9 @@ void init_topology(void) { neigh_info[cpu].size[i] = cpumask_weight((struct cpumask *)&neigh_info[cpu].neighbors[i]); } - firstbits = *neigh_info[cpu].neighbors[i]->bits; printk("CPU %d has %d neighbors at level %d. (mask = %lx)\n", - cpu, neigh_info[cpu].size[i], i, firstbits); + cpu, neigh_info[cpu].size[i], i, + *cpumask_bits(neigh_info[cpu].neighbors[i])); } /* set data for non-existent levels */ diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 0707059597d6..690b94dbd686 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c @@ -263,11 +263,17 @@ static noinline void requeue(struct task_struct* task) #ifdef CONFIG_SCHED_CPU_AFFINITY static cpu_entry_t* cedf_get_nearest_available_cpu( - cedf_domain_t *cluster, cpu_entry_t* start) + cedf_domain_t *cluster, cpu_entry_t *start) { - cpu_entry_t* affinity; + cpu_entry_t *affinity; - get_nearest_available_cpu(affinity, start, cedf_cpu_entries, -1); + get_nearest_available_cpu(affinity, start, cedf_cpu_entries, +#ifdef CONFIG_RELEASE_MASTER + cluster->domain.release_master +#else + NO_CPU +#endif + ); /* make sure CPU is in our cluster */ if (affinity && cpu_isset(affinity->cpu, *cluster->cpu_map)) @@ -282,7 +288,7 @@ static cpu_entry_t* cedf_get_nearest_available_cpu( static void check_for_preemptions(cedf_domain_t *cluster) { struct task_struct *task; - cpu_entry_t* last; + cpu_entry_t *last; for(last = lowest_prio_cpu(cluster); edf_preemption_needed(&cluster->domain, last->linked); @@ -293,7 +299,7 @@ static void check_for_preemptions(cedf_domain_t *cluster) task->pid, last->cpu); #ifdef CONFIG_SCHED_CPU_AFFINITY { - cpu_entry_t* affinity = + cpu_entry_t *affinity = cedf_get_nearest_available_cpu(cluster, &per_cpu(cedf_cpu_entries, task_cpu(task))); if(affinity) diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index 17926e9fccdc..467f8b284de4 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c @@ -258,15 +258,15 @@ static noinline void requeue(struct task_struct* task) } #ifdef CONFIG_SCHED_CPU_AFFINITY -static cpu_entry_t* gsnedf_get_nearest_available_cpu(cpu_entry_t* start) +static cpu_entry_t* gsnedf_get_nearest_available_cpu(cpu_entry_t *start) { - cpu_entry_t* affinity; + cpu_entry_t *affinity; get_nearest_available_cpu(affinity, start, gsnedf_cpu_entries, #ifdef CONFIG_RELEASE_MASTER gsnedf.release_master #else - -1 + NO_CPU #endif ); @@ -278,7 +278,7 @@ static cpu_entry_t* gsnedf_get_nearest_available_cpu(cpu_entry_t* start) static void check_for_preemptions(void) { struct task_struct *task; - cpu_entry_t* last; + cpu_entry_t *last; for (last = lowest_prio_cpu(); edf_preemption_needed(&gsnedf, last->linked); @@ -290,7 +290,7 @@ static void check_for_preemptions(void) #ifdef CONFIG_SCHED_CPU_AFFINITY { - cpu_entry_t* affinity = + cpu_entry_t *affinity = gsnedf_get_nearest_available_cpu( &per_cpu(gsnedf_cpu_entries, task_cpu(task))); if (affinity) -- cgit v1.2.2