Skip to contentSkip to conversation

Class-based Kernel Resource Management

RFC Shailabh Nagar 2 participants 4 messages Aug 29, 2003 – Sep 17, 2003

lore
Share & tools
lore
#0 lore raw

As promised at the Ottawa Linux Symposium presentation in July, here is the first code drop for the Class-based Kernel Resource Management project.

The Class-based Kernel Resource Management (CKRM)
project seeks to develop Linux kernel mechanisms providing differentiated service to resources such as CPU time, memory pages, I/O and incoming network bandwith based on user defined groups of tasks called classes. Changes to the primary resource schedulers such as O(1) (cpu), deadline/CFQ (I/O) , VM page manager (memory) and inbound network connection managers will be explored and developed.

More details on the project can be found at

	http://ckrm.sf.net

including

- the paper and presentation at the Ottawa Linux Symposium 2003
- current status
- patches, modules, user programs
- detailed description of individual components and
- results from the version that was talked about at OLS'03.

The current CKRM design consists of the following components:

1) Core patch: Kernel patch defining kernel API and hooks for the classification module and individual resource (cpu,mem,io,net) controllers.

2) Classification and user API module: Loadable module implementing a Rule-based Classification Engine (RBCE) and defining a user API to CKRM. Requires the core patch.

3) CPU controller: Kernel patch implementing class-based CPU control.Requires the core patch and some classification module like RBCE.

4) Memory controller: Kernel patch for class-based control of physical memory. Requires the core patch and some classification module like RBCE.

5) I/O controller: Design proposed in OLS. To be developed in conjunction with Jens Axboe's next version of CFQ I/O scheduler.

6) Inbound network controller: Design proposed. In development.

The next few mail will contain the patches for 1),3) and 4), the module for 2).

If you are interested in this project, please join the ckrm-tech mailing list at
http://lists.sourceforge.net/lists/listinfo/ckrm-tech

You are also welcome to join as a developer by sending a mail to the project admins
Hubertus Franke ([email protected]) and Shailabh Nagar ([email protected]).

CKRM has been jointly developed by a number of folks including Hubertus Franke, Shailabh Nagar, Chandra Seetharaman, Jiantao Kong, Haoqiang Zheng, Vivek Kashyap, Nivedita Singhvi and Jonghyuk Choi.

-- Shailabh

#1 lore raw

Hello.

I tried ckrm (Class-based Kernel Resource Management) patch. I am very interested in ckrm.

However, I found the following problems.

1) Both of ckcpu and ckmem could not be applied at the same time.

I corrected the patch by hand.
Is it impossible to use both at the same time?

2) When rbcemod of the module is compiled, "ckrm_cpu_change_class" becomes an undeclared symbol.

I modified kernel source kernel/class.c and export "ckrm_cpu_change_class":

        EXPORT_SYMBOL(ckrm_cpu_change_class);

3) The bash process newly executed dies one after another when rbadmin is executed.

The value of the argument "cls" of the "ckrm_cpu_change_class" function might be NULL.
Therefore, the NULL pointer dereference occurs when it starts changing the class of the bash process.

best regards,
NIWA

#2 lore raw
Quoted 3 lines · NIWA Hideyuki

Hello.

I tried ckrm (Class-based Kernel Resource Management) patch. I am very interested in ckrm.

Thanks for your interest and feedback.

Quoted 5 lines

However, I found the following problems.

1) Both of ckcpu and ckmem could not be applied at the same time. I corrected the patch by hand.
Is it impossible to use both at the same time?

No, it is the intent of the project to have all four controllers cpu, memory, io and network to be usable simultaneously.

However, the supplied patches for each controller only assume the core patch (ckcore) to have been applied. We'll try to provide rollups of all controllers combined on the ckrm site once the combinations get tested (if you do that, please let us know !)

Quoted 5 lines

2) When rbcemod of the module is compiled, "ckrm_cpu_change_class" becomes an undeclared symbol.

I modified kernel source kernel/class.c and export "ckrm_cpu_change_class":

        EXPORT_SYMBOL(ckrm_cpu_change_class);

Thanks. I'll add it to the next version.

Quoted 7 lines

3) The bash process newly executed dies one after another when rbadmin is executed.

The value of the argument "cls" of the "ckrm_cpu_change_class" function might be NULL.
Therefore, the NULL pointer dereference occurs when it starts changing the class of the bash process.

Will check this out.

-Shailabh

#3 lore raw

I tried ckcpu patch.
However, echo command did not return from the kernel when trying to create a new class through /proc I/F.

ex. echo 1 1 10 class1 > /proc/classes

Moreover, this process kept using CPU for a long time.

And, I cannot put a process into the class.

	ex. echo 1 5560 > /proc/classes

I checked the source of ckcpu(ckcpu-A01-2.6.0-test2) and made a simple patch as a workaround.

This patch is quick Hack.:-)

best regards,
NIWA

kernel/class.c +29 -11
diff -Nru linux-2.6.0-test2/kernel/class.c linux-2.6.0-test2-ckcpu/kernel/class.c
@@ -825,6 +825,7 @@
 //	kfree(arg);
 }
 
+
 struct seq_operations classes_op = {
 	.start	= classes_start,
 	.next	= classes_next,
@@ -846,27 +847,39 @@
 {
 	char kbuf[MAX_CLASSES_WRITE+1];
 	char name[MAX_CLASSNAME_LEN];
-	int classid,weight;
+	int classid,weight,pid;
 	int cmd;
 	
 	if (count > MAX_CLASSES_WRITE)
 		return -EINVAL;
+
 	if (copy_from_user(&kbuf, buffer, count))
 		return -EFAULT;
-	kbuf[MAX_CLASSES_WRITE] = '\0'; 
 
-	if (sscanf(kbuf, "%d %d %d %s", &cmd, &classid, &weight, name) != 4)
-		return -EINVAL;
+	kbuf[MAX_CLASSES_WRITE] = '\0'; 
 
-	if (cmd == 1) {
-		__create_class(classid,name,weight,0);
-		return 0;
-	} 
+	sscanf(kbuf, "%d", &cmd);
 
-	if (cmd == 2) {
-		set_class(weight, classid);
+	switch (cmd) {
+	case 1:
+		if (sscanf(kbuf, "%d %d %d %s", &cmd, &classid, &weight, name) 
+								== 4) {
+			__create_class(classid,name,weight,0);
+			return strlen(kbuf);
+		} else {
+			return -EINVAL;
+		}
+	case 2:
+		if (sscanf(kbuf, "%d %d %d", &cmd, &classid, &pid) == 3) {
+			set_class(pid, classid);
+			return strlen(kbuf);
+		} else {
+			return -EINVAL;
+		}
+	default: 
+		return -EINVAL;
 	}
-
+		
 	return -1;
 }
 
@@ -951,6 +964,9 @@
 								
 void ckrm_cpu_change_class(struct task_struct *tsk,				
                                struct ckrm_cpu_class *cls) {		
+	if (cls == NULL) {
+		return;
+	}
 	set_class(tsk->pid,cls->class_id);
         tsk->cpu_class = cls;
 }							
@@ -960,3 +976,5 @@
 EXPORT_SYMBOL(ckrm_cpu_set_share);						
 EXPORT_SYMBOL(ckrm_cpu_get_usage);					
 EXPORT_SYMBOL(ckrm_dflt_cpu_class);
+EXPORT_SYMBOL(ckrm_cpu_change_class);
+