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

sched/fair: Reorder throttle_cfs_rq() path

As commit:

39f23ce07b93 ("sched/fair: Fix unthrottle_cfs_rq() for leaf_cfs_rq list")

does in unthrottle_cfs_rq(), throttle_cfs_rq() can also use the same
pattern as dequeue_task_fair().

No functional changes.

Signed-off-by: Peng Wang <rocking@linux.alibaba.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Phil Auld <pauld@redhat.com>
Cc: Ben Segall <bsegall@google.com>
Link: https://lore.kernel.org/r/f11dd2e3ab35cc538e2eb57bf0c99b6eaffce127.1604973978.git.rocking@linux.alibaba.com

authored by

Peng Wang and committed by
Ingo Molnar
b6d37a76 d8fcb81f

+23 -11
+23 -11
kernel/sched/fair.c
··· 4788 4788 struct cfs_rq *qcfs_rq = cfs_rq_of(se); 4789 4789 /* throttled entity or throttle-on-deactivate */ 4790 4790 if (!se->on_rq) 4791 - break; 4791 + goto done; 4792 4792 4793 - if (dequeue) { 4794 - dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); 4795 - } else { 4796 - update_load_avg(qcfs_rq, se, 0); 4797 - se_update_runnable(se); 4798 - } 4793 + dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); 4799 4794 4800 4795 qcfs_rq->h_nr_running -= task_delta; 4801 4796 qcfs_rq->idle_h_nr_running -= idle_task_delta; 4802 4797 4803 - if (qcfs_rq->load.weight) 4804 - dequeue = 0; 4798 + if (qcfs_rq->load.weight) { 4799 + /* Avoid re-evaluating load for this entity: */ 4800 + se = parent_entity(se); 4801 + break; 4802 + } 4805 4803 } 4806 4804 4807 - if (!se) 4808 - sub_nr_running(rq, task_delta); 4805 + for_each_sched_entity(se) { 4806 + struct cfs_rq *qcfs_rq = cfs_rq_of(se); 4807 + /* throttled entity or throttle-on-deactivate */ 4808 + if (!se->on_rq) 4809 + goto done; 4809 4810 4811 + update_load_avg(qcfs_rq, se, 0); 4812 + se_update_runnable(se); 4813 + 4814 + qcfs_rq->h_nr_running -= task_delta; 4815 + qcfs_rq->idle_h_nr_running -= idle_task_delta; 4816 + } 4817 + 4818 + /* At this point se is NULL and we are at root level*/ 4819 + sub_nr_running(rq, task_delta); 4820 + 4821 + done: 4810 4822 /* 4811 4823 * Note: distribution will already see us throttled via the 4812 4824 * throttled-list. rq->lock protects completion.