]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/sched_average.c
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / osfmk / kern / sched_average.c
index a6a855c9ff1114d95a2c0f07dd60ae50e254f50e..f74e8b960d421fda3058a1e96b5ba0ee4a72df77 100644 (file)
@@ -292,7 +292,13 @@ compute_averages(uint64_t stdelta)
        /* Update the global pri_shifts based on the latest values */
        for (uint32_t i = TH_BUCKET_SHARE_FG; i <= TH_BUCKET_SHARE_BG; i++) {
                uint32_t bucket_load = SCHED_LOAD_EWMA_UNSCALE(sched_load[i]);
-               sched_pri_shifts[i] = sched_fixed_shift - sched_load_shifts[bucket_load];
+               uint32_t shift = sched_fixed_shift - sched_load_shifts[bucket_load];
+
+               if (shift > SCHED_PRI_SHIFT_MAX) {
+                       sched_pri_shifts[i] = INT8_MAX;
+               } else {
+                       sched_pri_shifts[i] = shift;
+               }
        }
 
        /*