aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/litmus.c
diff options
context:
space:
mode:
authorJeremy Erickson <jerickso@cs.unc.edu>2010-11-18 21:19:53 -0500
committerJeremy Erickson <jerickso@cs.unc.edu>2010-11-18 21:19:53 -0500
commit96b6afbe3c8496e9a081f18679b834edc9baa64b (patch)
tree3e1e312fbf2883ee28eb2626c5890ead9306cba2 /litmus/litmus.c
parent1726017e944d0086f14f867befbf5ebf07adc7dd (diff)
Attempt to fix race condition with plugin switchingwip-fix-switch-jerickso
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r--litmus/litmus.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 0756d0156f8f..1dbe8e52839f 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -22,6 +22,7 @@ atomic_t rt_task_count = ATOMIC_INIT(0);
22static DEFINE_RAW_SPINLOCK(task_transition_lock); 22static DEFINE_RAW_SPINLOCK(task_transition_lock);
23/* synchronize plugin switching */ 23/* synchronize plugin switching */
24atomic_t cannot_use_plugin = ATOMIC_INIT(0); 24atomic_t cannot_use_plugin = ATOMIC_INIT(0);
25atomic_t cpus_waiting_for_plugin = ATOMIC_INIT(0);
25 26
26/* Give log messages sequential IDs. */ 27/* Give log messages sequential IDs. */
27atomic_t __log_seq_no = ATOMIC_INIT(0); 28atomic_t __log_seq_no = ATOMIC_INIT(0);
@@ -382,6 +383,7 @@ void litmus_exit_task(struct task_struct* tsk)
382/* IPI callback to synchronize plugin switching */ 383/* IPI callback to synchronize plugin switching */
383static void synch_on_plugin_switch(void* info) 384static void synch_on_plugin_switch(void* info)
384{ 385{
386 atomic_inc(&cpus_waiting_for_plugin);
385 while (atomic_read(&cannot_use_plugin)) 387 while (atomic_read(&cannot_use_plugin))
386 cpu_relax(); 388 cpu_relax();
387} 389}
@@ -400,9 +402,16 @@ int switch_sched_plugin(struct sched_plugin* plugin)
400 402
401 /* forbid other cpus to use the plugin */ 403 /* forbid other cpus to use the plugin */
402 atomic_set(&cannot_use_plugin, 1); 404 atomic_set(&cannot_use_plugin, 1);
405
406 atomic_set(&cpus_waiting_for_plugin, 0);
407
403 /* send IPI to force other CPUs to synch with us */ 408 /* send IPI to force other CPUs to synch with us */
404 smp_call_function(synch_on_plugin_switch, NULL, 0); 409 smp_call_function(synch_on_plugin_switch, NULL, 0);
405 410
411 /* wait until all other CPUs have started synch */
412 while (atomic_read(&cpus_waiting_for_plugin) < num_online_cpus() - 1)
413 cpu_relax();
414
406 /* stop task transitions */ 415 /* stop task transitions */
407 raw_spin_lock_irqsave(&task_transition_lock, flags); 416 raw_spin_lock_irqsave(&task_transition_lock, flags);
408 417