Commit 4cbb62148cd686c2d3618861deb15eeb83744405
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Merge branch 'tip/sched/core' of git://git.kernel.org/pub/scm/linux/kernel/git/r…
…ostedt/linux-trace into sched/core Pull a scheduler optimization commit from Steven Rostedt. Signed-off-by: Ingo Molnar <mingo@kernel.org>
Showing 1 changed file Side-by-side Diff
kernel/sched/rt.c
... | ... | @@ -1803,44 +1803,40 @@ |
1803 | 1803 | static void set_cpus_allowed_rt(struct task_struct *p, |
1804 | 1804 | const struct cpumask *new_mask) |
1805 | 1805 | { |
1806 | - int weight = cpumask_weight(new_mask); | |
1806 | + struct rq *rq; | |
1807 | + int weight; | |
1807 | 1808 | |
1808 | 1809 | BUG_ON(!rt_task(p)); |
1809 | 1810 | |
1811 | + if (!p->on_rq) | |
1812 | + return; | |
1813 | + | |
1814 | + weight = cpumask_weight(new_mask); | |
1815 | + | |
1810 | 1816 | /* |
1811 | - * Update the migration status of the RQ if we have an RT task | |
1812 | - * which is running AND changing its weight value. | |
1817 | + * Only update if the process changes its state from whether it | |
1818 | + * can migrate or not. | |
1813 | 1819 | */ |
1814 | - if (p->on_rq && (weight != p->rt.nr_cpus_allowed)) { | |
1815 | - struct rq *rq = task_rq(p); | |
1820 | + if ((p->rt.nr_cpus_allowed > 1) == (weight > 1)) | |
1821 | + return; | |
1816 | 1822 | |
1817 | - if (!task_current(rq, p)) { | |
1818 | - /* | |
1819 | - * Make sure we dequeue this task from the pushable list | |
1820 | - * before going further. It will either remain off of | |
1821 | - * the list because we are no longer pushable, or it | |
1822 | - * will be requeued. | |
1823 | - */ | |
1824 | - if (p->rt.nr_cpus_allowed > 1) | |
1825 | - dequeue_pushable_task(rq, p); | |
1823 | + rq = task_rq(p); | |
1826 | 1824 | |
1827 | - /* | |
1828 | - * Requeue if our weight is changing and still > 1 | |
1829 | - */ | |
1830 | - if (weight > 1) | |
1831 | - enqueue_pushable_task(rq, p); | |
1832 | - | |
1833 | - } | |
1834 | - | |
1835 | - if ((p->rt.nr_cpus_allowed <= 1) && (weight > 1)) { | |
1836 | - rq->rt.rt_nr_migratory++; | |
1837 | - } else if ((p->rt.nr_cpus_allowed > 1) && (weight <= 1)) { | |
1838 | - BUG_ON(!rq->rt.rt_nr_migratory); | |
1839 | - rq->rt.rt_nr_migratory--; | |
1840 | - } | |
1841 | - | |
1842 | - update_rt_migration(&rq->rt); | |
1825 | + /* | |
1826 | + * The process used to be able to migrate OR it can now migrate | |
1827 | + */ | |
1828 | + if (weight <= 1) { | |
1829 | + if (!task_current(rq, p)) | |
1830 | + dequeue_pushable_task(rq, p); | |
1831 | + BUG_ON(!rq->rt.rt_nr_migratory); | |
1832 | + rq->rt.rt_nr_migratory--; | |
1833 | + } else { | |
1834 | + if (!task_current(rq, p)) | |
1835 | + enqueue_pushable_task(rq, p); | |
1836 | + rq->rt.rt_nr_migratory++; | |
1843 | 1837 | } |
1838 | + | |
1839 | + update_rt_migration(&rq->rt); | |
1844 | 1840 | } |
1845 | 1841 | |
1846 | 1842 | /* Assumes rq->lock is held */ |