mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Williams <pwil3058@bigpond.net.au>
To: Andrew Morton <akpm@osdl.org>
Cc: Con Kolivas <kernel@kolivas.org>, Sam Vilain <sam@vilain.net>,
	Peter Williams <pwil3058@bigpond.net.au>,
	Srivatsa <vatsa@in.ibm.com>, Balbir Singh <bsingharora@gmail.com>,
	Kirill Korotaev <dev@openvz.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Mike Galbraith <efault@gmx.de>,
	Kingsley Cheung <kingsley@aurema.com>,
	CKRM <ckrm-tech@lists.sourceforge.net>,
	Ingo Molnar <mingo@elte.hu>,
	Rene Herman <rene.herman@keyaccess.nl>
Subject: [PATCH 3/4] sched: Add procfs interface for CPU rate soft caps
Date: Sun, 18 Jun 2006 18:27:09 +1000	[thread overview]
Message-ID: <20060618082709.6061.30813.sendpatchset@heathwren.pw.nest> (raw)
In-Reply-To: <20060618082638.6061.20172.sendpatchset@heathwren.pw.nest>

This patch implements a procfs interface for soft CPU rate caps.

Signed-off-by: Peter Williams <pwil3058@bigpond.com.au>
 fs/proc/base.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

Index: MM-2.6.17-rc6-mm2/fs/proc/base.c
===================================================================
--- MM-2.6.17-rc6-mm2.orig/fs/proc/base.c	2006-06-13 09:56:43.000000000 +1000
+++ MM-2.6.17-rc6-mm2/fs/proc/base.c	2006-06-14 11:14:01.000000000 +1000
@@ -167,6 +167,9 @@ enum pid_directory_inos {
 #ifdef CONFIG_CPUSETS
 	PROC_TID_CPUSET,
 #endif
+#ifdef CONFIG_CPU_RATE_CAPS
+	PROC_TID_CPU_RATE_CAP,
+#endif
 #ifdef CONFIG_SECURITY
 	PROC_TID_ATTR,
 	PROC_TID_ATTR_CURRENT,
@@ -280,6 +283,9 @@ static struct pid_entry tid_base_stuff[]
 #ifdef CONFIG_AUDITSYSCALL
 	E(PROC_TID_LOGINUID, "loginuid", S_IFREG|S_IWUSR|S_IRUGO),
 #endif
+#ifdef CONFIG_CPU_RATE_CAPS
+	E(PROC_TID_CPU_RATE_CAP,  "cpu_rate_cap",   S_IFREG|S_IRUGO|S_IWUSR),
+#endif
 	{0,0,NULL,0}
 };
 
@@ -1037,6 +1043,54 @@ static struct file_operations proc_secco
 };
 #endif /* CONFIG_SECCOMP */
 
+#ifdef CONFIG_CPU_RATE_CAPS
+static ssize_t cpu_rate_cap_read(struct file * file, char * buf,
+			size_t count, loff_t *ppos)
+{
+	struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+	char buffer[64];
+	size_t len;
+	unsigned int cppt = get_cpu_rate_cap(task);
+
+	if (*ppos)
+		return 0;
+	*ppos = len = sprintf(buffer, "%u\n", cppt);
+	if (copy_to_user(buf, buffer, len))
+		return -EFAULT;
+
+	return len;
+}
+
+static ssize_t cpu_rate_cap_write(struct file * file, const char * buf,
+			 size_t count, loff_t *ppos)
+{
+	struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
+	char buffer[128] = "";
+	char *endptr = NULL;
+	unsigned long hcppt;
+	int res;
+
+
+	if ((count > 63) || *ppos)
+		return -EFBIG;
+	if (copy_from_user(buffer, buf, count))
+		return -EFAULT;
+	hcppt = simple_strtoul(buffer, &endptr, 0);
+	if ((endptr == buffer) || (hcppt == ULONG_MAX))
+		return -EINVAL;
+
+	if ((res = set_cpu_rate_cap(task, hcppt)) != 0)
+		return res;
+
+	return count;
+}
+
+struct file_operations proc_cpu_rate_cap_operations = {
+	read:		cpu_rate_cap_read,
+	write:		cpu_rate_cap_write,
+};
+#endif
+
 static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
 	struct inode *inode = dentry->d_inode;
@@ -1797,6 +1851,11 @@ static struct dentry *proc_pident_lookup
 			inode->i_fop = &proc_loginuid_operations;
 			break;
 #endif
+#ifdef CONFIG_CPU_RATE_CAPS
+		case PROC_TID_CPU_RATE_CAP:
+			inode->i_fop = &proc_cpu_rate_cap_operations;
+			break;
+#endif
 		default:
 			printk("procfs: impossible type (%d)",p->type);
 			iput(inode);

-- 
Peter Williams                                   pwil3058@bigpond.net.au

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce

  parent reply	other threads:[~2006-06-18  8:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-18  8:26 [PATCH 0/4] sched: Add CPU rate caps Peter Williams
2006-06-18  8:26 ` [PATCH 1/4] sched: Add CPU rate soft caps Peter Williams
2006-06-18  8:38   ` Con Kolivas
2006-06-18 15:52     ` Peter Williams
2006-06-19  1:21   ` Peter Williams
2006-06-18  8:26 ` [PATCH 2/4] sched: Add CPU rate hard caps Peter Williams
2006-06-18  8:27 ` Peter Williams [this message]
2006-06-18  8:27 ` [PATCH 4/4] sched: Add procfs interface for " Peter Williams
2006-06-18  9:50 ` [PATCH 0/4] sched: Add CPU rate caps Andrew Morton
2006-06-18 10:25   ` Peter Williams
2006-06-18 11:42     ` Srivatsa Vaddagiri
2006-06-18 12:19       ` Peter Williams
2006-06-19  0:13     ` Balbir Singh
2006-06-19  1:03       ` [ckrm-tech] " Peter Williams
2006-06-19  2:20         ` Balbir Singh
2006-06-19  3:17           ` Peter Williams
2006-06-19  3:31             ` Balbir Singh
2006-06-19  3:50               ` Peter Williams
2006-06-19  8:30                 ` Balbir Singh
2006-06-19 11:35                   ` Peter Williams
2006-06-19 11:33                     ` Balbir Singh
2006-06-19 23:09                       ` Peter Williams
2006-06-20  4:28           ` Peter Williams
2006-06-20  4:40             ` Balbir Singh
2006-06-20  5:56               ` Peter Williams
2006-06-19  5:04     ` Peter Williams
2006-06-19 23:59   ` Peter Williams
2006-06-19 18:55 ` [ckrm-tech] " Chris Friesen
2006-06-19 23:28   ` Peter Williams
2006-06-22  1:52 Peter Williams
2006-06-22  1:53 ` [PATCH 3/4] sched: Add procfs interface for CPU rate soft caps Peter Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060618082709.6061.30813.sendpatchset@heathwren.pw.nest \
    --to=pwil3058@bigpond.net.au \
    --cc=akpm@osdl.org \
    --cc=bsingharora@gmail.com \
    --cc=ckrm-tech@lists.sourceforge.net \
    --cc=dev@openvz.org \
    --cc=efault@gmx.de \
    --cc=kernel@kolivas.org \
    --cc=kingsley@aurema.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rene.herman@keyaccess.nl \
    --cc=sam@vilain.net \
    --cc=vatsa@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®