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:
[PATCH] sched: reduce task_struct size
[PATCH] sched: reduce debug code
[PATCH] sched: use schedstat_set() API
[PATCH] sched: add schedstat_set() API
[PATCH] sched: move load-calculation functions
[PATCH] sched: ->task_new cleanup
[PATCH] sched: uninline inc/dec_nr_running()
[PATCH] sched: uninline calc_delta_mine()
[PATCH] sched: calc_delta_mine(): use fixed limit
[PATCH] sched: tidy up left over smpnice code
[PATCH] sched: remove cache_hot_time

+136 -145
+15 -11
include/linux/sched.h
··· 734 unsigned long max_interval; /* Maximum balance interval ms */ 735 unsigned int busy_factor; /* less balancing by factor if busy */ 736 unsigned int imbalance_pct; /* No balance until over watermark */ 737 - unsigned long long cache_hot_time; /* Task considered cache hot (ns) */ 738 unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ 739 unsigned int busy_idx; 740 unsigned int idle_idx; ··· 874 875 void (*set_curr_task) (struct rq *rq); 876 void (*task_tick) (struct rq *rq, struct task_struct *p); 877 - void (*task_new) (struct rq *rq, struct task_struct *p); 878 }; 879 880 struct load_weight { ··· 904 struct rb_node run_node; 905 unsigned int on_rq; 906 907 - u64 wait_start_fair; 908 - u64 wait_start; 909 u64 exec_start; 910 - u64 sleep_start; 911 u64 sleep_start_fair; 912 - u64 block_start; 913 u64 sleep_max; 914 u64 block_max; 915 u64 exec_max; 916 - u64 wait_max; 917 - u64 last_ran; 918 919 - u64 sum_exec_runtime; 920 - s64 sum_wait_runtime; 921 - s64 sum_sleep_runtime; 922 unsigned long wait_runtime_overruns; 923 unsigned long wait_runtime_underruns; 924 #ifdef CONFIG_FAIR_GROUP_SCHED 925 struct sched_entity *parent; 926 /* rq on which this entity is (to be) queued: */
··· 734 unsigned long max_interval; /* Maximum balance interval ms */ 735 unsigned int busy_factor; /* less balancing by factor if busy */ 736 unsigned int imbalance_pct; /* No balance until over watermark */ 737 unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ 738 unsigned int busy_idx; 739 unsigned int idle_idx; ··· 875 876 void (*set_curr_task) (struct rq *rq); 877 void (*task_tick) (struct rq *rq, struct task_struct *p); 878 + void (*task_new) (struct rq *rq, struct task_struct *p, u64 now); 879 }; 880 881 struct load_weight { ··· 905 struct rb_node run_node; 906 unsigned int on_rq; 907 908 u64 exec_start; 909 + u64 sum_exec_runtime; 910 + u64 wait_start_fair; 911 u64 sleep_start_fair; 912 + 913 + #ifdef CONFIG_SCHEDSTATS 914 + u64 wait_start; 915 + u64 wait_max; 916 + s64 sum_wait_runtime; 917 + 918 + u64 sleep_start; 919 u64 sleep_max; 920 + s64 sum_sleep_runtime; 921 + 922 + u64 block_start; 923 u64 block_max; 924 u64 exec_max; 925 926 unsigned long wait_runtime_overruns; 927 unsigned long wait_runtime_underruns; 928 + #endif 929 + 930 #ifdef CONFIG_FAIR_GROUP_SCHED 931 struct sched_entity *parent; 932 /* rq on which this entity is (to be) queued: */
-1
include/linux/topology.h
··· 185 .max_interval = 64*num_online_cpus(), \ 186 .busy_factor = 128, \ 187 .imbalance_pct = 133, \ 188 - .cache_hot_time = (10*1000000), \ 189 .cache_nice_tries = 1, \ 190 .busy_idx = 3, \ 191 .idle_idx = 3, \
··· 185 .max_interval = 64*num_online_cpus(), \ 186 .busy_factor = 128, \ 187 .imbalance_pct = 133, \ 188 .cache_nice_tries = 1, \ 189 .busy_idx = 3, \ 190 .idle_idx = 3, \
+96 -99
kernel/sched.c
··· 637 638 #define WMULT_SHIFT 32 639 640 - static inline unsigned long 641 calc_delta_mine(unsigned long delta_exec, unsigned long weight, 642 struct load_weight *lw) 643 { ··· 657 tmp = (tmp * lw->inv_weight) >> WMULT_SHIFT; 658 } 659 660 - return (unsigned long)min(tmp, (u64)sysctl_sched_runtime_limit); 661 } 662 663 static inline unsigned long ··· 678 lw->inv_weight = 0; 679 } 680 681 - static void __update_curr_load(struct rq *rq, struct load_stat *ls) 682 - { 683 - if (rq->curr != rq->idle && ls->load.weight) { 684 - ls->delta_exec += ls->delta_stat; 685 - ls->delta_fair += calc_delta_fair(ls->delta_stat, &ls->load); 686 - ls->delta_stat = 0; 687 - } 688 - } 689 - 690 - /* 691 - * Update delta_exec, delta_fair fields for rq. 692 - * 693 - * delta_fair clock advances at a rate inversely proportional to 694 - * total load (rq->ls.load.weight) on the runqueue, while 695 - * delta_exec advances at the same rate as wall-clock (provided 696 - * cpu is not idle). 697 - * 698 - * delta_exec / delta_fair is a measure of the (smoothened) load on this 699 - * runqueue over any given interval. This (smoothened) load is used 700 - * during load balance. 701 - * 702 - * This function is called /before/ updating rq->ls.load 703 - * and when switching tasks. 704 - */ 705 - static void update_curr_load(struct rq *rq, u64 now) 706 - { 707 - struct load_stat *ls = &rq->ls; 708 - u64 start; 709 - 710 - start = ls->load_update_start; 711 - ls->load_update_start = now; 712 - ls->delta_stat += now - start; 713 - /* 714 - * Stagger updates to ls->delta_fair. Very frequent updates 715 - * can be expensive. 716 - */ 717 - if (ls->delta_stat >= sysctl_sched_stat_granularity) 718 - __update_curr_load(rq, ls); 719 - } 720 - 721 /* 722 * To aid in avoiding the subversion of "niceness" due to uneven distribution 723 * of tasks with abnormal "nice" values across CPUs the contribution that ··· 686 * scaled version of the new time slice allocation that they receive on time 687 * slice expiry etc. 688 */ 689 - 690 - /* 691 - * Assume: static_prio_timeslice(NICE_TO_PRIO(0)) == DEF_TIMESLICE 692 - * If static_prio_timeslice() is ever changed to break this assumption then 693 - * this code will need modification 694 - */ 695 - #define TIME_SLICE_NICE_ZERO DEF_TIMESLICE 696 - #define load_weight(lp) \ 697 - (((lp) * SCHED_LOAD_SCALE) / TIME_SLICE_NICE_ZERO) 698 - #define PRIO_TO_LOAD_WEIGHT(prio) \ 699 - load_weight(static_prio_timeslice(prio)) 700 - #define RTPRIO_TO_LOAD_WEIGHT(rp) \ 701 - (PRIO_TO_LOAD_WEIGHT(MAX_RT_PRIO) + load_weight(rp)) 702 703 #define WEIGHT_IDLEPRIO 2 704 #define WMULT_IDLEPRIO (1 << 31) ··· 728 /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, 729 }; 730 731 - static inline void 732 - inc_load(struct rq *rq, const struct task_struct *p, u64 now) 733 - { 734 - update_curr_load(rq, now); 735 - update_load_add(&rq->ls.load, p->se.load.weight); 736 - } 737 - 738 - static inline void 739 - dec_load(struct rq *rq, const struct task_struct *p, u64 now) 740 - { 741 - update_curr_load(rq, now); 742 - update_load_sub(&rq->ls.load, p->se.load.weight); 743 - } 744 - 745 - static inline void inc_nr_running(struct task_struct *p, struct rq *rq, u64 now) 746 - { 747 - rq->nr_running++; 748 - inc_load(rq, p, now); 749 - } 750 - 751 - static inline void dec_nr_running(struct task_struct *p, struct rq *rq, u64 now) 752 - { 753 - rq->nr_running--; 754 - dec_load(rq, p, now); 755 - } 756 - 757 static void activate_task(struct rq *rq, struct task_struct *p, int wakeup); 758 759 /* ··· 757 #endif 758 759 #define sched_class_highest (&rt_sched_class) 760 761 static void set_load_weight(struct task_struct *p) 762 { ··· 983 u64 clock_offset, fair_clock_offset; 984 985 clock_offset = old_rq->clock - new_rq->clock; 986 - fair_clock_offset = old_rq->cfs.fair_clock - 987 - new_rq->cfs.fair_clock; 988 - if (p->se.wait_start) 989 - p->se.wait_start -= clock_offset; 990 if (p->se.wait_start_fair) 991 p->se.wait_start_fair -= fair_clock_offset; 992 if (p->se.sleep_start) 993 p->se.sleep_start -= clock_offset; 994 if (p->se.block_start) 995 p->se.block_start -= clock_offset; 996 - if (p->se.sleep_start_fair) 997 - p->se.sleep_start_fair -= fair_clock_offset; 998 999 __set_task_cpu(p, new_cpu); 1000 } ··· 1558 static void __sched_fork(struct task_struct *p) 1559 { 1560 p->se.wait_start_fair = 0; 1561 - p->se.wait_start = 0; 1562 p->se.exec_start = 0; 1563 p->se.sum_exec_runtime = 0; 1564 p->se.delta_exec = 0; 1565 p->se.delta_fair_run = 0; 1566 p->se.delta_fair_sleep = 0; 1567 p->se.wait_runtime = 0; 1568 p->se.sum_wait_runtime = 0; 1569 p->se.sum_sleep_runtime = 0; 1570 p->se.sleep_start = 0; 1571 - p->se.sleep_start_fair = 0; 1572 p->se.block_start = 0; 1573 p->se.sleep_max = 0; 1574 p->se.block_max = 0; ··· 1578 p->se.wait_max = 0; 1579 p->se.wait_runtime_overruns = 0; 1580 p->se.wait_runtime_underruns = 0; 1581 1582 INIT_LIST_HEAD(&p->run_list); 1583 p->se.on_rq = 0; ··· 1647 unsigned long flags; 1648 struct rq *rq; 1649 int this_cpu; 1650 1651 rq = task_rq_lock(p, &flags); 1652 BUG_ON(p->state != TASK_RUNNING); 1653 this_cpu = smp_processor_id(); /* parent's CPU */ 1654 1655 p->prio = effective_prio(p); 1656 1657 - if (!sysctl_sched_child_runs_first || (clone_flags & CLONE_VM) || 1658 - task_cpu(p) != this_cpu || !current->se.on_rq) { 1659 activate_task(rq, p, 0); 1660 } else { 1661 /* 1662 * Let the scheduling class do new task startup 1663 * management (if any): 1664 */ 1665 - p->sched_class->task_new(rq, p); 1666 } 1667 check_preempt_curr(rq, p); 1668 task_rq_unlock(rq, &flags); ··· 2906 schedstat_inc(sd, alb_cnt); 2907 2908 if (move_tasks(target_rq, target_cpu, busiest_rq, 1, 2909 - RTPRIO_TO_LOAD_WEIGHT(100), sd, CPU_IDLE, 2910 - NULL)) 2911 schedstat_inc(sd, alb_pushed); 2912 else 2913 schedstat_inc(sd, alb_failed); ··· 5266 sizeof(int), 0644, proc_dointvec_minmax); 5267 set_table_entry(&table[8], 9, "imbalance_pct", &sd->imbalance_pct, 5268 sizeof(int), 0644, proc_dointvec_minmax); 5269 - set_table_entry(&table[9], 10, "cache_hot_time", &sd->cache_hot_time, 5270 - sizeof(long long), 0644, proc_doulongvec_minmax); 5271 set_table_entry(&table[10], 11, "cache_nice_tries", 5272 &sd->cache_nice_tries, 5273 sizeof(int), 0644, proc_dointvec_minmax); ··· 6585 do_each_thread(g, p) { 6586 p->se.fair_key = 0; 6587 p->se.wait_runtime = 0; 6588 - p->se.wait_start_fair = 0; 6589 - p->se.wait_start = 0; 6590 p->se.exec_start = 0; 6591 - p->se.sleep_start = 0; 6592 p->se.sleep_start_fair = 0; 6593 p->se.block_start = 0; 6594 task_rq(p)->cfs.fair_clock = 0; 6595 task_rq(p)->clock = 0; 6596
··· 637 638 #define WMULT_SHIFT 32 639 640 + static unsigned long 641 calc_delta_mine(unsigned long delta_exec, unsigned long weight, 642 struct load_weight *lw) 643 { ··· 657 tmp = (tmp * lw->inv_weight) >> WMULT_SHIFT; 658 } 659 660 + return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX); 661 } 662 663 static inline unsigned long ··· 678 lw->inv_weight = 0; 679 } 680 681 /* 682 * To aid in avoiding the subversion of "niceness" due to uneven distribution 683 * of tasks with abnormal "nice" values across CPUs the contribution that ··· 726 * scaled version of the new time slice allocation that they receive on time 727 * slice expiry etc. 728 */ 729 730 #define WEIGHT_IDLEPRIO 2 731 #define WMULT_IDLEPRIO (1 << 31) ··· 781 /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, 782 }; 783 784 static void activate_task(struct rq *rq, struct task_struct *p, int wakeup); 785 786 /* ··· 836 #endif 837 838 #define sched_class_highest (&rt_sched_class) 839 + 840 + static void __update_curr_load(struct rq *rq, struct load_stat *ls) 841 + { 842 + if (rq->curr != rq->idle && ls->load.weight) { 843 + ls->delta_exec += ls->delta_stat; 844 + ls->delta_fair += calc_delta_fair(ls->delta_stat, &ls->load); 845 + ls->delta_stat = 0; 846 + } 847 + } 848 + 849 + /* 850 + * Update delta_exec, delta_fair fields for rq. 851 + * 852 + * delta_fair clock advances at a rate inversely proportional to 853 + * total load (rq->ls.load.weight) on the runqueue, while 854 + * delta_exec advances at the same rate as wall-clock (provided 855 + * cpu is not idle). 856 + * 857 + * delta_exec / delta_fair is a measure of the (smoothened) load on this 858 + * runqueue over any given interval. This (smoothened) load is used 859 + * during load balance. 860 + * 861 + * This function is called /before/ updating rq->ls.load 862 + * and when switching tasks. 863 + */ 864 + static void update_curr_load(struct rq *rq, u64 now) 865 + { 866 + struct load_stat *ls = &rq->ls; 867 + u64 start; 868 + 869 + start = ls->load_update_start; 870 + ls->load_update_start = now; 871 + ls->delta_stat += now - start; 872 + /* 873 + * Stagger updates to ls->delta_fair. Very frequent updates 874 + * can be expensive. 875 + */ 876 + if (ls->delta_stat >= sysctl_sched_stat_granularity) 877 + __update_curr_load(rq, ls); 878 + } 879 + 880 + static inline void 881 + inc_load(struct rq *rq, const struct task_struct *p, u64 now) 882 + { 883 + update_curr_load(rq, now); 884 + update_load_add(&rq->ls.load, p->se.load.weight); 885 + } 886 + 887 + static inline void 888 + dec_load(struct rq *rq, const struct task_struct *p, u64 now) 889 + { 890 + update_curr_load(rq, now); 891 + update_load_sub(&rq->ls.load, p->se.load.weight); 892 + } 893 + 894 + static void inc_nr_running(struct task_struct *p, struct rq *rq, u64 now) 895 + { 896 + rq->nr_running++; 897 + inc_load(rq, p, now); 898 + } 899 + 900 + static void dec_nr_running(struct task_struct *p, struct rq *rq, u64 now) 901 + { 902 + rq->nr_running--; 903 + dec_load(rq, p, now); 904 + } 905 906 static void set_load_weight(struct task_struct *p) 907 { ··· 996 u64 clock_offset, fair_clock_offset; 997 998 clock_offset = old_rq->clock - new_rq->clock; 999 + fair_clock_offset = old_rq->cfs.fair_clock - new_rq->cfs.fair_clock; 1000 + 1001 if (p->se.wait_start_fair) 1002 p->se.wait_start_fair -= fair_clock_offset; 1003 + if (p->se.sleep_start_fair) 1004 + p->se.sleep_start_fair -= fair_clock_offset; 1005 + 1006 + #ifdef CONFIG_SCHEDSTATS 1007 + if (p->se.wait_start) 1008 + p->se.wait_start -= clock_offset; 1009 if (p->se.sleep_start) 1010 p->se.sleep_start -= clock_offset; 1011 if (p->se.block_start) 1012 p->se.block_start -= clock_offset; 1013 + #endif 1014 1015 __set_task_cpu(p, new_cpu); 1016 } ··· 1568 static void __sched_fork(struct task_struct *p) 1569 { 1570 p->se.wait_start_fair = 0; 1571 p->se.exec_start = 0; 1572 p->se.sum_exec_runtime = 0; 1573 p->se.delta_exec = 0; 1574 p->se.delta_fair_run = 0; 1575 p->se.delta_fair_sleep = 0; 1576 p->se.wait_runtime = 0; 1577 + p->se.sleep_start_fair = 0; 1578 + 1579 + #ifdef CONFIG_SCHEDSTATS 1580 + p->se.wait_start = 0; 1581 p->se.sum_wait_runtime = 0; 1582 p->se.sum_sleep_runtime = 0; 1583 p->se.sleep_start = 0; 1584 p->se.block_start = 0; 1585 p->se.sleep_max = 0; 1586 p->se.block_max = 0; ··· 1586 p->se.wait_max = 0; 1587 p->se.wait_runtime_overruns = 0; 1588 p->se.wait_runtime_underruns = 0; 1589 + #endif 1590 1591 INIT_LIST_HEAD(&p->run_list); 1592 p->se.on_rq = 0; ··· 1654 unsigned long flags; 1655 struct rq *rq; 1656 int this_cpu; 1657 + u64 now; 1658 1659 rq = task_rq_lock(p, &flags); 1660 BUG_ON(p->state != TASK_RUNNING); 1661 this_cpu = smp_processor_id(); /* parent's CPU */ 1662 + now = rq_clock(rq); 1663 1664 p->prio = effective_prio(p); 1665 1666 + if (!p->sched_class->task_new || !sysctl_sched_child_runs_first || 1667 + (clone_flags & CLONE_VM) || task_cpu(p) != this_cpu || 1668 + !current->se.on_rq) { 1669 + 1670 activate_task(rq, p, 0); 1671 } else { 1672 /* 1673 * Let the scheduling class do new task startup 1674 * management (if any): 1675 */ 1676 + p->sched_class->task_new(rq, p, now); 1677 + inc_nr_running(p, rq, now); 1678 } 1679 check_preempt_curr(rq, p); 1680 task_rq_unlock(rq, &flags); ··· 2908 schedstat_inc(sd, alb_cnt); 2909 2910 if (move_tasks(target_rq, target_cpu, busiest_rq, 1, 2911 + ULONG_MAX, sd, CPU_IDLE, NULL)) 2912 schedstat_inc(sd, alb_pushed); 2913 else 2914 schedstat_inc(sd, alb_failed); ··· 5269 sizeof(int), 0644, proc_dointvec_minmax); 5270 set_table_entry(&table[8], 9, "imbalance_pct", &sd->imbalance_pct, 5271 sizeof(int), 0644, proc_dointvec_minmax); 5272 set_table_entry(&table[10], 11, "cache_nice_tries", 5273 &sd->cache_nice_tries, 5274 sizeof(int), 0644, proc_dointvec_minmax); ··· 6590 do_each_thread(g, p) { 6591 p->se.fair_key = 0; 6592 p->se.wait_runtime = 0; 6593 p->se.exec_start = 0; 6594 + p->se.wait_start_fair = 0; 6595 p->se.sleep_start_fair = 0; 6596 + #ifdef CONFIG_SCHEDSTATS 6597 + p->se.wait_start = 0; 6598 + p->se.sleep_start = 0; 6599 p->se.block_start = 0; 6600 + #endif 6601 task_rq(p)->cfs.fair_clock = 0; 6602 task_rq(p)->clock = 0; 6603
+16 -6
kernel/sched_debug.c
··· 44 (long long)p->se.wait_runtime, 45 (long long)(p->nvcsw + p->nivcsw), 46 p->prio, 47 (long long)p->se.sum_exec_runtime, 48 (long long)p->se.sum_wait_runtime, 49 (long long)p->se.sum_sleep_runtime, 50 (long long)p->se.wait_runtime_overruns, 51 - (long long)p->se.wait_runtime_underruns); 52 } 53 54 static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu, u64 now) ··· 176 u64 now = ktime_to_ns(ktime_get()); 177 int cpu; 178 179 - SEQ_printf(m, "Sched Debug Version: v0.05, %s %.*s\n", 180 init_utsname()->release, 181 (int)strcspn(init_utsname()->version, " "), 182 init_utsname()->version); ··· 240 #define P(F) \ 241 SEQ_printf(m, "%-25s:%20Ld\n", #F, (long long)p->F) 242 243 - P(se.wait_start); 244 P(se.wait_start_fair); 245 P(se.exec_start); 246 - P(se.sleep_start); 247 P(se.sleep_start_fair); 248 P(se.block_start); 249 P(se.sleep_max); 250 P(se.block_max); 251 P(se.exec_max); 252 P(se.wait_max); 253 - P(se.wait_runtime); 254 P(se.wait_runtime_overruns); 255 P(se.wait_runtime_underruns); 256 P(se.sum_wait_runtime); 257 - P(se.sum_exec_runtime); 258 SEQ_printf(m, "%-25s:%20Ld\n", 259 "nr_switches", (long long)(p->nvcsw + p->nivcsw)); 260 P(se.load.weight); ··· 277 278 void proc_sched_set_task(struct task_struct *p) 279 { 280 p->se.sleep_max = p->se.block_max = p->se.exec_max = p->se.wait_max = 0; 281 p->se.wait_runtime_overruns = p->se.wait_runtime_underruns = 0; 282 p->se.sum_exec_runtime = 0; 283 }
··· 44 (long long)p->se.wait_runtime, 45 (long long)(p->nvcsw + p->nivcsw), 46 p->prio, 47 + #ifdef CONFIG_SCHEDSTATS 48 (long long)p->se.sum_exec_runtime, 49 (long long)p->se.sum_wait_runtime, 50 (long long)p->se.sum_sleep_runtime, 51 (long long)p->se.wait_runtime_overruns, 52 + (long long)p->se.wait_runtime_underruns 53 + #else 54 + 0LL, 0LL, 0LL, 0LL, 0LL 55 + #endif 56 + ); 57 } 58 59 static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu, u64 now) ··· 171 u64 now = ktime_to_ns(ktime_get()); 172 int cpu; 173 174 + SEQ_printf(m, "Sched Debug Version: v0.05-v20, %s %.*s\n", 175 init_utsname()->release, 176 (int)strcspn(init_utsname()->version, " "), 177 init_utsname()->version); ··· 235 #define P(F) \ 236 SEQ_printf(m, "%-25s:%20Ld\n", #F, (long long)p->F) 237 238 + P(se.wait_runtime); 239 P(se.wait_start_fair); 240 P(se.exec_start); 241 P(se.sleep_start_fair); 242 + P(se.sum_exec_runtime); 243 + 244 + #ifdef CONFIG_SCHEDSTATS 245 + P(se.wait_start); 246 + P(se.sleep_start); 247 P(se.block_start); 248 P(se.sleep_max); 249 P(se.block_max); 250 P(se.exec_max); 251 P(se.wait_max); 252 P(se.wait_runtime_overruns); 253 P(se.wait_runtime_underruns); 254 P(se.sum_wait_runtime); 255 + #endif 256 SEQ_printf(m, "%-25s:%20Ld\n", 257 "nr_switches", (long long)(p->nvcsw + p->nivcsw)); 258 P(se.load.weight); ··· 269 270 void proc_sched_set_task(struct task_struct *p) 271 { 272 + #ifdef CONFIG_SCHEDSTATS 273 p->se.sleep_max = p->se.block_max = p->se.exec_max = p->se.wait_max = 0; 274 p->se.wait_runtime_overruns = p->se.wait_runtime_underruns = 0; 275 + #endif 276 p->se.sum_exec_runtime = 0; 277 }
+5 -16
kernel/sched_fair.c
··· 292 return; 293 294 delta_exec = curr->delta_exec; 295 - #ifdef CONFIG_SCHEDSTATS 296 - if (unlikely(delta_exec > curr->exec_max)) 297 - curr->exec_max = delta_exec; 298 - #endif 299 300 curr->sum_exec_runtime += delta_exec; 301 cfs_rq->exec_clock += delta_exec; ··· 349 update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) 350 { 351 se->wait_start_fair = cfs_rq->fair_clock; 352 - se->wait_start = now; 353 } 354 355 /* ··· 422 { 423 unsigned long delta_fair = se->delta_fair_run; 424 425 - #ifdef CONFIG_SCHEDSTATS 426 - { 427 - s64 delta_wait = now - se->wait_start; 428 - if (unlikely(delta_wait > se->wait_max)) 429 - se->wait_max = delta_wait; 430 - } 431 - #endif 432 433 if (unlikely(se->load.weight != NICE_0_LOAD)) 434 delta_fair = calc_weighted(delta_fair, se->load.weight, ··· 447 } 448 449 se->wait_start_fair = 0; 450 - se->wait_start = 0; 451 } 452 453 static inline void ··· 1032 * monopolize the CPU. Note: the parent runqueue is locked, 1033 * the child is not running yet. 1034 */ 1035 - static void task_new_fair(struct rq *rq, struct task_struct *p) 1036 { 1037 struct cfs_rq *cfs_rq = task_cfs_rq(p); 1038 struct sched_entity *se = &p->se; 1039 - u64 now = rq_clock(rq); 1040 1041 sched_info_queued(p); 1042 ··· 1062 p->se.wait_runtime = -(sysctl_sched_granularity / 2); 1063 1064 __enqueue_entity(cfs_rq, se); 1065 - inc_nr_running(p, rq, now); 1066 } 1067 1068 #ifdef CONFIG_FAIR_GROUP_SCHED
··· 292 return; 293 294 delta_exec = curr->delta_exec; 295 + schedstat_set(curr->exec_max, max((u64)delta_exec, curr->exec_max)); 296 297 curr->sum_exec_runtime += delta_exec; 298 cfs_rq->exec_clock += delta_exec; ··· 352 update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) 353 { 354 se->wait_start_fair = cfs_rq->fair_clock; 355 + schedstat_set(se->wait_start, now); 356 } 357 358 /* ··· 425 { 426 unsigned long delta_fair = se->delta_fair_run; 427 428 + schedstat_set(se->wait_max, max(se->wait_max, now - se->wait_start)); 429 430 if (unlikely(se->load.weight != NICE_0_LOAD)) 431 delta_fair = calc_weighted(delta_fair, se->load.weight, ··· 456 } 457 458 se->wait_start_fair = 0; 459 + schedstat_set(se->wait_start, 0); 460 } 461 462 static inline void ··· 1041 * monopolize the CPU. Note: the parent runqueue is locked, 1042 * the child is not running yet. 1043 */ 1044 + static void task_new_fair(struct rq *rq, struct task_struct *p, u64 now) 1045 { 1046 struct cfs_rq *cfs_rq = task_cfs_rq(p); 1047 struct sched_entity *se = &p->se; 1048 1049 sched_info_queued(p); 1050 ··· 1072 p->se.wait_runtime = -(sysctl_sched_granularity / 2); 1073 1074 __enqueue_entity(cfs_rq, se); 1075 } 1076 1077 #ifdef CONFIG_FAIR_GROUP_SCHED
+2 -12
kernel/sched_rt.c
··· 18 delta_exec = now - curr->se.exec_start; 19 if (unlikely((s64)delta_exec < 0)) 20 delta_exec = 0; 21 - if (unlikely(delta_exec > curr->se.exec_max)) 22 - curr->se.exec_max = delta_exec; 23 24 curr->se.sum_exec_runtime += delta_exec; 25 curr->se.exec_start = now; ··· 229 requeue_task_rt(rq, p); 230 } 231 232 - /* 233 - * No parent/child timeslice management necessary for RT tasks, 234 - * just activate them: 235 - */ 236 - static void task_new_rt(struct rq *rq, struct task_struct *p) 237 - { 238 - activate_task(rq, p, 1); 239 - } 240 - 241 static struct sched_class rt_sched_class __read_mostly = { 242 .enqueue_task = enqueue_task_rt, 243 .dequeue_task = dequeue_task_rt, ··· 242 .load_balance = load_balance_rt, 243 244 .task_tick = task_tick_rt, 245 - .task_new = task_new_rt, 246 };
··· 18 delta_exec = now - curr->se.exec_start; 19 if (unlikely((s64)delta_exec < 0)) 20 delta_exec = 0; 21 + 22 + schedstat_set(curr->se.exec_max, max(curr->se.exec_max, delta_exec)); 23 24 curr->se.sum_exec_runtime += delta_exec; 25 curr->se.exec_start = now; ··· 229 requeue_task_rt(rq, p); 230 } 231 232 static struct sched_class rt_sched_class __read_mostly = { 233 .enqueue_task = enqueue_task_rt, 234 .dequeue_task = dequeue_task_rt, ··· 251 .load_balance = load_balance_rt, 252 253 .task_tick = task_tick_rt, 254 };
+2
kernel/sched_stats.h
··· 116 } 117 # define schedstat_inc(rq, field) do { (rq)->field++; } while (0) 118 # define schedstat_add(rq, field, amt) do { (rq)->field += (amt); } while (0) 119 #else /* !CONFIG_SCHEDSTATS */ 120 static inline void 121 rq_sched_info_arrive(struct rq *rq, unsigned long long delta) ··· 126 {} 127 # define schedstat_inc(rq, field) do { } while (0) 128 # define schedstat_add(rq, field, amt) do { } while (0) 129 #endif 130 131 #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
··· 116 } 117 # define schedstat_inc(rq, field) do { (rq)->field++; } while (0) 118 # define schedstat_add(rq, field, amt) do { (rq)->field += (amt); } while (0) 119 + # define schedstat_set(var, val) do { var = (val); } while (0) 120 #else /* !CONFIG_SCHEDSTATS */ 121 static inline void 122 rq_sched_info_arrive(struct rq *rq, unsigned long long delta) ··· 125 {} 126 # define schedstat_inc(rq, field) do { } while (0) 127 # define schedstat_add(rq, field, amt) do { } while (0) 128 + # define schedstat_set(var, val) do { } while (0) 129 #endif 130 131 #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)