From e3697ee7ecbcadf2ae4f17495ce46612c54fad13 Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Sat, 8 Jun 2013 12:22:59 +0200 Subject: GSN-EDF: link tasks to local CPU if it is idle If a task is released on a CPU that is idle, then it is pointless to send an IPI to another CPU just to schedule the newly released task. This patch changes check_for_preemptions() to prefer the local CPU first if it is idle. --- litmus/sched_gsn_edf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'litmus/sched_gsn_edf.c') diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index 90ff6f639461..66ffa3e7a7bd 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c @@ -280,6 +280,18 @@ static void check_for_preemptions(void) { struct task_struct *task; cpu_entry_t *last; + cpu_entry_t *local; + + /* Before linking to other CPUs, check first whether the local CPU is + * idle. */ + local = &__get_cpu_var(gsnedf_cpu_entries); + task = __peek_ready(&gsnedf); + if (task && !local->linked) { + task = __take_ready(&gsnedf); + TRACE_TASK(task, "linking to local CPU %d to avoid IPI\n", local->cpu); + link_task_to_cpu(task, local); + preempt(local); + } for (last = lowest_prio_cpu(); edf_preemption_needed(&gsnedf, last->linked); -- cgit v1.2.2