[PATCH, v3 2/2] cgroups: introduce timer slack subsystem

Kirill A. Shutemov kirill at shutemov.name
Thu Feb 3 01:28:55 PST 2011


On Wed, Feb 02, 2011 at 03:23:15PM -0800, Paul Menage wrote:
> On Wed, Feb 2, 2011 at 12:47 PM, Kirill A. Shutsemov
> <kirill at shutemov.name> wrote:
> > From: Kirill A. Shutemov <kirill at shutemov.name>
> >
> > Provides a way of tasks grouping by timer slack value. Introduces per
> > cgroup max and min timer slack value. When a task attaches to a cgroup,
> > its timer slack value adjusts (if needed) to fit min-max range.
> >
> > It also provides a way to set timer slack value for all tasks in the
> > cgroup at once.
> >
> > This functionality is useful in mobile devices where certain background
> > apps are attached to a cgroup and minimum wakeups are desired.
> 
> If you really want to be able to make this modular,

Why not?

> I'd be inclined to
> make the check_timer_slack hook just default to NULL, rather than
> introducing dummy_timer_slack_check()

Good point.

> > +
> > +static int tslack_write_range(struct cgroup *cgroup, struct cftype *cft,
> > +               u64 val)
> > +{
> > +       struct timer_slack_cgroup *tslack_cgroup;
> > +       struct cgroup_iter it;
> > +       struct task_struct *task;
> > +
> > +       if (!val)
> > +               return -EINVAL;
> > +
> > +       tslack_cgroup = cgroup_to_tslack_cgroup(cgroup);
> > +       switch (cft->private) {
> > +       case TIMER_SLACK_MIN:
> > +               if (val > tslack_cgroup->max_slack_ns)
> > +                       return -EINVAL;
> > +               tslack_cgroup->min_slack_ns = val;
> > +               break;
> > +       case TIMER_SLACK_MAX:
> > +               if (val < tslack_cgroup->min_slack_ns)
> > +                       return -EINVAL;
> > +               tslack_cgroup->max_slack_ns = val;
> > +               break;
> > +       default:
> > +               BUG();
> > +       }
> > +
> 
> Don't we want to keep the min/max applied hierarchically as well? i.e.
> a child can't set its min/max outside the range of its parents?

Ok, I'll implement it.

> > +
> > +static int __init init_cgroup_timer_slack(void)
> > +{
> > +       BUG_ON(timer_slack_check != dummy_timer_slack_check);
> 
> Better to make this just fail the initialization if someone else has
> already claimed the hook, rather than crashing.

Ok.

Thanks, for reviewing.

-- 
 Kirill A. Shutemov


More information about the Containers mailing list