From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762430AbYBWTsm (ORCPT ); Sat, 23 Feb 2008 14:48:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755507AbYBWTsd (ORCPT ); Sat, 23 Feb 2008 14:48:33 -0500 Received: from smtp-out.google.com ([216.239.33.17]:1663 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753503AbYBWTsc (ORCPT ); Sat, 23 Feb 2008 14:48:32 -0500 DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=received:message-id:date:from:to:subject:cc:in-reply-to: mime-version:content-type:content-transfer-encoding: content-disposition:references; b=U4y31mxRaMMZkaKGWNFcHxeWEywgPXhGFtck8zCSF9vVrVsj0mkFptAMN/aT09GOc OFfIjDR921DKWLHVr0I1w== Message-ID: <6599ad830802231148w518d937cyd75d1d0a35702d9d@mail.gmail.com> Date: Sat, 23 Feb 2008 11:48:23 -0800 From: "Paul Menage" To: "Peter Zijlstra" Subject: Re: [PATCH 3/8] sched: rt-group: interface Cc: "Ingo Molnar" , linux-kernel@vger.kernel.org, tong.n.li@intel.com In-Reply-To: <20080204211836.968632000@chello.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080204210258.118479000@chello.nl> <20080204211836.968632000@chello.nl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 4, 2008 at 1:03 PM, Peter Zijlstra 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