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 git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched

* git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched:
sched: fix invalid sched_class use
sched: add /proc/sys/kernel/sched_compat_yield

+72 -10
+1
include/linux/sched.h
··· 1406 1406 extern unsigned int sysctl_sched_batch_wakeup_granularity; 1407 1407 extern unsigned int sysctl_sched_stat_granularity; 1408 1408 extern unsigned int sysctl_sched_runtime_limit; 1409 + extern unsigned int sysctl_sched_compat_yield; 1409 1410 extern unsigned int sysctl_sched_child_runs_first; 1410 1411 extern unsigned int sysctl_sched_features; 1411 1412
+6 -4
kernel/sched.c
··· 1682 1682 1683 1683 p->prio = effective_prio(p); 1684 1684 1685 + if (rt_prio(p->prio)) 1686 + p->sched_class = &rt_sched_class; 1687 + else 1688 + p->sched_class = &fair_sched_class; 1689 + 1685 1690 if (!p->sched_class->task_new || !sysctl_sched_child_runs_first || 1686 1691 (clone_flags & CLONE_VM) || task_cpu(p) != this_cpu || 1687 1692 !current->se.on_rq) { ··· 4555 4550 struct rq *rq = this_rq_lock(); 4556 4551 4557 4552 schedstat_inc(rq, yld_cnt); 4558 - if (unlikely(rq->nr_running == 1)) 4559 - schedstat_inc(rq, yld_act_empty); 4560 - else 4561 - current->sched_class->yield_task(rq, current); 4553 + current->sched_class->yield_task(rq, current); 4562 4554 4563 4555 /* 4564 4556 * Since we are going to call schedule() anyway, there's
+57 -6
kernel/sched_fair.c
··· 43 43 unsigned int sysctl_sched_min_granularity __read_mostly = 2000000ULL; 44 44 45 45 /* 46 + * sys_sched_yield() compat mode 47 + * 48 + * This option switches the agressive yield implementation of the 49 + * old scheduler back on. 50 + */ 51 + unsigned int __read_mostly sysctl_sched_compat_yield; 52 + 53 + /* 46 54 * SCHED_BATCH wake-up granularity. 47 55 * (default: 25 msec, units: nanoseconds) 48 56 * ··· 905 897 } 906 898 907 899 /* 908 - * sched_yield() support is very simple - we dequeue and enqueue 900 + * sched_yield() support is very simple - we dequeue and enqueue. 901 + * 902 + * If compat_yield is turned on then we requeue to the end of the tree. 909 903 */ 910 904 static void yield_task_fair(struct rq *rq, struct task_struct *p) 911 905 { 912 906 struct cfs_rq *cfs_rq = task_cfs_rq(p); 907 + struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; 908 + struct sched_entity *rightmost, *se = &p->se; 909 + struct rb_node *parent; 913 910 914 - __update_rq_clock(rq); 915 911 /* 916 - * Dequeue and enqueue the task to update its 917 - * position within the tree: 912 + * Are we the only task in the tree? 918 913 */ 919 - dequeue_entity(cfs_rq, &p->se, 0); 920 - enqueue_entity(cfs_rq, &p->se, 0); 914 + if (unlikely(cfs_rq->nr_running == 1)) 915 + return; 916 + 917 + if (likely(!sysctl_sched_compat_yield)) { 918 + __update_rq_clock(rq); 919 + /* 920 + * Dequeue and enqueue the task to update its 921 + * position within the tree: 922 + */ 923 + dequeue_entity(cfs_rq, &p->se, 0); 924 + enqueue_entity(cfs_rq, &p->se, 0); 925 + 926 + return; 927 + } 928 + /* 929 + * Find the rightmost entry in the rbtree: 930 + */ 931 + do { 932 + parent = *link; 933 + link = &parent->rb_right; 934 + } while (*link); 935 + 936 + rightmost = rb_entry(parent, struct sched_entity, run_node); 937 + /* 938 + * Already in the rightmost position? 939 + */ 940 + if (unlikely(rightmost == se)) 941 + return; 942 + 943 + /* 944 + * Minimally necessary key value to be last in the tree: 945 + */ 946 + se->fair_key = rightmost->fair_key + 1; 947 + 948 + if (cfs_rq->rb_leftmost == &se->run_node) 949 + cfs_rq->rb_leftmost = rb_next(&se->run_node); 950 + /* 951 + * Relink the task to the rightmost position: 952 + */ 953 + rb_erase(&se->run_node, &cfs_rq->tasks_timeline); 954 + rb_link_node(&se->run_node, parent, link); 955 + rb_insert_color(&se->run_node, &cfs_rq->tasks_timeline); 921 956 } 922 957 923 958 /*
+8
kernel/sysctl.c
··· 303 303 .proc_handler = &proc_dointvec, 304 304 }, 305 305 #endif 306 + { 307 + .ctl_name = CTL_UNNUMBERED, 308 + .procname = "sched_compat_yield", 309 + .data = &sysctl_sched_compat_yield, 310 + .maxlen = sizeof(unsigned int), 311 + .mode = 0644, 312 + .proc_handler = &proc_dointvec, 313 + }, 306 314 #ifdef CONFIG_PROVE_LOCKING 307 315 { 308 316 .ctl_name = CTL_UNNUMBERED,