Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
sched: Simplify sys_sched_rr_get_interval() system call
sched: Fix potential NULL derference of doms_cur
sched: Fix raciness in runqueue_is_locked()
sched: Re-add lost cpu_allowed check to sched_fair.c::select_task_rq_fair()
sched: Remove unneeded indentation in sched_fair.c::place_entity()

+76 -50
+3 -1
include/linux/sched.h
··· 257 257 extern void init_idle(struct task_struct *idle, int cpu); 258 258 extern void init_idle_bootup_task(struct task_struct *idle); 259 259 260 - extern int runqueue_is_locked(void); 260 + extern int runqueue_is_locked(int cpu); 261 261 extern void task_rq_unlock_wait(struct task_struct *p); 262 262 263 263 extern cpumask_var_t nohz_cpu_mask; ··· 1074 1074 int running); 1075 1075 void (*prio_changed) (struct rq *this_rq, struct task_struct *task, 1076 1076 int oldprio, int running); 1077 + 1078 + unsigned int (*get_rr_interval) (struct task_struct *task); 1077 1079 1078 1080 #ifdef CONFIG_FAIR_GROUP_SCHED 1079 1081 void (*moved_group) (struct task_struct *p);
+4 -25
kernel/sched.c
··· 681 681 * This interface allows printk to be called with the runqueue lock 682 682 * held and know whether or not it is OK to wake up the klogd. 683 683 */ 684 - int runqueue_is_locked(void) 684 + int runqueue_is_locked(int cpu) 685 685 { 686 - int cpu = get_cpu(); 687 - struct rq *rq = cpu_rq(cpu); 688 - int ret; 689 - 690 - ret = spin_is_locked(&rq->lock); 691 - put_cpu(); 692 - return ret; 686 + return spin_is_locked(&cpu_rq(cpu)->lock); 693 687 } 694 688 695 689 /* ··· 6819 6825 if (retval) 6820 6826 goto out_unlock; 6821 6827 6822 - /* 6823 - * Time slice is 0 for SCHED_FIFO tasks and for SCHED_OTHER 6824 - * tasks that are on an otherwise idle runqueue: 6825 - */ 6826 - time_slice = 0; 6827 - if (p->policy == SCHED_RR) { 6828 - time_slice = DEF_TIMESLICE; 6829 - } else if (p->policy != SCHED_FIFO) { 6830 - struct sched_entity *se = &p->se; 6831 - unsigned long flags; 6832 - struct rq *rq; 6828 + time_slice = p->sched_class->get_rr_interval(p); 6833 6829 6834 - rq = task_rq_lock(p, &flags); 6835 - if (rq->cfs.load.weight) 6836 - time_slice = NS_TO_JIFFIES(sched_slice(&rq->cfs, se)); 6837 - task_rq_unlock(rq, &flags); 6838 - } 6839 6830 read_unlock(&tasklist_lock); 6840 6831 jiffies_to_timespec(time_slice, &t); 6841 6832 retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0; ··· 9150 9171 cpumask_var_t non_isolated_cpus; 9151 9172 9152 9173 alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL); 9174 + alloc_cpumask_var(&fallback_doms, GFP_KERNEL); 9153 9175 9154 9176 #if defined(CONFIG_NUMA) 9155 9177 sched_group_nodes_bycpu = kzalloc(nr_cpu_ids * sizeof(void **), ··· 9182 9202 sched_init_granularity(); 9183 9203 free_cpumask_var(non_isolated_cpus); 9184 9204 9185 - alloc_cpumask_var(&fallback_doms, GFP_KERNEL); 9186 9205 init_sched_rt_class(); 9187 9206 } 9188 9207 #else
+42 -23
kernel/sched_fair.c
··· 710 710 if (initial && sched_feat(START_DEBIT)) 711 711 vruntime += sched_vslice(cfs_rq, se); 712 712 713 - if (!initial) { 714 - /* sleeps upto a single latency don't count. */ 715 - if (sched_feat(FAIR_SLEEPERS)) { 716 - unsigned long thresh = sysctl_sched_latency; 713 + /* sleeps up to a single latency don't count. */ 714 + if (!initial && sched_feat(FAIR_SLEEPERS)) { 715 + unsigned long thresh = sysctl_sched_latency; 717 716 718 - /* 719 - * Convert the sleeper threshold into virtual time. 720 - * SCHED_IDLE is a special sub-class. We care about 721 - * fairness only relative to other SCHED_IDLE tasks, 722 - * all of which have the same weight. 723 - */ 724 - if (sched_feat(NORMALIZED_SLEEPER) && 725 - (!entity_is_task(se) || 726 - task_of(se)->policy != SCHED_IDLE)) 727 - thresh = calc_delta_fair(thresh, se); 717 + /* 718 + * Convert the sleeper threshold into virtual time. 719 + * SCHED_IDLE is a special sub-class. We care about 720 + * fairness only relative to other SCHED_IDLE tasks, 721 + * all of which have the same weight. 722 + */ 723 + if (sched_feat(NORMALIZED_SLEEPER) && (!entity_is_task(se) || 724 + task_of(se)->policy != SCHED_IDLE)) 725 + thresh = calc_delta_fair(thresh, se); 728 726 729 - /* 730 - * Halve their sleep time's effect, to allow 731 - * for a gentler effect of sleepers: 732 - */ 733 - if (sched_feat(GENTLE_FAIR_SLEEPERS)) 734 - thresh >>= 1; 727 + /* 728 + * Halve their sleep time's effect, to allow 729 + * for a gentler effect of sleepers: 730 + */ 731 + if (sched_feat(GENTLE_FAIR_SLEEPERS)) 732 + thresh >>= 1; 735 733 736 - vruntime -= thresh; 737 - } 734 + vruntime -= thresh; 738 735 } 739 736 740 737 /* ensure we never gain time by being placed backwards. */ ··· 1340 1343 int sync = wake_flags & WF_SYNC; 1341 1344 1342 1345 if (sd_flag & SD_BALANCE_WAKE) { 1343 - if (sched_feat(AFFINE_WAKEUPS)) 1346 + if (sched_feat(AFFINE_WAKEUPS) && 1347 + cpumask_test_cpu(cpu, &p->cpus_allowed)) 1344 1348 want_affine = 1; 1345 1349 new_cpu = prev_cpu; 1346 1350 } ··· 1939 1941 } 1940 1942 #endif 1941 1943 1944 + unsigned int get_rr_interval_fair(struct task_struct *task) 1945 + { 1946 + struct sched_entity *se = &task->se; 1947 + unsigned long flags; 1948 + struct rq *rq; 1949 + unsigned int rr_interval = 0; 1950 + 1951 + /* 1952 + * Time slice is 0 for SCHED_OTHER tasks that are on an otherwise 1953 + * idle runqueue: 1954 + */ 1955 + rq = task_rq_lock(task, &flags); 1956 + if (rq->cfs.load.weight) 1957 + rr_interval = NS_TO_JIFFIES(sched_slice(&rq->cfs, se)); 1958 + task_rq_unlock(rq, &flags); 1959 + 1960 + return rr_interval; 1961 + } 1962 + 1942 1963 /* 1943 1964 * All the scheduling class methods: 1944 1965 */ ··· 1985 1968 1986 1969 .prio_changed = prio_changed_fair, 1987 1970 .switched_to = switched_to_fair, 1971 + 1972 + .get_rr_interval = get_rr_interval_fair, 1988 1973 1989 1974 #ifdef CONFIG_FAIR_GROUP_SCHED 1990 1975 .moved_group = moved_group_fair,
+7
kernel/sched_idletask.c
··· 97 97 check_preempt_curr(rq, p, 0); 98 98 } 99 99 100 + unsigned int get_rr_interval_idle(struct task_struct *task) 101 + { 102 + return 0; 103 + } 104 + 100 105 /* 101 106 * Simple, special scheduling class for the per-CPU idle tasks: 102 107 */ ··· 126 121 127 122 .set_curr_task = set_curr_task_idle, 128 123 .task_tick = task_tick_idle, 124 + 125 + .get_rr_interval = get_rr_interval_idle, 129 126 130 127 .prio_changed = prio_changed_idle, 131 128 .switched_to = switched_to_idle,
+13
kernel/sched_rt.c
··· 1734 1734 dequeue_pushable_task(rq, p); 1735 1735 } 1736 1736 1737 + unsigned int get_rr_interval_rt(struct task_struct *task) 1738 + { 1739 + /* 1740 + * Time slice is 0 for SCHED_FIFO tasks 1741 + */ 1742 + if (task->policy == SCHED_RR) 1743 + return DEF_TIMESLICE; 1744 + else 1745 + return 0; 1746 + } 1747 + 1737 1748 static const struct sched_class rt_sched_class = { 1738 1749 .next = &fair_sched_class, 1739 1750 .enqueue_task = enqueue_task_rt, ··· 1772 1761 1773 1762 .set_curr_task = set_curr_task_rt, 1774 1763 .task_tick = task_tick_rt, 1764 + 1765 + .get_rr_interval = get_rr_interval_rt, 1775 1766 1776 1767 .prio_changed = prio_changed_rt, 1777 1768 .switched_to = switched_to_rt,
+7 -1
kernel/trace/trace.c
··· 268 268 */ 269 269 void trace_wake_up(void) 270 270 { 271 + int cpu; 272 + 273 + if (trace_flags & TRACE_ITER_BLOCK) 274 + return; 271 275 /* 272 276 * The runqueue_is_locked() can fail, but this is the best we 273 277 * have for now: 274 278 */ 275 - if (!(trace_flags & TRACE_ITER_BLOCK) && !runqueue_is_locked()) 279 + cpu = get_cpu(); 280 + if (!runqueue_is_locked(cpu)) 276 281 wake_up(&trace_wait); 282 + put_cpu(); 277 283 } 278 284 279 285 static int __init set_buf_size(char *str)