Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched

* git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched:
sched: clean up task_new_fair()
sched: small schedstat fix
sched: fix wait_start_fair condition in update_stats_wait_end()
sched: call update_curr() in task_tick_fair()
sched: make the scheduler converge to the ideal latency
sched: fix sleeper bonus limit

+37 -11
+1
include/linux/sched.h
··· 904 904 905 905 u64 exec_start; 906 906 u64 sum_exec_runtime; 907 + u64 prev_sum_exec_runtime; 907 908 u64 wait_start_fair; 908 909 u64 sleep_start_fair; 909 910
+1
kernel/sched.c
··· 1587 1587 p->se.wait_start_fair = 0; 1588 1588 p->se.exec_start = 0; 1589 1589 p->se.sum_exec_runtime = 0; 1590 + p->se.prev_sum_exec_runtime = 0; 1590 1591 p->se.delta_exec = 0; 1591 1592 p->se.delta_fair_run = 0; 1592 1593 p->se.delta_fair_sleep = 0;
+35 -11
kernel/sched_fair.c
··· 354 354 delta_fair = calc_delta_fair(delta_exec, lw); 355 355 delta_mine = calc_delta_mine(delta_exec, curr->load.weight, lw); 356 356 357 - if (cfs_rq->sleeper_bonus > sysctl_sched_latency) { 357 + if (cfs_rq->sleeper_bonus > sysctl_sched_min_granularity) { 358 358 delta = min((u64)delta_mine, cfs_rq->sleeper_bonus); 359 359 delta = min(delta, (unsigned long)( 360 360 (long)sysctl_sched_runtime_limit - curr->wait_runtime)); ··· 488 488 update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) 489 489 { 490 490 unsigned long delta_fair; 491 + 492 + if (unlikely(!se->wait_start_fair)) 493 + return; 491 494 492 495 delta_fair = (unsigned long)min((u64)(2*sysctl_sched_runtime_limit), 493 496 (u64)(cfs_rq->fair_clock - se->wait_start_fair)); ··· 671 668 /* 672 669 * Preempt the current task with a newly woken task if needed: 673 670 */ 674 - static void 671 + static int 675 672 __check_preempt_curr_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, 676 673 struct sched_entity *curr, unsigned long granularity) 677 674 { ··· 682 679 * preempt the current task unless the best task has 683 680 * a larger than sched_granularity fairness advantage: 684 681 */ 685 - if (__delta > niced_granularity(curr, granularity)) 682 + if (__delta > niced_granularity(curr, granularity)) { 686 683 resched_task(rq_of(cfs_rq)->curr); 684 + return 1; 685 + } 686 + return 0; 687 687 } 688 688 689 689 static inline void ··· 731 725 732 726 static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) 733 727 { 728 + unsigned long gran, ideal_runtime, delta_exec; 734 729 struct sched_entity *next; 735 730 736 731 /* ··· 748 741 if (next == curr) 749 742 return; 750 743 751 - __check_preempt_curr_fair(cfs_rq, next, curr, 752 - sched_granularity(cfs_rq)); 744 + gran = sched_granularity(cfs_rq); 745 + ideal_runtime = niced_granularity(curr, 746 + max(sysctl_sched_latency / cfs_rq->nr_running, 747 + (unsigned long)sysctl_sched_min_granularity)); 748 + /* 749 + * If we executed more than what the latency constraint suggests, 750 + * reduce the rescheduling granularity. This way the total latency 751 + * of how much a task is not scheduled converges to 752 + * sysctl_sched_latency: 753 + */ 754 + delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime; 755 + if (delta_exec > ideal_runtime) 756 + gran = 0; 757 + 758 + if (__check_preempt_curr_fair(cfs_rq, next, curr, gran)) 759 + curr->prev_sum_exec_runtime = curr->sum_exec_runtime; 753 760 } 754 761 755 762 /************************************************** ··· 1097 1076 static void task_new_fair(struct rq *rq, struct task_struct *p) 1098 1077 { 1099 1078 struct cfs_rq *cfs_rq = task_cfs_rq(p); 1100 - struct sched_entity *se = &p->se; 1079 + struct sched_entity *se = &p->se, *curr = cfs_rq_curr(cfs_rq); 1101 1080 1102 1081 sched_info_queued(p); 1103 1082 1083 + update_curr(cfs_rq); 1104 1084 update_stats_enqueue(cfs_rq, se); 1105 1085 /* 1106 1086 * Child runs first: we let it run before the parent 1107 1087 * until it reschedules once. We set up the key so that 1108 1088 * it will preempt the parent: 1109 1089 */ 1110 - p->se.fair_key = current->se.fair_key - 1111 - niced_granularity(&rq->curr->se, sched_granularity(cfs_rq)) - 1; 1090 + se->fair_key = curr->fair_key - 1091 + niced_granularity(curr, sched_granularity(cfs_rq)) - 1; 1112 1092 /* 1113 1093 * The first wait is dominated by the child-runs-first logic, 1114 1094 * so do not credit it with that waiting time yet: 1115 1095 */ 1116 1096 if (sysctl_sched_features & SCHED_FEAT_SKIP_INITIAL) 1117 - p->se.wait_start_fair = 0; 1097 + se->wait_start_fair = 0; 1118 1098 1119 1099 /* 1120 1100 * The statistical average of wait_runtime is about 1121 1101 * -granularity/2, so initialize the task with that: 1122 1102 */ 1123 - if (sysctl_sched_features & SCHED_FEAT_START_DEBIT) 1124 - p->se.wait_runtime = -(sched_granularity(cfs_rq) / 2); 1103 + if (sysctl_sched_features & SCHED_FEAT_START_DEBIT) { 1104 + se->wait_runtime = -(sched_granularity(cfs_rq) / 2); 1105 + schedstat_add(cfs_rq, wait_runtime, se->wait_runtime); 1106 + } 1125 1107 1126 1108 __enqueue_entity(cfs_rq, se); 1127 1109 }