Re: [PATCH 3/8] sched: rt-group: interface

From: Peter Zijlstra
Date: Sat Feb 23 2008 - 14:58:47 EST



On Sat, 2008-02-23 at 11:48 -0800, Paul Menage wrote:
> On Mon, Feb 4, 2008 at 1:03 PM, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> 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.

Yes.

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

0 means no time, quite useful and clearly distinct from inf. time.


--
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/