diff options
Diffstat (limited to 'kernel/sched.c')
| -rw-r--r-- | kernel/sched.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index a455dca884a6..3c11ae0a948d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -309,6 +309,8 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq); | |||
| 309 | */ | 309 | */ |
| 310 | static DEFINE_SPINLOCK(task_group_lock); | 310 | static DEFINE_SPINLOCK(task_group_lock); |
| 311 | 311 | ||
| 312 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
| 313 | |||
| 312 | #ifdef CONFIG_SMP | 314 | #ifdef CONFIG_SMP |
| 313 | static int root_task_group_empty(void) | 315 | static int root_task_group_empty(void) |
| 314 | { | 316 | { |
| @@ -316,7 +318,6 @@ static int root_task_group_empty(void) | |||
| 316 | } | 318 | } |
| 317 | #endif | 319 | #endif |
| 318 | 320 | ||
| 319 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
| 320 | #ifdef CONFIG_USER_SCHED | 321 | #ifdef CONFIG_USER_SCHED |
| 321 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) | 322 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) |
| 322 | #else /* !CONFIG_USER_SCHED */ | 323 | #else /* !CONFIG_USER_SCHED */ |
| @@ -1992,6 +1993,38 @@ static inline void check_class_changed(struct rq *rq, struct task_struct *p, | |||
| 1992 | p->sched_class->prio_changed(rq, p, oldprio, running); | 1993 | p->sched_class->prio_changed(rq, p, oldprio, running); |
| 1993 | } | 1994 | } |
| 1994 | 1995 | ||
| 1996 | /** | ||
| 1997 | * kthread_bind - bind a just-created kthread to a cpu. | ||
| 1998 | * @p: thread created by kthread_create(). | ||
| 1999 | * @cpu: cpu (might not be online, must be possible) for @k to run on. | ||
| 2000 | * | ||
| 2001 | * Description: This function is equivalent to set_cpus_allowed(), | ||
| 2002 | * except that @cpu doesn't need to be online, and the thread must be | ||
| 2003 | * stopped (i.e., just returned from kthread_create()). | ||
| 2004 | * | ||
| 2005 | * Function lives here instead of kthread.c because it messes with | ||
| 2006 | * scheduler internals which require locking. | ||
| 2007 | */ | ||
| 2008 | void kthread_bind(struct task_struct *p, unsigned int cpu) | ||
| 2009 | { | ||
| 2010 | struct rq *rq = cpu_rq(cpu); | ||
| 2011 | unsigned long flags; | ||
| 2012 | |||
| 2013 | /* Must have done schedule() in kthread() before we set_task_cpu */ | ||
| 2014 | if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE)) { | ||
| 2015 | WARN_ON(1); | ||
| 2016 | return; | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | spin_lock_irqsave(&rq->lock, flags); | ||
| 2020 | set_task_cpu(p, cpu); | ||
| 2021 | p->cpus_allowed = cpumask_of_cpu(cpu); | ||
| 2022 | p->rt.nr_cpus_allowed = 1; | ||
| 2023 | p->flags |= PF_THREAD_BOUND; | ||
| 2024 | spin_unlock_irqrestore(&rq->lock, flags); | ||
| 2025 | } | ||
| 2026 | EXPORT_SYMBOL(kthread_bind); | ||
| 2027 | |||
| 1995 | #ifdef CONFIG_SMP | 2028 | #ifdef CONFIG_SMP |
| 1996 | /* | 2029 | /* |
| 1997 | * Is this task likely cache-hot: | 2030 | * Is this task likely cache-hot: |
| @@ -2004,7 +2037,7 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd) | |||
| 2004 | /* | 2037 | /* |
| 2005 | * Buddy candidates are cache hot: | 2038 | * Buddy candidates are cache hot: |
| 2006 | */ | 2039 | */ |
| 2007 | if (sched_feat(CACHE_HOT_BUDDY) && | 2040 | if (sched_feat(CACHE_HOT_BUDDY) && this_rq()->nr_running && |
| 2008 | (&p->se == cfs_rq_of(&p->se)->next || | 2041 | (&p->se == cfs_rq_of(&p->se)->next || |
| 2009 | &p->se == cfs_rq_of(&p->se)->last)) | 2042 | &p->se == cfs_rq_of(&p->se)->last)) |
| 2010 | return 1; | 2043 | return 1; |
| @@ -9532,13 +9565,13 @@ void __init sched_init(void) | |||
| 9532 | current->sched_class = &fair_sched_class; | 9565 | current->sched_class = &fair_sched_class; |
| 9533 | 9566 | ||
| 9534 | /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ | 9567 | /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ |
| 9535 | alloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); | 9568 | zalloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); |
| 9536 | #ifdef CONFIG_SMP | 9569 | #ifdef CONFIG_SMP |
| 9537 | #ifdef CONFIG_NO_HZ | 9570 | #ifdef CONFIG_NO_HZ |
| 9538 | alloc_cpumask_var(&nohz.cpu_mask, GFP_NOWAIT); | 9571 | zalloc_cpumask_var(&nohz.cpu_mask, GFP_NOWAIT); |
| 9539 | alloc_cpumask_var(&nohz.ilb_grp_nohz_mask, GFP_NOWAIT); | 9572 | alloc_cpumask_var(&nohz.ilb_grp_nohz_mask, GFP_NOWAIT); |
| 9540 | #endif | 9573 | #endif |
| 9541 | alloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); | 9574 | zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); |
| 9542 | #endif /* SMP */ | 9575 | #endif /* SMP */ |
| 9543 | 9576 | ||
| 9544 | perf_event_init(); | 9577 | perf_event_init(); |
