On Mon, Feb 4, 2008 at 1:03 PM, Peter Zijlstra <[EMAIL PROTECTED]> wrote:
>  +static int cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft,
>  +                               struct file *file,
>  +                               const char __user *userbuf,
>  +                               size_t nbytes, loff_t *unused_ppos)
>  +{
>  +       char buffer[64];
>  +       int retval = 0;
>  +       s64 val;
>  +       char *end;
>  +
>  +       if (!nbytes)
>  +               return -EINVAL;
>  +       if (nbytes >= sizeof(buffer))
>  +               return -E2BIG;
>  +       if (copy_from_user(buffer, userbuf, nbytes))
>  +               return -EFAULT;
>  +
>  +       buffer[nbytes] = 0;     /* nul-terminate */
>  +
>  +       /* strip newline if necessary */
>  +       if (nbytes && (buffer[nbytes-1] == '\n'))
>  +               buffer[nbytes-1] = 0;
>  +       val = simple_strtoll(buffer, &end, 0);
>  +       if (*end)
>  +               return -EINVAL;
>  +
>  +       /* Pass to subsystem */
>  +       retval = sched_group_set_rt_runtime(cgroup_tg(cgrp), val);
>  +       if (!retval)
>  +               retval = nbytes;
>  +       return retval;
>   }
>
>  -static u64 cpu_rt_ratio_read_uint(struct cgroup *cgrp, struct cftype *cft)
>  -{
>  -       struct task_group *tg = cgroup_tg(cgrp);
>  +static ssize_t cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft,
>  +                                  struct file *file,
>  +                                  char __user *buf, size_t nbytes,
>  +                                  loff_t *ppos)
>  +{
>  +       char tmp[64];
>  +       long val = sched_group_rt_runtime(cgroup_tg(cgrp));
>  +       int len = sprintf(tmp, "%ld\n", val);
>
>  -       return (u64) tg->rt_ratio;
>  +       return simple_read_from_buffer(buf, nbytes, ppos, tmp, len);
>   }

What's the reason that you can't use the cgroup read_uint/write_uint
methods for this? Is it just because you have -1 as your "unlimited"
value.

If so, could we avoid that problem by using 0 rather than -1 as the
"unlimited" value? It looks from what I've read in the Documentation
changes as though 0 isn't really a meaningful value.

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

Reply via email to