public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Wang <wangyun@linux.vnet.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Paul Turner <pjt@google.com>, Dhaval Giani <dhaval.giani@gmail.com>
Subject: [PATCH 2/2] linsched: add the ability to read proc setting from proc.conf
Date: Fri, 27 Apr 2012 15:41:26 +0800	[thread overview]
Message-ID: <4F9A4DA6.8060507@linux.vnet.ibm.com> (raw)

From: Michael Wang <wangyun@linux.vnet.ibm.com>

This patch add the ability to read proc setting from: 
tools/linsched/tests/proc.conf

The style in the proc.conf is like: 
proname value

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
---
 tools/linsched/linux_linsched.c |   30 ++++++++++++++++++++++++++++++
 tools/linsched/tests/proc.conf  |    5 +++++
 2 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 tools/linsched/tests/proc.conf

diff --git a/tools/linsched/linux_linsched.c b/tools/linsched/linux_linsched.c
index 6c24578..81825b9 100644
--- a/tools/linsched/linux_linsched.c
+++ b/tools/linsched/linux_linsched.c
@@ -76,6 +76,35 @@ void linsched_init_root_cgroup(struct cgroup *root)
 
 void init_stop_tasks(void);
 
+#define PROC_CONFIGURE_PATH	"./proc.conf"
+#define CONFIGURE_BUFFER_SIZE	77
+#define CONFIGURE_MAX_LINE	77
+void linsched_read_proc_configure(void)
+{
+	int line = 0;
+	char buffer[CONFIGURE_BUFFER_SIZE];
+	char procname[CONFIGURE_BUFFER_SIZE];
+	unsigned long value;
+	
+	FILE *file = fopen(PROC_CONFIGURE_PATH, "r");
+	if (!file) {
+		return;
+	}
+
+	while (fgets(buffer, CONFIGURE_BUFFER_SIZE, file)
+		&& line < CONFIGURE_MAX_LINE) {
+		line++;	
+		if (buffer[0] == '#')
+			continue;
+		if (!sscanf(buffer, "%s %lu", procname, &value))
+			goto out;
+		set_linsched_proc(procname, value);
+	}
+
+out:
+	fclose(file);
+}
+
 void linsched_init(struct linsched_topology *topo)
 {
 	curr_task_id = 1;
@@ -98,6 +127,7 @@ void linsched_init(struct linsched_topology *topo)
 
 	init_lb_info();
 	init_stop_tasks();
+	linsched_read_proc_configure();
 }
 
 void linsched_default_callback(void)
diff --git a/tools/linsched/tests/proc.conf b/tools/linsched/tests/proc.conf
new file mode 100644
index 0000000..b7276da
--- /dev/null
+++ b/tools/linsched/tests/proc.conf
@@ -0,0 +1,5 @@
+#style: procname value
+sched_child_runs_first 1;
+sched_latency_ns 6000000;
+sched_min_granularity_ns 750000;
+sched_wakeup_granularity_ns 1000000;
-- 
1.7.1


                 reply	other threads:[~2012-04-27  7:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4F9A4DA6.8060507@linux.vnet.ibm.com \
    --to=wangyun@linux.vnet.ibm.com \
    --cc=dhaval.giani@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pjt@google.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