PERFORCE change 181295 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Jul 22 06:43:11 UTC 2010


http://p4web.freebsd.org/@@181295?ac=10

Change 181295 by trasz at trasz_victim on 2010/07/22 06:42:28

	Better working CPU accounting; still not quite right, though.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/TODO#17 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#24 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#43 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/TODO#17 (text+ko) ====

@@ -1,5 +1,6 @@
 Limits done:
 
+ - CPU time (RUSAGE_CPU), in microseconds
  - data size (RUSAGE_DATA), in megabytes
  - maximum file size (RUSAGE_FSIZE), in megabytes
  - number of processes (RUSAGE_NPROC)
@@ -9,7 +10,6 @@
 
 Milestone 1:
 
- - CPU time (RUSAGE_CPU), in seconds
  - stack size (RUSAGE_STACK), in megabytes,
  - resident set size (physical memory usage) (RUSAGE_RSS), in megabytes
  - locked memory usage (RUSAGE_MEMLOCK), in megabytes

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#24 (text+ko) ====

@@ -768,6 +768,7 @@
 	 */
 	(void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0);
 #ifdef CONTAINERS
+	rusage_set(p, RUSAGE_CPU, cputick2usec(p->p_rux.rux_runtime));
 	rusage_sub(p->p_pptr, RUSAGE_NPROC, 1);
 
 	/*

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#43 (text+ko) ====

@@ -633,7 +633,7 @@
 			ruxagg(p, td);
 		}
 		PROC_SUNLOCK(p);
-		rusage_set(p, RUSAGE_CPU, p->p_rux.rux_runtime / cpu_tickrate());
+		rusage_set(p, RUSAGE_CPU, cputick2usec(p->p_rux.rux_runtime));
 	}
 
 	callout_reset(&rusage_cpu_callout, hz, rusage_cpu_update, NULL);
@@ -766,7 +766,8 @@
 
 		if (lim->rlim_cur != RLIM_INFINITY) {
 			if (rule2->hr_resource == RUSAGE_CPU)
-				rule2->hr_amount = lim->rlim_max;
+				rule2->hr_amount = (uint64_t)lim->rlim_max *
+				    1000000;
 			else
 				rule2->hr_amount = lim->rlim_cur;
 			error = hrl_rule_add(rule2);
@@ -777,6 +778,9 @@
 
 	if (lim->rlim_cur != RLIM_INFINITY) {
 		rule->hr_amount = lim->rlim_cur;
+		/* Container stores CPU time in microseconds. */
+		if (rule->hr_resource == RUSAGE_CPU)
+				rule->hr_amount *= 1000000;
 		error = hrl_rule_add(rule);
 		KASSERT(error == 0, ("hrl_rule_add failed"));
 	}


More information about the p4-projects mailing list