lkml.org 
[lkml]   [2011]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 1/1, v6] cgroup/freezer: add per freezer duty ratio control
    On Wed, 09 Feb 2011 11:07:59 +0800
    Li Zefan <lizf@cn.fujitsu.com> wrote:


    > >
    > > +#define FREEZER_KH_PREFIX "freezer_"
    > > +static int freezer_write_param(struct cgroup *cgroup, struct
    > > cftype *cft,
    > > + u64 val)
    > > +{
    > > + struct freezer *freezer;
    > > + char thread_name[32];
    > > + int ret = 0;
    > > +
    > > + freezer = cgroup_freezer(cgroup);
    > > +
    > > + if (!cgroup_lock_live_group(cgroup))
    > > + return -ENODEV;
    > > +
    > > + switch (cft->private) {
    > > + case FREEZER_DUTY_RATIO:
    > > + if (val >= 100 || val < 0) {
    >
    > val will never < 0.
    good point, I will fix it.

    >
    > > + ret = -EINVAL;
    > > + goto exit;
    > > + }
    > > + freezer->duty.ratio = val;
    > > + break;
    > > + case FREEZER_PERIOD:
    > > + if (val)
    > > + do_div(val, 100);
    >
    > Is 0 an invalid value for do_div()?
    0 is valid. I was thinking about divide by 0 by mistake. will fix it.

    >
    > > + freezer->duty.period_pct_ms = val;
    > > + break;
    > > + default:
    > > + BUG();
    > > + }
    > > +
    > > + /* start/stop management kthread as needed, the rule is
    > > that
    > > + * if both duty ratio and period values are zero, then no
    > > management
    > > + * kthread is created. when both are non-zero, we create a
    > > kthread
    > > + * for the cgroup. When user set zero to duty ratio and
    > > period again
    > > + * the kthread is stopped.
    > > + */
    > > + if (freezer->duty.ratio && freezer->duty.period_pct_ms) {
    > > + if (!freezer->fkh) {
    > > + snprintf(thread_name, 32, "%s%s",
    > > FREEZER_KH_PREFIX,
    > > + cgroup->dentry->d_name.name);
    > > + freezer->fkh = kthread_run(freezer_kh,
    > > (void *)cgroup,
    > > + thread_name);
    > > + if (IS_ERR(freezer_task)) {
    >
    > You mean IS_ERR(freezer->fkh)?
    Right, same bug for PTR_ERR. will fix.

    thanks.


    \
     
     \ /
      Last update: 2011-02-10 05:53    [W:0.024 / U:30.840 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site