* [PATCH] feat(CFS Bandwidth): add an interface for CFS Bandwidth
@ 2019-04-28 7:32 k-onishi
2019-04-29 7:55 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: k-onishi @ 2019-04-28 7:32 UTC (permalink / raw)
To: mingo; +Cc: peterz, linux-kernel, princeontrojanhorse
I added an interface which is more intuitive
and takes less write/read systemcalls.
I think that most people don't really care period
and quota of CFS Bandwidth,
They just use it like
"I will allow this process to use 50% of single core" in most cases.
But I know that we still need to care period and quota in some cases.
Please consider for merging this if you like, thanks.
Signed-off-by: k-onishi <princeontrojanhorse@gmail.com>
---
kernel/sched/core.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4778c48a7fda..27338c727d7c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6700,6 +6700,35 @@ long tg_get_cfs_period(struct task_group *tg)
return cfs_period_us;
}
+int tg_set_cfs_percent(struct task_group *tg, long cfs_percent)
+{
+ u64 quota, period;
+
+ if (cfs_percent < 0)
+ return -EINVAL;
+
+ period = 1 * NSEC_PER_SEC;
+ quota = cfs_percent * 10 * USEC_PER_SECUL;
+ return tg_set_cfs_bandwidth(tg, period, quota);
+}
+
+long tg_get_cfs_percent(struct task_group *tg)
+{
+ u64 quota, period;
+
+ if (tg->cfs_bandwidth.quota == RUNTIME_INF)
+ return -1;
+
+ quota = tg->cfs_bandwidth.quota;
+ period = tg->cfs_bandwidth.period;
+
+ do_div(quota, 10);
+ do_div(period, NSEC_PER_USEC);
+ do_div(quota, period);
+
+ return quota;
+}
+
static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css,
struct cftype *cft)
{
@@ -6724,6 +6753,18 @@ static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css,
return tg_set_cfs_period(css_tg(css), cfs_period_us);
}
+static s64 cpu_cfs_percent_read_u64(struct cgroup_subsys_state *css,
+ struct cftype *cft)
+{
+ return tg_get_cfs_percent(css_tg(css));
+}
+
+static int cpu_cfs_percent_write_u64(struct cgroup_subsys_state *css,
+ struct cftype *cftype, u64 cfs_percent)
+{
+ return tg_set_cfs_percent(css_tg(css), cfs_percent);
+}
+
struct cfs_schedulable_data {
struct task_group *tg;
u64 period, quota;
@@ -6876,6 +6917,11 @@ static struct cftype cpu_legacy_files[] = {
.read_u64 = cpu_cfs_period_read_u64,
.write_u64 = cpu_cfs_period_write_u64,
},
+ {
+ .name = "cfs_percent",
+ .read_s64 = cpu_cfs_percent_read_u64,
+ .write_u64 = cpu_cfs_percent_write_u64,
+ },
{
.name = "stat",
.seq_show = cpu_cfs_stat_show,
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] feat(CFS Bandwidth): add an interface for CFS Bandwidth
2019-04-28 7:32 [PATCH] feat(CFS Bandwidth): add an interface for CFS Bandwidth k-onishi
@ 2019-04-29 7:55 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2019-04-29 7:55 UTC (permalink / raw)
To: k-onishi; +Cc: mingo, linux-kernel
On Sun, Apr 28, 2019 at 04:32:06PM +0900, k-onishi wrote:
> I added an interface which is more intuitive
> and takes less write/read systemcalls.
>
> I think that most people don't really care period
> and quota of CFS Bandwidth,
>
> They just use it like
> "I will allow this process to use 50% of single core" in most cases.
>
> But I know that we still need to care period and quota in some cases.
>
> Please consider for merging this if you like, thanks.
This is ABI, never just add ABI without proper consideration. And given
we can already do this, it sreves no purpose what so ever.
If people cannot compute a runtime from a period, they have no business
being admin on a computer.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-29 7:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 7:32 [PATCH] feat(CFS Bandwidth): add an interface for CFS Bandwidth k-onishi
2019-04-29 7:55 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®