diff options
Diffstat (limited to 'kernel/sched/core.c')
| -rw-r--r-- | kernel/sched/core.c | 207 |
1 files changed, 126 insertions, 81 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f5c6635b806c..ae365aaa8181 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -1745,8 +1745,10 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p) | |||
| 1745 | p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0; | 1745 | p->numa_scan_seq = p->mm ? p->mm->numa_scan_seq : 0; |
| 1746 | p->numa_scan_period = sysctl_numa_balancing_scan_delay; | 1746 | p->numa_scan_period = sysctl_numa_balancing_scan_delay; |
| 1747 | p->numa_work.next = &p->numa_work; | 1747 | p->numa_work.next = &p->numa_work; |
| 1748 | p->numa_faults = NULL; | 1748 | p->numa_faults_memory = NULL; |
| 1749 | p->numa_faults_buffer = NULL; | 1749 | p->numa_faults_buffer_memory = NULL; |
| 1750 | p->last_task_numa_placement = 0; | ||
| 1751 | p->last_sum_exec_runtime = 0; | ||
| 1750 | 1752 | ||
| 1751 | INIT_LIST_HEAD(&p->numa_entry); | 1753 | INIT_LIST_HEAD(&p->numa_entry); |
| 1752 | p->numa_group = NULL; | 1754 | p->numa_group = NULL; |
| @@ -2149,8 +2151,6 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) | |||
| 2149 | if (mm) | 2151 | if (mm) |
| 2150 | mmdrop(mm); | 2152 | mmdrop(mm); |
| 2151 | if (unlikely(prev_state == TASK_DEAD)) { | 2153 | if (unlikely(prev_state == TASK_DEAD)) { |
| 2152 | task_numa_free(prev); | ||
| 2153 | |||
| 2154 | if (prev->sched_class->task_dead) | 2154 | if (prev->sched_class->task_dead) |
| 2155 | prev->sched_class->task_dead(prev); | 2155 | prev->sched_class->task_dead(prev); |
| 2156 | 2156 | ||
| @@ -2167,13 +2167,6 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) | |||
| 2167 | 2167 | ||
| 2168 | #ifdef CONFIG_SMP | 2168 | #ifdef CONFIG_SMP |
| 2169 | 2169 | ||
| 2170 | /* assumes rq->lock is held */ | ||
| 2171 | static inline void pre_schedule(struct rq *rq, struct task_struct *prev) | ||
| 2172 | { | ||
| 2173 | if (prev->sched_class->pre_schedule) | ||
| 2174 | prev->sched_class->pre_schedule(rq, prev); | ||
| 2175 | } | ||
| 2176 | |||
| 2177 | /* rq->lock is NOT held, but preemption is disabled */ | 2170 | /* rq->lock is NOT held, but preemption is disabled */ |
| 2178 | static inline void post_schedule(struct rq *rq) | 2171 | static inline void post_schedule(struct rq *rq) |
| 2179 | { | 2172 | { |
| @@ -2191,10 +2184,6 @@ static inline void post_schedule(struct rq *rq) | |||
| 2191 | 2184 | ||
| 2192 | #else | 2185 | #else |
| 2193 | 2186 | ||
| 2194 | static inline void pre_schedule(struct rq *rq, struct task_struct *p) | ||
| 2195 | { | ||
| 2196 | } | ||
| 2197 | |||
| 2198 | static inline void post_schedule(struct rq *rq) | 2187 | static inline void post_schedule(struct rq *rq) |
| 2199 | { | 2188 | { |
| 2200 | } | 2189 | } |
| @@ -2510,8 +2499,13 @@ void __kprobes preempt_count_add(int val) | |||
| 2510 | DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >= | 2499 | DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >= |
| 2511 | PREEMPT_MASK - 10); | 2500 | PREEMPT_MASK - 10); |
| 2512 | #endif | 2501 | #endif |
| 2513 | if (preempt_count() == val) | 2502 | if (preempt_count() == val) { |
| 2514 | trace_preempt_off(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1)); | 2503 | unsigned long ip = get_parent_ip(CALLER_ADDR1); |
| 2504 | #ifdef CONFIG_DEBUG_PREEMPT | ||
| 2505 | current->preempt_disable_ip = ip; | ||
| 2506 | #endif | ||
| 2507 | trace_preempt_off(CALLER_ADDR0, ip); | ||
| 2508 | } | ||
| 2515 | } | 2509 | } |
| 2516 | EXPORT_SYMBOL(preempt_count_add); | 2510 | EXPORT_SYMBOL(preempt_count_add); |
| 2517 | 2511 | ||
| @@ -2554,6 +2548,13 @@ static noinline void __schedule_bug(struct task_struct *prev) | |||
| 2554 | print_modules(); | 2548 | print_modules(); |
| 2555 | if (irqs_disabled()) | 2549 | if (irqs_disabled()) |
| 2556 | print_irqtrace_events(prev); | 2550 | print_irqtrace_events(prev); |
| 2551 | #ifdef CONFIG_DEBUG_PREEMPT | ||
| 2552 | if (in_atomic_preempt_off()) { | ||
| 2553 | pr_err("Preemption disabled at:"); | ||
| 2554 | print_ip_sym(current->preempt_disable_ip); | ||
| 2555 | pr_cont("\n"); | ||
| 2556 | } | ||
| 2557 | #endif | ||
| 2557 | dump_stack(); | 2558 | dump_stack(); |
| 2558 | add_taint(TAINT_WARN, LOCKDEP_STILL_OK); | 2559 | add_taint(TAINT_WARN, LOCKDEP_STILL_OK); |
| 2559 | } | 2560 | } |
| @@ -2577,36 +2578,34 @@ static inline void schedule_debug(struct task_struct *prev) | |||
| 2577 | schedstat_inc(this_rq(), sched_count); | 2578 | schedstat_inc(this_rq(), sched_count); |
| 2578 | } | 2579 | } |
| 2579 | 2580 | ||
| 2580 | static void put_prev_task(struct rq *rq, struct task_struct *prev) | ||
| 2581 | { | ||
| 2582 | if (prev->on_rq || rq->skip_clock_update < 0) | ||
| 2583 | update_rq_clock(rq); | ||
| 2584 | prev->sched_class->put_prev_task(rq, prev); | ||
| 2585 | } | ||
| 2586 | |||
| 2587 | /* | 2581 | /* |
| 2588 | * Pick up the highest-prio task: | 2582 | * Pick up the highest-prio task: |
| 2589 | */ | 2583 | */ |
| 2590 | static inline struct task_struct * | 2584 | static inline struct task_struct * |
| 2591 | pick_next_task(struct rq *rq) | 2585 | pick_next_task(struct rq *rq, struct task_struct *prev) |
| 2592 | { | 2586 | { |
| 2593 | const struct sched_class *class; | 2587 | const struct sched_class *class = &fair_sched_class; |
| 2594 | struct task_struct *p; | 2588 | struct task_struct *p; |
| 2595 | 2589 | ||
| 2596 | /* | 2590 | /* |
| 2597 | * Optimization: we know that if all tasks are in | 2591 | * Optimization: we know that if all tasks are in |
| 2598 | * the fair class we can call that function directly: | 2592 | * the fair class we can call that function directly: |
| 2599 | */ | 2593 | */ |
| 2600 | if (likely(rq->nr_running == rq->cfs.h_nr_running)) { | 2594 | if (likely(prev->sched_class == class && |
| 2601 | p = fair_sched_class.pick_next_task(rq); | 2595 | rq->nr_running == rq->cfs.h_nr_running)) { |
| 2602 | if (likely(p)) | 2596 | p = fair_sched_class.pick_next_task(rq, prev); |
| 2597 | if (likely(p && p != RETRY_TASK)) | ||
| 2603 | return p; | 2598 | return p; |
| 2604 | } | 2599 | } |
| 2605 | 2600 | ||
| 2601 | again: | ||
| 2606 | for_each_class(class) { | 2602 | for_each_class(class) { |
| 2607 | p = class->pick_next_task(rq); | 2603 | p = class->pick_next_task(rq, prev); |
| 2608 | if (p) | 2604 | if (p) { |
| 2605 | if (unlikely(p == RETRY_TASK)) | ||
| 2606 | goto again; | ||
| 2609 | return p; | 2607 | return p; |
| 2608 | } | ||
| 2610 | } | 2609 | } |
| 2611 | 2610 | ||
| 2612 | BUG(); /* the idle class will always have a runnable task */ | 2611 | BUG(); /* the idle class will always have a runnable task */ |
| @@ -2700,13 +2699,10 @@ need_resched: | |||
| 2700 | switch_count = &prev->nvcsw; | 2699 | switch_count = &prev->nvcsw; |
| 2701 | } | 2700 | } |
| 2702 | 2701 | ||
| 2703 | pre_schedule(rq, prev); | 2702 | if (prev->on_rq || rq->skip_clock_update < 0) |
| 2704 | 2703 | update_rq_clock(rq); | |
| 2705 | if (unlikely(!rq->nr_running)) | ||
| 2706 | idle_balance(cpu, rq); | ||
| 2707 | 2704 | ||
| 2708 | put_prev_task(rq, prev); | 2705 | next = pick_next_task(rq, prev); |
| 2709 | next = pick_next_task(rq); | ||
| 2710 | clear_tsk_need_resched(prev); | 2706 | clear_tsk_need_resched(prev); |
| 2711 | clear_preempt_need_resched(); | 2707 | clear_preempt_need_resched(); |
| 2712 | rq->skip_clock_update = 0; | 2708 | rq->skip_clock_update = 0; |
| @@ -2908,7 +2904,8 @@ EXPORT_SYMBOL(sleep_on_timeout); | |||
| 2908 | * This function changes the 'effective' priority of a task. It does | 2904 | * This function changes the 'effective' priority of a task. It does |
| 2909 | * not touch ->normal_prio like __setscheduler(). | 2905 | * not touch ->normal_prio like __setscheduler(). |
| 2910 | * | 2906 | * |
| 2911 | * Used by the rt_mutex code to implement priority inheritance logic. | 2907 | * Used by the rt_mutex code to implement priority inheritance |
| 2908 | * logic. Call site only calls if the priority of the task changed. | ||
| 2912 | */ | 2909 | */ |
| 2913 | void rt_mutex_setprio(struct task_struct *p, int prio) | 2910 | void rt_mutex_setprio(struct task_struct *p, int prio) |
| 2914 | { | 2911 | { |
| @@ -2998,7 +2995,7 @@ void set_user_nice(struct task_struct *p, long nice) | |||
| 2998 | unsigned long flags; | 2995 | unsigned long flags; |
| 2999 | struct rq *rq; | 2996 | struct rq *rq; |
| 3000 | 2997 | ||
| 3001 | if (TASK_NICE(p) == nice || nice < -20 || nice > 19) | 2998 | if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) |
| 3002 | return; | 2999 | return; |
| 3003 | /* | 3000 | /* |
| 3004 | * We have to be careful, if called from sys_setpriority(), | 3001 | * We have to be careful, if called from sys_setpriority(), |
| @@ -3076,11 +3073,11 @@ SYSCALL_DEFINE1(nice, int, increment) | |||
| 3076 | if (increment > 40) | 3073 | if (increment > 40) |
| 3077 | increment = 40; | 3074 | increment = 40; |
| 3078 | 3075 | ||
| 3079 | nice = TASK_NICE(current) + increment; | 3076 | nice = task_nice(current) + increment; |
| 3080 | if (nice < -20) | 3077 | if (nice < MIN_NICE) |
| 3081 | nice = -20; | 3078 | nice = MIN_NICE; |
