From: Song Liu <songliubraving@fb.com>
To: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Cc: mingo@redhat.com, peterz@infradead.org,
vincent.guittot@linaro.org, tglx@linutronix.de,
morten.rasmussen@arm.com, kernel-team@fb.com,
Song Liu <songliubraving@fb.com>
Subject: [PATCH 1/7] sched: refactor tg_set_cfs_bandwidth()
Date: Mon, 8 Apr 2019 14:45:33 -0700 [thread overview]
Message-ID: <20190408214539.2705660-2-songliubraving@fb.com> (raw)
In-Reply-To: <20190408214539.2705660-1-songliubraving@fb.com>
This patch factors tg_switch_cfs_runtime() out of tg_set_cfs_bandwidth(),
so that next patches can extend tg_switch_cfs_runtime() to support the new
target_idle_pct value.
This patch doesn't have any functionality changes.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
kernel/sched/core.c | 71 +++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ead464a0f2e5..b8f220860dc7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6578,39 +6578,12 @@ const u64 min_cfs_quota_period = 1 * NSEC_PER_MSEC; /* 1ms */
static int __cfs_schedulable(struct task_group *tg, u64 period, u64 runtime);
-static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)
+/* need get_online_cpus() and hold cfs_constraints_mutex */
+static void tg_switch_cfs_runtime(struct task_group *tg, u64 period, u64 quota)
{
- int i, ret = 0, runtime_enabled, runtime_was_enabled;
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
-
- if (tg == &root_task_group)
- return -EINVAL;
-
- /*
- * Ensure we have at some amount of bandwidth every period. This is
- * to prevent reaching a state of large arrears when throttled via
- * entity_tick() resulting in prolonged exit starvation.
- */
- if (quota < min_cfs_quota_period || period < min_cfs_quota_period)
- return -EINVAL;
-
- /*
- * Likewise, bound things on the otherside by preventing insane quota
- * periods. This also allows us to normalize in computing quota
- * feasibility.
- */
- if (period > max_cfs_quota_period)
- return -EINVAL;
-
- /*
- * Prevent race between setting of cfs_rq->runtime_enabled and
- * unthrottle_offline_cfs_rqs().
- */
- get_online_cpus();
- mutex_lock(&cfs_constraints_mutex);
- ret = __cfs_schedulable(tg, period, quota);
- if (ret)
- goto out_unlock;
+ int runtime_enabled, runtime_was_enabled;
+ int i;
runtime_enabled = quota != RUNTIME_INF;
runtime_was_enabled = cfs_b->quota != RUNTIME_INF;
@@ -6647,7 +6620,41 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)
}
if (runtime_was_enabled && !runtime_enabled)
cfs_bandwidth_usage_dec();
-out_unlock:
+}
+
+static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)
+{
+ int ret = 0;
+
+ if (tg == &root_task_group)
+ return -EINVAL;
+
+ /*
+ * Ensure we have at some amount of bandwidth every period. This is
+ * to prevent reaching a state of large arrears when throttled via
+ * entity_tick() resulting in prolonged exit starvation.
+ */
+ if (quota < min_cfs_quota_period || period < min_cfs_quota_period)
+ return -EINVAL;
+
+ /*
+ * Likewise, bound things on the otherside by preventing insane quota
+ * periods. This also allows us to normalize in computing quota
+ * feasibility.
+ */
+ if (period > max_cfs_quota_period)
+ return -EINVAL;
+
+ /*
+ * Prevent race between setting of cfs_rq->runtime_enabled and
+ * unthrottle_offline_cfs_rqs().
+ */
+ get_online_cpus();
+ mutex_lock(&cfs_constraints_mutex);
+ ret = __cfs_schedulable(tg, period, quota);
+ if (!ret)
+ tg_switch_cfs_runtime(tg, period, quota);
+
mutex_unlock(&cfs_constraints_mutex);
put_online_cpus();
--
2.17.1
next prev parent reply other threads:[~2019-04-08 21:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 21:45 [PATCH 0/7] introduce cpu.headroom knob to cpu controller Song Liu
2019-04-08 21:45 ` Song Liu [this message]
2019-04-08 21:45 ` [PATCH 2/7] cgroup: introduce hook css_has_tasks_changed Song Liu
2019-04-08 21:45 ` [PATCH 3/7] cgroup: introduce cgroup_parse_percentage Song Liu
2019-04-08 21:45 ` [PATCH 4/7] sched, cgroup: add entry cpu.headroom Song Liu
2019-04-08 21:45 ` [PATCH 5/7] sched/fair: global idleness counter for cpu.headroom Song Liu
2019-04-08 21:45 ` [PATCH 6/7] sched/fair: throttle task runtime based on cpu.headroom Song Liu
2019-04-08 21:45 ` [PATCH 7/7] Documentation: cgroup-v2: add information for cpu.headroom Song Liu
2019-04-10 11:59 ` [PATCH 0/7] introduce cpu.headroom knob to cpu controller Morten Rasmussen
2019-04-10 19:43 ` Song Liu
2019-04-17 12:56 ` Vincent Guittot
2019-04-22 23:22 ` Song Liu
2019-04-28 19:47 ` Song Liu
2019-04-29 12:24 ` Vincent Guittot
2019-04-30 6:10 ` Song Liu
2019-04-30 16:20 ` Vincent Guittot
2019-04-30 16:54 ` Song Liu
2019-05-10 18:22 ` Song Liu
2019-05-14 20:58 ` Song Liu
2019-05-15 10:18 ` Vincent Guittot
2019-05-15 15:42 ` Song Liu
2019-05-21 13:47 ` Michal Koutný
2019-05-21 16:27 ` Song Liu
2019-06-26 8:26 ` Michal Koutný
2019-06-26 15:56 ` Song Liu
2019-04-15 16:48 ` Song Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190408214539.2705660-2-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=cgroups@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox