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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull scheduler fixes from Thomas Gleixner:

- two patches addressing the problem that the scheduler allows under
certain conditions user space tasks to be scheduled on CPUs which are
not yet fully booted which causes a few subtle and hard to debug
issue

- add a missing runqueue clock update in the deadline scheduler which
triggers a warning under certain circumstances

- fix a silly typo in the scheduler header file

* 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
sched/headers: Fix typo
sched/deadline: Fix missing clock update
sched/core: Require cpu_active() in select_task_rq(), for user tasks
sched/core: Fix rules for running on online && !active CPUs

+35 -18
+31 -14
kernel/sched/core.c
··· 881 881 } 882 882 883 883 #ifdef CONFIG_SMP 884 + 885 + static inline bool is_per_cpu_kthread(struct task_struct *p) 886 + { 887 + if (!(p->flags & PF_KTHREAD)) 888 + return false; 889 + 890 + if (p->nr_cpus_allowed != 1) 891 + return false; 892 + 893 + return true; 894 + } 895 + 896 + /* 897 + * Per-CPU kthreads are allowed to run on !actie && online CPUs, see 898 + * __set_cpus_allowed_ptr() and select_fallback_rq(). 899 + */ 900 + static inline bool is_cpu_allowed(struct task_struct *p, int cpu) 901 + { 902 + if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) 903 + return false; 904 + 905 + if (is_per_cpu_kthread(p)) 906 + return cpu_online(cpu); 907 + 908 + return cpu_active(cpu); 909 + } 910 + 884 911 /* 885 912 * This is how migration works: 886 913 * ··· 965 938 static struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf, 966 939 struct task_struct *p, int dest_cpu) 967 940 { 968 - if (p->flags & PF_KTHREAD) { 969 - if (unlikely(!cpu_online(dest_cpu))) 970 - return rq; 971 - } else { 972 - if (unlikely(!cpu_active(dest_cpu))) 973 - return rq; 974 - } 975 - 976 941 /* Affinity changed (again). */ 977 - if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) 942 + if (!is_cpu_allowed(p, dest_cpu)) 978 943 return rq; 979 944 980 945 update_rq_clock(rq); ··· 1495 1476 for (;;) { 1496 1477 /* Any allowed, online CPU? */ 1497 1478 for_each_cpu(dest_cpu, &p->cpus_allowed) { 1498 - if (!(p->flags & PF_KTHREAD) && !cpu_active(dest_cpu)) 1479 + if (!is_cpu_allowed(p, dest_cpu)) 1499 1480 continue; 1500 - if (!cpu_online(dest_cpu)) 1501 - continue; 1481 + 1502 1482 goto out; 1503 1483 } 1504 1484 ··· 1560 1542 * [ this allows ->select_task() to simply return task_cpu(p) and 1561 1543 * not worry about this generic constraint ] 1562 1544 */ 1563 - if (unlikely(!cpumask_test_cpu(cpu, &p->cpus_allowed) || 1564 - !cpu_online(cpu))) 1545 + if (unlikely(!is_cpu_allowed(p, cpu))) 1565 1546 cpu = select_fallback_rq(task_cpu(p), p); 1566 1547 1567 1548 return cpu;
+3 -3
kernel/sched/deadline.c
··· 1259 1259 1260 1260 rq = task_rq_lock(p, &rf); 1261 1261 1262 + sched_clock_tick(); 1263 + update_rq_clock(rq); 1264 + 1262 1265 if (!dl_task(p) || p->state == TASK_DEAD) { 1263 1266 struct dl_bw *dl_b = dl_bw_of(task_cpu(p)); 1264 1267 ··· 1280 1277 } 1281 1278 if (dl_se->dl_non_contending == 0) 1282 1279 goto unlock; 1283 - 1284 - sched_clock_tick(); 1285 - update_rq_clock(rq); 1286 1280 1287 1281 sub_running_bw(dl_se, &rq->dl); 1288 1282 dl_se->dl_non_contending = 0;
+1 -1
kernel/sched/sched.h
··· 983 983 } 984 984 985 985 /* 986 - * See rt task throttoling, which is the only time a skip 986 + * See rt task throttling, which is the only time a skip 987 987 * request is cancelled. 988 988 */ 989 989 static inline void rq_clock_cancel_skipupdate(struct rq *rq)