diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-02 14:15:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-02 14:15:27 -0400 |
commit | 370504cf7c68b953de55c41d5e0be97d30f3cf00 (patch) | |
tree | 1941a38f78083dca4852070c229363d81bbb9aae | |
parent | 160d6aaf60d75b71a48223b5bdc29285e18cff07 (diff) | |
parent | 94c18227d1e3f02de5b345bd3cd5c960214dc9c8 (diff) |
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
-rw-r--r-- | include/linux/sched.h | 24 | ||||
-rw-r--r-- | include/linux/topology.h | 1 | ||||
-rw-r--r-- | kernel/sched.c | 193 | ||||
-rw-r--r-- | kernel/sched_debug.c | 22 | ||||
-rw-r--r-- | kernel/sched_fair.c | 21 | ||||
-rw-r--r-- | kernel/sched_rt.c | 14 | ||||
-rw-r--r-- | kernel/sched_stats.h | 2 |
7 files changed, 134 insertions, 143 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 2e490271acf6..17249fae5014 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -734,7 +734,6 @@ struct sched_domain { | |||
734 | unsigned long max_interval; /* Maximum balance interval ms */ | 734 | unsigned long max_interval; /* Maximum balance interval ms */ |
735 | unsigned int busy_factor; /* less balancing by factor if busy */ | 735 | unsigned int busy_factor; /* less balancing by factor if busy */ |
736 | unsigned int imbalance_pct; /* No balance until over watermark */ | 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 */ | 737 | unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ |
739 | unsigned int busy_idx; | 738 | unsigned int busy_idx; |
740 | unsigned int idle_idx; | 739 | unsigned int idle_idx; |
@@ -875,7 +874,7 @@ struct sched_class { | |||
875 | 874 | ||
876 | void (*set_curr_task) (struct rq *rq); | 875 | void (*set_curr_task) (struct rq *rq); |
877 | void (*task_tick) (struct rq *rq, struct task_struct *p); | 876 | void (*task_tick) (struct rq *rq, struct task_struct *p); |
878 | void (*task_new) (struct rq *rq, struct task_struct *p); | 877 | void (*task_new) (struct rq *rq, struct task_struct *p, u64 now); |
879 | }; | 878 | }; |
880 | 879 | ||
881 | struct load_weight { | 880 | struct load_weight { |
@@ -905,23 +904,28 @@ struct sched_entity { | |||
905 | struct rb_node run_node; | 904 | struct rb_node run_node; |
906 | unsigned int on_rq; | 905 | unsigned int on_rq; |
907 | 906 | ||
907 | u64 exec_start; | ||
908 | u64 sum_exec_runtime; | ||
908 | u64 wait_start_fair; | 909 | u64 wait_start_fair; |
910 | u64 sleep_start_fair; | ||
911 | |||
912 | #ifdef CONFIG_SCHEDSTATS | ||
909 | u64 wait_start; | 913 | u64 wait_start; |
910 | u64 exec_start; | 914 | u64 wait_max; |
915 | s64 sum_wait_runtime; | ||
916 | |||
911 | u64 sleep_start; | 917 | u64 sleep_start; |
912 | u64 sleep_start_fair; | ||
913 | u64 block_start; | ||
914 | u64 sleep_max; | 918 | u64 sleep_max; |
919 | s64 sum_sleep_runtime; | ||
920 | |||
921 | u64 block_start; | ||
915 | u64 block_max; | 922 | u64 block_max; |
916 | u64 exec_max; | 923 | u64 exec_max; |
917 | u64 wait_max; | ||
918 | u64 last_ran; | ||
919 | 924 | ||
920 | u64 sum_exec_runtime; | ||
921 | s64 sum_wait_runtime; | ||
922 | s64 sum_sleep_runtime; | ||
923 | unsigned long wait_runtime_overruns; | 925 | unsigned long wait_runtime_overruns; |
924 | unsigned long wait_runtime_underruns; | 926 | unsigned long wait_runtime_underruns; |
927 | #endif | ||
928 | |||
925 | #ifdef CONFIG_FAIR_GROUP_SCHED | 929 | #ifdef CONFIG_FAIR_GROUP_SCHED |
926 | struct sched_entity *parent; | 930 | struct sched_entity *parent; |
927 | /* rq on which this entity is (to be) queued: */ | 931 | /* rq on which this entity is (to be) queued: */ |
diff --git a/include/linux/topology.h b/include/linux/topology.h index d0890a7e5bab..525d437b1253 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h | |||
@@ -185,7 +185,6 @@ | |||
185 | .max_interval = 64*num_online_cpus(), \ | 185 | .max_interval = 64*num_online_cpus(), \ |
186 | .busy_factor = 128, \ | 186 | .busy_factor = 128, \ |
187 | .imbalance_pct = 133, \ | 187 | .imbalance_pct = 133, \ |
188 | .cache_hot_time = (10*1000000), \ | ||
189 | .cache_nice_tries = 1, \ | 188 | .cache_nice_tries = 1, \ |
190 | .busy_idx = 3, \ | 189 | .busy_idx = 3, \ |
191 | .idle_idx = 3, \ | 190 | .idle_idx = 3, \ |
diff --git a/kernel/sched.c b/kernel/sched.c index 238a76957e86..72bb9483d949 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -637,7 +637,7 @@ static u64 div64_likely32(u64 divident, unsigned long divisor) | |||
637 | 637 | ||
638 | #define WMULT_SHIFT 32 | 638 | #define WMULT_SHIFT 32 |
639 | 639 | ||
640 | static inline unsigned long | 640 | static unsigned long |
641 | calc_delta_mine(unsigned long delta_exec, unsigned long weight, | 641 | calc_delta_mine(unsigned long delta_exec, unsigned long weight, |
642 | struct load_weight *lw) | 642 | struct load_weight *lw) |
643 | { | 643 | { |
@@ -657,7 +657,7 @@ calc_delta_mine(unsigned long delta_exec, unsigned long weight, | |||
657 | tmp = (tmp * lw->inv_weight) >> WMULT_SHIFT; | 657 | tmp = (tmp * lw->inv_weight) >> WMULT_SHIFT; |
658 | } | 658 | } |
659 | 659 | ||
660 | return (unsigned long)min(tmp, (u64)sysctl_sched_runtime_limit); | 660 | return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX); |
661 | } | 661 | } |
662 | 662 | ||
663 | static inline unsigned long | 663 | static inline unsigned long |
@@ -678,46 +678,6 @@ static void update_load_sub(struct load_weight *lw, unsigned long dec) | |||
678 | lw->inv_weight = 0; | 678 | lw->inv_weight = 0; |
679 | } | 679 | } |
680 | 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 | /* | 681 | /* |
722 | * To aid in avoiding the subversion of "niceness" due to uneven distribution | 682 | * To aid in avoiding the subversion of "niceness" due to uneven distribution |
723 | * of tasks with abnormal "nice" values across CPUs the contribution that | 683 | * of tasks with abnormal "nice" values across CPUs the contribution that |
@@ -727,19 +687,6 @@ static void update_curr_load(struct rq *rq, u64 now) | |||
727 | * slice expiry etc. | 687 | * slice expiry etc. |
728 | */ | 688 | */ |
729 | 689 | ||
730 | /* | ||
731 | * Assume: static_prio_timeslice(NICE_TO_PRIO(0)) == DEF_TIMESLICE | ||
732 | * If static_prio_timeslice() is ever changed to break this assumption then | ||
733 | * this code will need modification | ||
734 | */ | ||
735 | #define TIME_SLICE_NICE_ZERO DEF_TIMESLICE | ||
736 | #define load_weight(lp) \ | ||
737 | (((lp) * SCHED_LOAD_SCALE) / TIME_SLICE_NICE_ZERO) | ||
738 | #define PRIO_TO_LOAD_WEIGHT(prio) \ | ||
739 | load_weight(static_prio_timeslice(prio)) | ||
740 | #define RTPRIO_TO_LOAD_WEIGHT(rp) \ | ||
741 | (PRIO_TO_LOAD_WEIGHT(MAX_RT_PRIO) + load_weight(rp)) | ||
742 | |||
743 | #define WEIGHT_IDLEPRIO 2 | 690 | #define WEIGHT_IDLEPRIO 2 |
744 | #define WMULT_IDLEPRIO (1 << 31) | 691 | #define WMULT_IDLEPRIO (1 << 31) |
745 | 692 | ||
@@ -781,32 +728,6 @@ static const u32 prio_to_wmult[40] = { | |||
781 | /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, | 728 | /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, |
782 | }; | 729 | }; |
783 | 730 | ||
784 | static inline void | ||
785 | inc_load(struct rq *rq, const struct task_struct *p, u64 now) | ||
786 | { | ||
787 | update_curr_load(rq, now); | ||
788 | update_load_add(&rq->ls.load, p->se.load.weight); | ||
789 | } | ||
790 | |||
791 | static inline void | ||
792 | dec_load(struct rq *rq, const struct task_struct *p, u64 now) | ||
793 | { | ||
794 | update_curr_load(rq, now); | ||
795 | update_load_sub(&rq->ls.load, p->se.load.weight); | ||
796 | } | ||
797 | |||
798 | static inline void inc_nr_running(struct task_struct *p, struct rq *rq, u64 now) | ||
799 | { | ||
800 | rq->nr_running++; | ||
801 | inc_load(rq, p, now); | ||
802 | } | ||
803 | |||
804 | static inline void dec_nr_running(struct task_struct *p, struct rq *rq, u64 now) | ||
805 | { | ||
806 | rq->nr_running--; | ||
807 | dec_load(rq, p, now); | ||
808 | } | ||
809 | |||
810 | static void activate_task(struct rq *rq, struct task_struct *p, int wakeup); | 731 | static void activate_task(struct rq *rq, struct task_struct *p, int wakeup); |
811 | 732 | ||
812 | /* | 733 | /* |
@@ -837,6 +758,72 @@ static int balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest, | |||
837 | 758 | ||
838 | #define sched_class_highest (&rt_sched_class) | 759 | #define sched_class_highest (&rt_sched_class) |
839 | 760 | ||
761 | static void __update_curr_load(struct rq *rq, struct load_stat *ls) | ||
762 | { | ||
763 | if (rq->curr != rq->idle && ls->load.weight) { | ||
764 | ls->delta_exec += ls->delta_stat; | ||
765 | ls->delta_fair += calc_delta_fair(ls->delta_stat, &ls->load); | ||
766 | ls->delta_stat = 0; | ||
767 | } | ||
768 | } | ||
769 | |||
770 | /* | ||
771 | * Update delta_exec, delta_fair fields for rq. | ||
772 | * | ||
773 | * delta_fair clock advances at a rate inversely proportional to | ||
774 | * total load (rq->ls.load.weight) on the runqueue, while | ||
775 | * delta_exec advances at the same rate as wall-clock (provided | ||
776 | * cpu is not idle). | ||
777 | * | ||
778 | * delta_exec / delta_fair is a measure of the (smoothened) load on this | ||
779 | * runqueue over any given interval. This (smoothened) load is used | ||
780 | * during load balance. | ||
781 | * | ||
782 | * This function is called /before/ updating rq->ls.load | ||
783 | * and when switching tasks. | ||
784 | */ | ||
785 | static void update_curr_load(struct rq *rq, u64 now) | ||
786 | { | ||
787 | struct load_stat *ls = &rq->ls; | ||
788 | u64 start; | ||
789 | |||
790 | start = ls->load_update_start; | ||
791 | ls->load_update_start = now; | ||
792 | ls->delta_stat += now - start; | ||
793 | /* | ||
794 | * Stagger updates to ls->delta_fair. Very frequent updates | ||
795 | * can be expensive. | ||
796 | */ | ||
797 | if (ls->delta_stat >= sysctl_sched_stat_granularity) | ||
798 | __update_curr_load(rq, ls); | ||
799 | } | ||
800 | |||
801 | static inline void | ||
802 | inc_load(struct rq *rq, const struct task_struct *p, u64 now) | ||
803 | { | ||
804 | update_curr_load(rq, now); | ||
805 | update_load_add(&rq->ls.load, p->se.load.weight); | ||
806 | } | ||
807 | |||
808 | static inline void | ||
809 | dec_load(struct rq *rq, const struct task_struct *p, u64 now) | ||
810 | { | ||
811 | update_curr_load(rq, now); | ||
812 | update_load_sub(&rq->ls.load, p->se.load.weight); | ||
813 | } | ||
814 | |||
815 | static void inc_nr_running(struct task_struct *p, struct rq *rq, u64 now) | ||
816 | { | ||
817 | rq->nr_running++; | ||
818 | inc_load(rq, p, now); | ||
819 | } | ||
820 | |||
821 | static void dec_nr_running(struct task_struct *p, struct rq *rq, u64 now) | ||
822 | { | ||
823 | rq->nr_running--; | ||
824 | dec_load(rq, p, now); | ||
825 | } | ||
826 | |||
840 | static void set_load_weight(struct task_struct *p) | 827 | static void set_load_weight(struct task_struct *p) |
841 | { | 828 | { |
842 | task_rq(p)->cfs.wait_runtime -= p->se.wait_runtime; | 829 | task_rq(p)->cfs.wait_runtime -= p->se.wait_runtime; |
@@ -996,18 +983,21 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | |||
996 | u64 clock_offset, fair_clock_offset; | 983 | u64 clock_offset, fair_clock_offset; |
997 | 984 | ||
998 | clock_offset = old_rq->clock - new_rq->clock; | 985 | clock_offset = old_rq->clock - new_rq->clock; |
999 | fair_clock_offset = old_rq->cfs.fair_clock - | 986 | fair_clock_offset = old_rq->cfs.fair_clock - new_rq->cfs.fair_clock; |
1000 | new_rq->cfs.fair_clock; | 987 | |
1001 | if (p->se.wait_start) | ||
1002 | p->se.wait_start -= clock_offset; | ||
1003 | if (p->se.wait_start_fair) | 988 | if (p->se.wait_start_fair) |
1004 | p->se.wait_start_fair -= fair_clock_offset; | 989 | p->se.wait_start_fair -= fair_clock_offset; |
990 | if (p->se.sleep_start_fair) | ||
991 | p->se.sleep_start_fair -= fair_clock_offset; | ||
992 | |||
993 | #ifdef CONFIG_SCHEDSTATS | ||
994 | if (p->se.wait_start) | ||
995 | p->se.wait_start -= clock_offset; | ||
1005 | if (p->se.sleep_start) | 996 | if (p->se.sleep_start) |
1006 | p->se.sleep_start -= clock_offset; | 997 | p->se.sleep_start -= clock_offset; |
1007 | if (p->se.block_start) | 998 | if (p->se.block_start) |
1008 | p->se.block_start -= clock_offset; | 999 | p->se.block_start -= clock_offset; |
1009 | if (p->se.sleep_start_fair) | 1000 | #endif |
1010 | p->se.sleep_start_fair -= fair_clock_offset; | ||
1011 | 1001 | ||
1012 | __set_task_cpu(p, new_cpu); | 1002 | __set_task_cpu(p, new_cpu); |
1013 | } | 1003 | } |
@@ -1568,17 +1558,19 @@ int fastcall wake_up_state(struct task_struct *p, unsigned int state) | |||
1568 | static void __sched_fork(struct task_struct *p) | 1558 | static void __sched_fork(struct task_struct *p) |
1569 | { | 1559 | { |
1570 | p->se.wait_start_fair = 0; | 1560 | p->se.wait_start_fair = 0; |
1571 | p->se.wait_start = 0; | ||
1572 | p->se.exec_start = 0; | 1561 | p->se.exec_start = 0; |
1573 | p->se.sum_exec_runtime = 0; | 1562 | p->se.sum_exec_runtime = 0; |
1574 | p->se.delta_exec = 0; | 1563 | p->se.delta_exec = 0; |
1575 | p->se.delta_fair_run = 0; | 1564 | p->se.delta_fair_run = 0; |
1576 | p->se.delta_fair_sleep = 0; | 1565 | p->se.delta_fair_sleep = 0; |
1577 | p->se.wait_runtime = 0; | 1566 | p->se.wait_runtime = 0; |
1567 | p->se.sleep_start_fair = 0; | ||
1568 | |||
1569 | #ifdef CONFIG_SCHEDSTATS | ||
1570 | p->se.wait_start = 0; | ||
1578 | p->se.sum_wait_runtime = 0; | 1571 | p->se.sum_wait_runtime = 0; |
1579 | p->se.sum_sleep_runtime = 0; | 1572 | p->se.sum_sleep_runtime = 0; |
1580 | p->se.sleep_start = 0; | 1573 | p->se.sleep_start = 0; |
1581 | p->se.sleep_start_fair = 0; | ||
1582 | p->se.block_start = 0; | 1574 | p->se.block_start = 0; |
1583 | p->se.sleep_max = 0; | 1575 | p->se.sleep_max = 0; |
1584 | p->se.block_max = 0; | 1576 | p->se.block_max = 0; |
@@ -1586,6 +1578,7 @@ static void __sched_fork(struct task_struct *p) | |||
1586 | p->se.wait_max = 0; | 1578 | p->se.wait_max = 0; |
1587 | p->se.wait_runtime_overruns = 0; | 1579 | p->se.wait_runtime_overruns = 0; |
1588 | p->se.wait_runtime_underruns = 0; | 1580 | p->se.wait_runtime_underruns = 0; |
1581 | #endif | ||
1589 | 1582 | ||
1590 | INIT_LIST_HEAD(&p->run_list); | 1583 | INIT_LIST_HEAD(&p->run_list); |
1591 | p->se.on_rq = 0; | 1584 | p->se.on_rq = 0; |
@@ -1654,22 +1647,27 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags) | |||
1654 | unsigned long flags; | 1647 | unsigned long flags; |
1655 | struct rq *rq; | 1648 | struct rq *rq; |
1656 | int this_cpu; | 1649 | int this_cpu; |
1650 | u64 now; | ||
1657 | 1651 | ||
1658 | rq = task_rq_lock(p, &flags); | 1652 | rq = task_rq_lock(p, &flags); |
1659 | BUG_ON(p->state != TASK_RUNNING); | 1653 | BUG_ON(p->state != TASK_RUNNING); |
1660 | this_cpu = smp_processor_id(); /* parent's CPU */ | 1654 | this_cpu = smp_processor_id(); /* parent's CPU */ |
1655 | now = rq_clock(rq); | ||
1661 | 1656 | ||
1662 | p->prio = effective_prio(p); | 1657 | p->prio = effective_prio(p); |
1663 | 1658 | ||
1664 | if (!sysctl_sched_child_runs_first || (clone_flags & CLONE_VM) || | 1659 | if (!p->sched_class->task_new || !sysctl_sched_child_runs_first || |
1665 | task_cpu(p) != this_cpu || !current->se.on_rq) { | 1660 | (clone_flags & CLONE_VM) || task_cpu(p) != this_cpu || |
1661 | !current->se.on_rq) { | ||
1662 | |||
1666 | activate_task(rq, p, 0); | 1663 | activate_task(rq, p, 0); |
1667 | } else { | 1664 | } else { |
1668 | /* | 1665 | /* |
1669 | * Let the scheduling class do new task startup | 1666 | * Let the scheduling class do new task startup |
1670 | * management (if any): | 1667 | * management (if any): |
1671 | */ | 1668 | */ |
1672 | p->sched_class->task_new(rq, p); | 1669 | p->sched_class->task_new(rq, p, now); |
1670 | inc_nr_running(p, rq, now); | ||
1673 | } | 1671 | } |
1674 | check_preempt_curr(rq, p); | 1672 | check_preempt_curr(rq, p); |
1675 | task_rq_unlock(rq, &flags); | 1673 | task_rq_unlock(rq, &flags); |
@@ -2908,8 +2906,7 @@ static void active_load_balance(struct rq *busiest_rq, int busiest_cpu) | |||
2908 | schedstat_inc(sd, alb_cnt); | 2906 | schedstat_inc(sd, alb_cnt); |
2909 | 2907 | ||
2910 | if (move_tasks(target_rq, target_cpu, busiest_rq, 1, | 2908 | if (move_tasks(target_rq, target_cpu, busiest_rq, 1, |
2911 | RTPRIO_TO_LOAD_WEIGHT(100), sd, CPU_IDLE, | 2909 | ULONG_MAX, sd, CPU_IDLE, NULL)) |
2912 | NULL)) | ||
2913 | schedstat_inc(sd, alb_pushed); | 2910 | schedstat_inc(sd, alb_pushed); |
2914 | else | 2911 | else |
2915 | schedstat_inc(sd, alb_failed); | 2912 | schedstat_inc(sd, alb_failed); |
@@ -5269,8 +5266,6 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd) | |||
5269 | sizeof(int), 0644, proc_dointvec_minmax); | 5266 | sizeof(int), 0644, proc_dointvec_minmax); |
5270 | set_table_entry(&table[8], 9, "imbalance_pct", &sd->imbalance_pct, | 5267 | set_table_entry(&table[8], 9, "imbalance_pct", &sd->imbalance_pct, |
5271 | sizeof(int), 0644, proc_dointvec_minmax); | 5268 | sizeof(int), 0644, proc_dointvec_minmax); |
5272 | set_table_entry(&table[9], 10, "cache_hot_time", &sd->cache_hot_time, | ||
5273 | sizeof(long long), 0644, proc_doulongvec_minmax); | ||
5274 | set_table_entry(&table[10], 11, "cache_nice_tries", | 5269 | set_table_entry(&table[10], 11, "cache_nice_tries", |
5275 | &sd->cache_nice_tries, | 5270 | &sd->cache_nice_tries, |
5276 | sizeof(int), 0644, proc_dointvec_minmax); | 5271 | sizeof(int), 0644, proc_dointvec_minmax); |
@@ -6590,12 +6585,14 @@ void normalize_rt_tasks(void) | |||
6590 | do_each_thread(g, p) { | 6585 | do_each_thread(g, p) { |
6591 | p->se.fair_key = 0; | 6586 | p->se.fair_key = 0; |
6592 | p->se.wait_runtime = 0; | 6587 | p->se.wait_runtime = 0; |
6588 | p->se.exec_start = 0; | ||
6593 | p->se.wait_start_fair = 0; | 6589 | p->se.wait_start_fair = 0; |
6590 | p->se.sleep_start_fair = 0; | ||
6591 | #ifdef CONFIG_SCHEDSTATS | ||
6594 | p->se.wait_start = 0; | 6592 | p->se.wait_start = 0; |
6595 | p->se.exec_start = 0; | ||
6596 | p->se.sleep_start = 0; | 6593 | p->se.sleep_start = 0; |
6597 | p->se.sleep_start_fair = 0; | ||
6598 | p->se.block_start = 0; | 6594 | p->se.block_start = 0; |
6595 | #endif | ||
6599 | task_rq(p)->cfs.fair_clock = 0; | 6596 | task_rq(p)->cfs.fair_clock = 0; |
6600 | task_rq(p)->clock = 0; | 6597 | task_rq(p)->clock = 0; |
6601 | 6598 | ||
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 0eca442b7792..1c61e5315ad2 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -44,11 +44,16 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p, u64 now) | |||
44 | (long long)p->se.wait_runtime, | 44 | (long long)p->se.wait_runtime, |
45 | (long long)(p->nvcsw + p->nivcsw), | 45 | (long long)(p->nvcsw + p->nivcsw), |
46 | p->prio, | 46 | p->prio, |
47 | #ifdef CONFIG_SCHEDSTATS | ||
47 | (long long)p->se.sum_exec_runtime, | 48 | (long long)p->se.sum_exec_runtime, |
48 | (long long)p->se.sum_wait_runtime, | 49 | (long long)p->se.sum_wait_runtime, |
49 | (long long)p->se.sum_sleep_runtime, | 50 | (long long)p->se.sum_sleep_runtime, |
50 | (long long)p->se.wait_runtime_overruns, | 51 | (long long)p->se.wait_runtime_overruns, |
51 | (long long)p->se.wait_runtime_underruns); | 52 | (long long)p->se.wait_runtime_underruns |
53 | #else | ||
54 | 0LL, 0LL, 0LL, 0LL, 0LL | ||
55 | #endif | ||
56 | ); | ||
52 | } | 57 | } |
53 | 58 | ||
54 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu, u64 now) | 59 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu, u64 now) |
@@ -171,7 +176,7 @@ static int sched_debug_show(struct seq_file *m, void *v) | |||
171 | u64 now = ktime_to_ns(ktime_get()); | 176 | u64 now = ktime_to_ns(ktime_get()); |
172 | int cpu; | 177 | int cpu; |
173 | 178 | ||
174 | SEQ_printf(m, "Sched Debug Version: v0.05, %s %.*s\n", | 179 | SEQ_printf(m, "Sched Debug Version: v0.05-v20, %s %.*s\n", |
175 | init_utsname()->release, | 180 | init_utsname()->release, |
176 | (int)strcspn(init_utsname()->version, " "), | 181 | (int)strcspn(init_utsname()->version, " "), |
177 | init_utsname()->version); | 182 | init_utsname()->version); |
@@ -235,21 +240,24 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
235 | #define P(F) \ | 240 | #define P(F) \ |
236 | SEQ_printf(m, "%-25s:%20Ld\n", #F, (long long)p->F) | 241 | SEQ_printf(m, "%-25s:%20Ld\n", #F, (long long)p->F) |
237 | 242 | ||
238 | P(se.wait_start); | 243 | P(se.wait_runtime); |
239 | P(se.wait_start_fair); | 244 | P(se.wait_start_fair); |
240 | P(se.exec_start); | 245 | P(se.exec_start); |
241 | P(se.sleep_start); | ||
242 | P(se.sleep_start_fair); | 246 | P(se.sleep_start_fair); |
247 | P(se.sum_exec_runtime); | ||
248 | |||
249 | #ifdef CONFIG_SCHEDSTATS | ||
250 | P(se.wait_start); | ||
251 | P(se.sleep_start); | ||
243 | P(se.block_start); | 252 | P(se.block_start); |
244 | P(se.sleep_max); | 253 | P(se.sleep_max); |
245 | P(se.block_max); | 254 | P(se.block_max); |
246 | P(se.exec_max); | 255 | P(se.exec_max); |
247 | P(se.wait_max); | 256 | P(se.wait_max); |
248 | P(se.wait_runtime); | ||
249 | P(se.wait_runtime_overruns); | 257 | P(se.wait_runtime_overruns); |
250 | P(se.wait_runtime_underruns); | 258 | P(se.wait_runtime_underruns); |
251 | P(se.sum_wait_runtime); | 259 | P(se.sum_wait_runtime); |
252 | P(se.sum_exec_runtime); | 260 | #endif |
253 | SEQ_printf(m, "%-25s:%20Ld\n", | 261 | SEQ_printf(m, "%-25s:%20Ld\n", |
254 | "nr_switches", (long long)(p->nvcsw + p->nivcsw)); | 262 | "nr_switches", (long long)(p->nvcsw + p->nivcsw)); |
255 | P(se.load.weight); | 263 | P(se.load.weight); |
@@ -269,7 +277,9 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
269 | 277 | ||
270 | void proc_sched_set_task(struct task_struct *p) | 278 | void proc_sched_set_task(struct task_struct *p) |
271 | { | 279 | { |
280 | #ifdef CONFIG_SCHEDSTATS | ||
272 | p->se.sleep_max = p->se.block_max = p->se.exec_max = p->se.wait_max = 0; | 281 | p->se.sleep_max = p->se.block_max = p->se.exec_max = p->se.wait_max = 0; |
273 | p->se.wait_runtime_overruns = p->se.wait_runtime_underruns = 0; | 282 | p->se.wait_runtime_overruns = p->se.wait_runtime_underruns = 0; |
283 | #endif | ||
274 | p->se.sum_exec_runtime = 0; | 284 | p->se.sum_exec_runtime = 0; |
275 | } | 285 | } |
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 6971db0a7160..6f579ff5a9bc 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -292,10 +292,7 @@ __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr, u64 now) | |||
292 | return; | 292 | return; |
293 | 293 | ||
294 | delta_exec = curr->delta_exec; | 294 | delta_exec = curr->delta_exec; |
295 | #ifdef CONFIG_SCHEDSTATS | 295 | schedstat_set(curr->exec_max, max((u64)delta_exec, curr->exec_max)); |
296 | if (unlikely(delta_exec > curr->exec_max)) | ||
297 | curr->exec_max = delta_exec; | ||
298 | #endif | ||
299 | 296 | ||
300 | curr->sum_exec_runtime += delta_exec; | 297 | curr->sum_exec_runtime += delta_exec; |
301 | cfs_rq->exec_clock += delta_exec; | 298 | cfs_rq->exec_clock += delta_exec; |
@@ -352,7 +349,7 @@ static inline void | |||
352 | update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) | 349 | update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) |
353 | { | 350 | { |
354 | se->wait_start_fair = cfs_rq->fair_clock; | 351 | se->wait_start_fair = cfs_rq->fair_clock; |
355 | se->wait_start = now; | 352 | schedstat_set(se->wait_start, now); |
356 | } | 353 | } |
357 | 354 | ||
358 | /* | 355 | /* |
@@ -425,13 +422,7 @@ __update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) | |||
425 | { | 422 | { |
426 | unsigned long delta_fair = se->delta_fair_run; | 423 | unsigned long delta_fair = se->delta_fair_run; |
427 | 424 | ||
428 | #ifdef CONFIG_SCHEDSTATS | 425 | schedstat_set(se->wait_max, max(se->wait_max, now - se->wait_start)); |
429 | { | ||
430 | s64 delta_wait = now - se->wait_start; | ||
431 | if (unlikely(delta_wait > se->wait_max)) | ||
432 | se->wait_max = delta_wait; | ||
433 | } | ||
434 | #endif | ||
435 | 426 | ||
436 | if (unlikely(se->load.weight != NICE_0_LOAD)) | 427 | if (unlikely(se->load.weight != NICE_0_LOAD)) |
437 | delta_fair = calc_weighted(delta_fair, se->load.weight, | 428 | delta_fair = calc_weighted(delta_fair, se->load.weight, |
@@ -456,7 +447,7 @@ update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se, u64 now) | |||
456 | } | 447 | } |
457 | 448 | ||
458 | se->wait_start_fair = 0; | 449 | se->wait_start_fair = 0; |
459 | se->wait_start = 0; | 450 | schedstat_set(se->wait_start, 0); |
460 | } | 451 | } |
461 | 452 | ||
462 | static inline void | 453 | static inline void |
@@ -1041,11 +1032,10 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr) | |||
1041 | * monopolize the CPU. Note: the parent runqueue is locked, | 1032 | * monopolize the CPU. Note: the parent runqueue is locked, |
1042 | * the child is not running yet. | 1033 | * the child is not running yet. |
1043 | */ | 1034 | */ |
1044 | static void task_new_fair(struct rq *rq, struct task_struct *p) | 1035 | static void task_new_fair(struct rq *rq, struct task_struct *p, u64 now) |
1045 | { | 1036 | { |
1046 | struct cfs_rq *cfs_rq = task_cfs_rq(p); | 1037 | struct cfs_rq *cfs_rq = task_cfs_rq(p); |
1047 | struct sched_entity *se = &p->se; | 1038 | struct sched_entity *se = &p->se; |
1048 | u64 now = rq_clock(rq); | ||
1049 | 1039 | ||
1050 | sched_info_queued(p); | 1040 | sched_info_queued(p); |
1051 | 1041 | ||
@@ -1072,7 +1062,6 @@ static void task_new_fair(struct rq *rq, struct task_struct *p) | |||
1072 | p->se.wait_runtime = -(sysctl_sched_granularity / 2); | 1062 | p->se.wait_runtime = -(sysctl_sched_granularity / 2); |
1073 | 1063 | ||
1074 | __enqueue_entity(cfs_rq, se); | 1064 | __enqueue_entity(cfs_rq, se); |
1075 | inc_nr_running(p, rq, now); | ||
1076 | } | 1065 | } |
1077 | 1066 | ||
1078 | #ifdef CONFIG_FAIR_GROUP_SCHED | 1067 | #ifdef CONFIG_FAIR_GROUP_SCHED |
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 1192a2741b99..002fcf8d3f64 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -18,8 +18,8 @@ static inline void update_curr_rt(struct rq *rq, u64 now) | |||
18 | delta_exec = now - curr->se.exec_start; | 18 | delta_exec = now - curr->se.exec_start; |
19 | if (unlikely((s64)delta_exec < 0)) | 19 | if (unlikely((s64)delta_exec < 0)) |
20 | delta_exec = 0; | 20 | delta_exec = 0; |
21 | if (unlikely(delta_exec > curr->se.exec_max)) | 21 | |
22 | curr->se.exec_max = delta_exec; | 22 | schedstat_set(curr->se.exec_max, max(curr->se.exec_max, delta_exec)); |
23 | 23 | ||
24 | curr->se.sum_exec_runtime += delta_exec; | 24 | curr->se.sum_exec_runtime += delta_exec; |
25 | curr->se.exec_start = now; | 25 | curr->se.exec_start = now; |
@@ -229,15 +229,6 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p) | |||
229 | requeue_task_rt(rq, p); | 229 | requeue_task_rt(rq, p); |
230 | } | 230 | } |
231 | 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 = { | 232 | static struct sched_class rt_sched_class __read_mostly = { |
242 | .enqueue_task = enqueue_task_rt, | 233 | .enqueue_task = enqueue_task_rt, |
243 | .dequeue_task = dequeue_task_rt, | 234 | .dequeue_task = dequeue_task_rt, |
@@ -251,5 +242,4 @@ static struct sched_class rt_sched_class __read_mostly = { | |||
251 | .load_balance = load_balance_rt, | 242 | .load_balance = load_balance_rt, |
252 | 243 | ||
253 | .task_tick = task_tick_rt, | 244 | .task_tick = task_tick_rt, |
254 | .task_new = task_new_rt, | ||
255 | }; | 245 | }; |
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index c63c38f6fa6e..c20a94dda61e 100644 --- a/kernel/sched_stats.h +++ b/kernel/sched_stats.h | |||
@@ -116,6 +116,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta) | |||
116 | } | 116 | } |
117 | # define schedstat_inc(rq, field) do { (rq)->field++; } while (0) | 117 | # define schedstat_inc(rq, field) do { (rq)->field++; } while (0) |
118 | # define schedstat_add(rq, field, amt) do { (rq)->field += (amt); } 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) | ||
119 | #else /* !CONFIG_SCHEDSTATS */ | 120 | #else /* !CONFIG_SCHEDSTATS */ |
120 | static inline void | 121 | static inline void |
121 | rq_sched_info_arrive(struct rq *rq, unsigned long long delta) | 122 | rq_sched_info_arrive(struct rq *rq, unsigned long long delta) |
@@ -125,6 +126,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta) | |||
125 | {} | 126 | {} |
126 | # define schedstat_inc(rq, field) do { } while (0) | 127 | # define schedstat_inc(rq, field) do { } while (0) |
127 | # define schedstat_add(rq, field, amt) do { } while (0) | 128 | # define schedstat_add(rq, field, amt) do { } while (0) |
129 | # define schedstat_set(var, val) do { } while (0) | ||
128 | #endif | 130 | #endif |
129 | 131 | ||
130 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) | 132 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) |