]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/sched_traditional.c
xnu-4903.221.2.tar.gz
[apple/xnu.git] / osfmk / kern / sched_traditional.c
index 80f950feb6b9665f1f595a3d028ea61da7f360db..02066c97e723d2e5b0b7a205b2d7663df8bc5965 100644 (file)
@@ -160,6 +160,20 @@ const struct sched_dispatch_table sched_traditional_dispatch = {
        .direct_dispatch_to_idle_processors             = TRUE,
        .multiple_psets_enabled                         = TRUE,
        .sched_groups_enabled                           = FALSE,
+       .avoid_processor_enabled                        = FALSE,
+       .thread_avoid_processor                         = NULL,
+       .processor_balance                              = sched_SMT_balance,
+
+       .rt_runq                                        = sched_rtglobal_runq,
+       .rt_init                                        = sched_rtglobal_init,
+       .rt_queue_shutdown                              = sched_rtglobal_queue_shutdown,
+       .rt_runq_scan                                   = sched_rtglobal_runq_scan,
+       .rt_runq_count_sum                              = sched_rtglobal_runq_count_sum,
+
+       .qos_max_parallelism                            = sched_qos_max_parallelism,
+       .check_spill                                    = sched_check_spill,
+       .ipi_policy                                     = sched_ipi_policy,
+       .thread_should_yield                            = sched_thread_should_yield,
 };
 
 const struct sched_dispatch_table sched_traditional_with_pset_runqueue_dispatch = {
@@ -194,6 +208,20 @@ const struct sched_dispatch_table sched_traditional_with_pset_runqueue_dispatch
        .direct_dispatch_to_idle_processors             = FALSE,
        .multiple_psets_enabled                         = TRUE,
        .sched_groups_enabled                           = FALSE,
+       .avoid_processor_enabled                        = FALSE,
+       .thread_avoid_processor                         = NULL,
+       .processor_balance                              = sched_SMT_balance,
+
+       .rt_runq                                        = sched_rtglobal_runq,
+       .rt_init                                        = sched_rtglobal_init,
+       .rt_queue_shutdown                              = sched_rtglobal_queue_shutdown,
+       .rt_runq_scan                                   = sched_rtglobal_runq_scan,
+       .rt_runq_count_sum                              = sched_rtglobal_runq_count_sum,
+
+       .qos_max_parallelism                            = sched_qos_max_parallelism,
+       .check_spill                                    = sched_check_spill,
+       .ipi_policy                                     = sched_ipi_policy,
+       .thread_should_yield                            = sched_thread_should_yield,
 };
 
 static void
@@ -431,11 +459,7 @@ sched_traditional_processor_queue_has_priority(processor_t      processor,
                                                int              priority,
                                                boolean_t        gte)
 {
-       run_queue_t runq = runq_for_processor(processor);
-
-       if (runq->count == 0)
-               return FALSE;
-       else if (gte)
+       if (gte)
                return runq_for_processor(processor)->highq >= priority;
        else
                return runq_for_processor(processor)->highq > priority;
@@ -665,21 +689,18 @@ sched_traditional_steal_thread(processor_set_t pset)
        thread_t        thread;
 
        do {
-               processor = (processor_t)(uintptr_t)queue_first(&cset->active_queue);
-               while (!queue_end(&cset->active_queue, (queue_entry_t)processor)) {
+               uint64_t active_map = (pset->cpu_state_map[PROCESSOR_RUNNING] |
+                                      pset->cpu_state_map[PROCESSOR_DISPATCHING]);
+               for (int cpuid = lsb_first(active_map); cpuid >= 0; cpuid = lsb_next(active_map, cpuid)) {
+                       processor = processor_array[cpuid];
                        if (runq_for_processor(processor)->count > 0) {
                                thread = sched_traditional_steal_processor_thread(processor);
                                if (thread != THREAD_NULL) {
-                                       remqueue((queue_entry_t)processor);
-                                       enqueue_tail(&cset->active_queue, (queue_entry_t)processor);
-
                                        pset_unlock(cset);
 
                                        return (thread);
                                }
                        }
-
-                       processor = (processor_t)(uintptr_t)queue_next((queue_entry_t)processor);
                }
 
                nset = next_pset(cset);