diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 0f2def822296..ac3f5cc3bb51 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -864,21 +864,28 @@ static void deactivate_task(struct task_struct *p, runqueue_t *rq) | |||
864 | #ifdef CONFIG_SMP | 864 | #ifdef CONFIG_SMP |
865 | static void resched_task(task_t *p) | 865 | static void resched_task(task_t *p) |
866 | { | 866 | { |
867 | int need_resched, nrpolling; | 867 | int cpu; |
868 | 868 | ||
869 | assert_spin_locked(&task_rq(p)->lock); | 869 | assert_spin_locked(&task_rq(p)->lock); |
870 | 870 | ||
871 | /* minimise the chance of sending an interrupt to poll_idle() */ | 871 | if (unlikely(test_tsk_thread_flag(p, TIF_NEED_RESCHED))) |
872 | nrpolling = test_tsk_thread_flag(p,TIF_POLLING_NRFLAG); | 872 | return; |
873 | need_resched = test_and_set_tsk_thread_flag(p,TIF_NEED_RESCHED); | 873 | |
874 | nrpolling |= test_tsk_thread_flag(p,TIF_POLLING_NRFLAG); | 874 | set_tsk_thread_flag(p, TIF_NEED_RESCHED); |
875 | |||
876 | cpu = task_cpu(p); | ||
877 | if (cpu == smp_processor_id()) | ||
878 | return; | ||
875 | 879 | ||
876 | if (!need_resched && !nrpolling && (task_cpu(p) != smp_processor_id())) | 880 | /* NEED_RESCHED must be visible before we test POLLING_NRFLAG */ |
877 | smp_send_reschedule(task_cpu(p)); | 881 | smp_mb(); |
882 | if (!test_tsk_thread_flag(p, TIF_POLLING_NRFLAG)) | ||
883 | smp_send_reschedule(cpu); | ||
878 | } | 884 | } |
879 | #else | 885 | #else |
880 | static inline void resched_task(task_t *p) | 886 | static inline void resched_task(task_t *p) |
881 | { | 887 | { |
888 | assert_spin_locked(&task_rq(p)->lock); | ||
882 | set_tsk_need_resched(p); | 889 | set_tsk_need_resched(p); |
883 | } | 890 | } |
884 | #endif | 891 | #endif |