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

From: Paul Menage
Date: Wed Feb 02 2011 - 18:23:46 EST


On Wed, Feb 2, 2011 at 12:47 PM, Kirill A. Shutsemov
<kirill@xxxxxxxxxxxxx> wrote:
> From: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
>
> 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, I'd be inclined to
make the check_timer_slack hook just default to NULL, rather than
introducing dummy_timer_slack_check()


> +
> +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?

> +
> +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.

Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/