Re: [RFC v3 1/5] sched/core: add capacity constraints to CPU controller
From: Tejun Heo
Date: Fri Mar 24 2017 - 11:01:07 EST
Hello,
On Thu, Mar 23, 2017 at 11:37:50PM -0700, Joel Fernandes (Google) wrote:
> > That's also why we're gonna have problem if we later decide we need a
> > thread based API for it. Once we make cgroup the primary owner of the
> > attribute, it's not straight forward to add another owner.
>
> Sorry I don't immediately see why it is not straight forward to have a
> per-task API later once CGroup interface is added? Maybe if you don't
> mind giving an example that will help?
>
> I can start with an example, say you have a single level hierarchy
> (Top-app in Android terms is the set of tasks that are user facing and
> we'd like to enforce some capacity minimums, background on the other
> hand is the opposite):
>
> ROOT (min = 0, max = 1024)
> / \
> / \
> TOP-APP (min = 200, max = 1024) BACKGROUND (min = 0, max = 500)
>
> If in the future, if we want to have a per-task API to individually
> configure the task with these limits, it seems it will be straight
> forward to implement IMO.
Ah, you're right. I got fixated on controllers which control single
value attributes (the net ones). Yeah, we can extend the same range
interace to thread level. Sorry about the confusion.
Not necessarliy specific to the API discussion but in general lower
level in the configuration hierarchy shouldn't be able to restrict
what the parents can do, so we need to think more about how delegation
should work.
> As Patrick mentioned, all of the usecases needing this right now is an
> informed runtime placing a task in a group of tasks and not needing to
> set attributes for each individual task. We are already placing tasks
> in individual CGroups in Android based on the information the runtime
> has so adding in the capacity constraints will make it fit naturally
> while leaving the door open for any future per-task API additions IMO.
But the question is that while the use case can be served by cgroup as
the primary API, it doesn't have to be. This still is an attribute
range restriction controller rather than an actual hierarchical
resource distributor. All the controller does is restricting per-task
configuration which is the only thing operative. This is different
from bandwidth which is an actual resource controller which
distributes cpu cycles hierarchically.
There can be some benefits to having cgroup restrictions on capacity
but they won't add anything functionally fundamental. So, I still
don't see why making cgroup the primary interface would be a good idea
here.
Thanks.
--
tejun