diff options
Diffstat (limited to 'kernel/sched.c')
| -rw-r--r-- | kernel/sched.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index deb5ac8c12f3..52bbf1c842a8 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -125,6 +125,9 @@ DEFINE_TRACE(sched_switch); | |||
| 125 | DEFINE_TRACE(sched_migrate_task); | 125 | DEFINE_TRACE(sched_migrate_task); |
| 126 | 126 | ||
| 127 | #ifdef CONFIG_SMP | 127 | #ifdef CONFIG_SMP |
| 128 | |||
| 129 | static void double_rq_lock(struct rq *rq1, struct rq *rq2); | ||
| 130 | |||
| 128 | /* | 131 | /* |
| 129 | * Divide a load by a sched group cpu_power : (load / sg->__cpu_power) | 132 | * Divide a load by a sched group cpu_power : (load / sg->__cpu_power) |
| 130 | * Since cpu_power is a 'constant', we can use a reciprocal divide. | 133 | * Since cpu_power is a 'constant', we can use a reciprocal divide. |
| @@ -1320,8 +1323,8 @@ static inline void update_load_sub(struct load_weight *lw, unsigned long dec) | |||
| 1320 | * slice expiry etc. | 1323 | * slice expiry etc. |
| 1321 | */ | 1324 | */ |
| 1322 | 1325 | ||
| 1323 | #define WEIGHT_IDLEPRIO 2 | 1326 | #define WEIGHT_IDLEPRIO 3 |
| 1324 | #define WMULT_IDLEPRIO (1 << 31) | 1327 | #define WMULT_IDLEPRIO 1431655765 |
| 1325 | 1328 | ||
| 1326 | /* | 1329 | /* |
| 1327 | * Nice levels are multiplicative, with a gentle 10% change for every | 1330 | * Nice levels are multiplicative, with a gentle 10% change for every |
| @@ -4437,7 +4440,7 @@ void __kprobes sub_preempt_count(int val) | |||
| 4437 | /* | 4440 | /* |
| 4438 | * Underflow? | 4441 | * Underflow? |
| 4439 | */ | 4442 | */ |
| 4440 | if (DEBUG_LOCKS_WARN_ON(val > preempt_count() - (!!kernel_locked()))) | 4443 | if (DEBUG_LOCKS_WARN_ON(val > preempt_count())) |
| 4441 | return; | 4444 | return; |
| 4442 | /* | 4445 | /* |
| 4443 | * Is the spinlock portion underflowing? | 4446 | * Is the spinlock portion underflowing? |
| @@ -5123,7 +5126,7 @@ int can_nice(const struct task_struct *p, const int nice) | |||
| 5123 | * sys_setpriority is a more generic, but much slower function that | 5126 | * sys_setpriority is a more generic, but much slower function that |
| 5124 | * does similar things. | 5127 | * does similar things. |
| 5125 | */ | 5128 | */ |
| 5126 | asmlinkage long sys_nice(int increment) | 5129 | SYSCALL_DEFINE1(nice, int, increment) |
| 5127 | { | 5130 | { |
| 5128 | long nice, retval; | 5131 | long nice, retval; |
| 5129 | 5132 | ||
| @@ -5430,8 +5433,8 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) | |||
| 5430 | * @policy: new policy. | 5433 | * @policy: new policy. |
| 5431 | * @param: structure containing the new RT priority. | 5434 | * @param: structure containing the new RT priority. |
| 5432 | */ | 5435 | */ |
| 5433 | asmlinkage long | 5436 | SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, |
| 5434 | sys_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) | 5437 | struct sched_param __user *, param) |
| 5435 | { | 5438 | { |
| 5436 | /* negative values for policy are not valid */ | 5439 | /* negative values for policy are not valid */ |
| 5437 | if (policy < 0) | 5440 | if (policy < 0) |
| @@ -5445,7 +5448,7 @@ sys_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param) | |||
| 5445 | * @pid: the pid in question. | 5448 | * @pid: the pid in question. |
| 5446 | * @param: structure containing the new RT priority. | 5449 | * @param: structure containing the new RT priority. |
| 5447 | */ | 5450 | */ |
| 5448 | asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param __user *param) | 5451 | SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) |
| 5449 | { | 5452 | { |
| 5450 | return do_sched_setscheduler(pid, -1, param); | 5453 | return do_sched_setscheduler(pid, -1, param); |
| 5451 | } | 5454 | } |
| @@ -5454,7 +5457,7 @@ asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param __user *param) | |||
| 5454 | * sys_sched_getscheduler - get the policy (scheduling class) of a thread | 5457 | * sys_sched_getscheduler - get the policy (scheduling class) of a thread |
| 5455 | * @pid: the pid in question. | 5458 | * @pid: the pid in question. |
| 5456 | */ | 5459 | */ |
| 5457 | asmlinkage long sys_sched_getscheduler(pid_t pid) | 5460 | SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid) |
| 5458 | { | 5461 | { |
| 5459 | struct task_struct *p; | 5462 | struct task_struct *p; |
| 5460 | int retval; | 5463 | int retval; |
| @@ -5479,7 +5482,7 @@ asmlinkage long sys_sched_getscheduler(pid_t pid) | |||
| 5479 | * @pid: the pid in question. | 5482 | * @pid: the pid in question. |
| 5480 | * @param: structure containing the RT priority. | 5483 | * @param: structure containing the RT priority. |
| 5481 | */ | 5484 | */ |
| 5482 | asmlinkage long sys_sched_getparam(pid_t pid, struct sched_param __user *param) | 5485 | SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param) |
| 5483 | { | 5486 | { |
| 5484 | struct sched_param lp; | 5487 | struct sched_param lp; |
| 5485 | struct task_struct *p; | 5488 | struct task_struct *p; |
| @@ -5597,8 +5600,8 @@ static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len, | |||
| 5597 | * @len: length in bytes of the bitmask pointed to by user_mask_ptr | 5600 | * @len: length in bytes of the bitmask pointed to by user_mask_ptr |
| 5598 | * @user_mask_ptr: user-space pointer to the new cpu mask | 5601 | * @user_mask_ptr: user-space pointer to the new cpu mask |
| 5599 | */ | 5602 | */ |
| 5600 | asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len, | 5603 | SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len, |
| 5601 | unsigned long __user *user_mask_ptr) | 5604 | unsigned long __user *, user_mask_ptr) |
| 5602 | { | 5605 | { |
| 5603 | cpumask_var_t new_mask; | 5606 | cpumask_var_t new_mask; |
| 5604 | int retval; | 5607 | int retval; |
| @@ -5645,8 +5648,8 @@ out_unlock: | |||
| 5645 | * @len: length in bytes of the bitmask pointed to by user_mask_ptr | 5648 | * @len: length in bytes of the bitmask pointed to by user_mask_ptr |
| 5646 | * @user_mask_ptr: user-space pointer to hold the current cpu mask | 5649 | * @user_mask_ptr: user-space pointer to hold the current cpu mask |
| 5647 | */ | 5650 | */ |
| 5648 | asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len, | 5651 | SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, |
| 5649 | unsigned long __user *user_mask_ptr) | 5652 | unsigned long __user *, user_mask_ptr) |
| 5650 | { | 5653 | { |
| 5651 | int ret; | 5654 | int ret; |
| 5652 | cpumask_var_t mask; | 5655 | cpumask_var_t mask; |
| @@ -5675,7 +5678,7 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len, | |||
| 5675 | * This function yields the current CPU to other tasks. If there are no | 5678 | * This function yields the current CPU to other tasks. If there are no |
| 5676 | * other threads running on this CPU then this function will return. | 5679 | * other threads running on this CPU then this function will return. |
| 5677 | */ | 5680 | */ |
| 5678 | asmlinkage long sys_sched_yield(void) | 5681 | SYSCALL_DEFINE0(sched_yield) |
| 5679 | { | 5682 | { |
| 5680 | struct rq *rq = this_rq_lock(); | 5683 | struct rq *rq = this_rq_lock(); |
| 5681 | 5684 | ||
| @@ -5816,7 +5819,7 @@ long __sched io_schedule_timeout(long timeout) | |||
| 5816 | * this syscall returns the maximum rt_priority that can be used | 5819 | * this syscall returns the maximum rt_priority that can be used |
| 5817 | * by a given scheduling class. | 5820 | * by a given scheduling class. |
| 5818 | */ | 5821 | */ |
| 5819 | asmlinkage long sys_sched_get_priority_max(int policy) | 5822 | SYSCALL_DEFINE1(sched_get_priority_max, int, policy) |
| 5820 | { | 5823 | { |
| 5821 | int ret = -EINVAL; | 5824 | int ret = -EINVAL; |
| 5822 | 5825 | ||
| @@ -5841,7 +5844,7 @@ asmlinkage long sys_sched_get_priority_max(int policy) | |||
| 5841 | * this syscall returns the minimum rt_priority that can be used | 5844 | * this syscall returns the minimum rt_priority that can be used |
| 5842 | * by a given scheduling class. | 5845 | * by a given scheduling class. |
| 5843 | */ | 5846 | */ |
| 5844 | asmlinkage long sys_sched_get_priority_min(int policy) | 5847 | SYSCALL_DEFINE1(sched_get_priority_min, int, policy) |
| 5845 | { | 5848 | { |
| 5846 | int ret = -EINVAL; | 5849 | int ret = -EINVAL; |
| 5847 | 5850 | ||
| @@ -5866,8 +5869,8 @@ asmlinkage long sys_sched_get_priority_min(int policy) | |||
| 5866 | * this syscall writes the default timeslice value of a given process | 5869 | * this syscall writes the default timeslice value of a given process |
| 5867 | * into the user-space timespec buffer. A value of '0' means infinity. | 5870 | * into the user-space timespec buffer. A value of '0' means infinity. |
| 5868 | */ | 5871 | */ |
| 5869 | asmlinkage | 5872 | SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, |
| 5870 | long sys_sched_rr_get_interval(pid_t pid, struct timespec __user *interval) | 5873 | struct timespec __user *, interval) |
| 5871 | { | 5874 | { |
| 5872 | struct task_struct *p; | 5875 | struct task_struct *p; |
| 5873 | unsigned int time_slice; | 5876 | unsigned int time_slice; |
| @@ -7282,10 +7285,10 @@ cpu_to_phys_group(int cpu, const struct cpumask *cpu_map, | |||
| 7282 | * groups, so roll our own. Now each node has its own list of groups which | 7285 | * groups, so roll our own. Now each node has its own list of groups which |
| 7283 | * gets dynamically allocated. | 7286 | * gets dynamically allocated. |
| 7284 | */ | 7287 | */ |
| 7285 | static DEFINE_PER_CPU(struct sched_domain, node_domains); | 7288 | static DEFINE_PER_CPU(struct static_sched_domain, node_domains); |
| 7286 | static struct sched_group ***sched_group_nodes_bycpu; | 7289 | static struct sched_group ***sched_group_nodes_bycpu; |
| 7287 | 7290 | ||
| 7288 | static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); | 7291 | static DEFINE_PER_CPU(struct static_sched_domain, allnodes_domains); |
| 7289 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_allnodes); | 7292 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_allnodes); |
| 7290 | 7293 | ||
| 7291 | static int cpu_to_allnodes_group(int cpu, const struct cpumask *cpu_map, | 7294 | static int cpu_to_allnodes_group(int cpu, const struct cpumask *cpu_map, |
| @@ -7560,7 +7563,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map, | |||
| 7560 | #ifdef CONFIG_NUMA | 7563 | #ifdef CONFIG_NUMA |
| 7561 | if (cpumask_weight(cpu_map) > | 7564 | if (cpumask_weight(cpu_map) > |
| 7562 | SD_NODES_PER_DOMAIN*cpumask_weight(nodemask)) { | 7565 | SD_NODES_PER_DOMAIN*cpumask_weight(nodemask)) { |
| 7563 | sd = &per_cpu(allnodes_domains, i); | 7566 | sd = &per_cpu(allnodes_domains, i).sd; |
| 7564 | SD_INIT(sd, ALLNODES); | 7567 | SD_INIT(sd, ALLNODES); |
| 7565 | set_domain_attribute(sd, attr); | 7568 | set_domain_attribute(sd, attr); |
| 7566 | cpumask_copy(sched_domain_span(sd), cpu_map); | 7569 | cpumask_copy(sched_domain_span(sd), cpu_map); |
| @@ -7570,7 +7573,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map, | |||
| 7570 | } else | 7573 | } else |
| 7571 | p = NULL; | 7574 | p = NULL; |
| 7572 | 7575 | ||
| 7573 | sd = &per_cpu(node_domains, i); | 7576 | sd = &per_cpu(node_domains, i).sd; |
| 7574 | SD_INIT(sd, NODE); | 7577 | SD_INIT(sd, NODE); |
| 7575 | set_domain_attribute(sd, attr); | 7578 | set_domain_attribute(sd, attr); |
| 7576 | sched_domain_node_span(cpu_to_node(i), sched_domain_span(sd)); | 7579 | sched_domain_node_span(cpu_to_node(i), sched_domain_span(sd)); |
| @@ -7688,7 +7691,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map, | |||
| 7688 | for_each_cpu(j, nodemask) { | 7691 | for_each_cpu(j, nodemask) { |
| 7689 | struct sched_domain *sd; | 7692 | struct sched_domain *sd; |
| 7690 | 7693 | ||
| 7691 | sd = &per_cpu(node_domains, j); | 7694 | sd = &per_cpu(node_domains, j).sd; |
| 7692 | sd->groups = sg; | 7695 | sd->groups = sg; |
| 7693 | } | 7696 | } |
| 7694 | sg->__cpu_power = 0; | 7697 | sg->__cpu_power = 0; |
| @@ -9047,6 +9050,13 @@ static int tg_schedulable(struct task_group *tg, void *data) | |||
| 9047 | runtime = d->rt_runtime; | 9050 | runtime = d->rt_runtime; |
| 9048 | } | 9051 | } |
| 9049 | 9052 | ||
| 9053 | #ifdef CONFIG_USER_SCHED | ||
| 9054 | if (tg == &root_task_group) { | ||
| 9055 | period = global_rt_period(); | ||
| 9056 | runtime = global_rt_runtime(); | ||
| 9057 | } | ||
| 9058 | #endif | ||
| 9059 | |||
| 9050 | /* | 9060 | /* |
| 9051 | * Cannot have more runtime than the period. | 9061 | * Cannot have more runtime than the period. |
| 9052 | */ | 9062 | */ |
