PERFORCE change 180647 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Jul 8 16:47:11 UTC 2010


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

Change 180647 by trasz at trasz_victim on 2010/07/08 16:46:11

	Inherit resources first, then join parent containers, not the other
	way around.  This way it's faster.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_container.c#8 edit

Differences ...

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

@@ -391,35 +391,44 @@
 	mtx_lock(&container_lock);
 
 	/*
-	 * Create container for the child process and inherit containing
-	 * containers from the parent.
+	 * Create container for the child process.
 	 */
 	bzero(&child->p_container, sizeof(child->p_container));
 	container_create(&child->p_container);
-	for (i = 0; i <= CONTAINER_PARENTS_MAX; i++) {
-		container = parent->p_container.c_parents[i];
-		if (container == NULL)
+
+	/*
+	 * Inherit resource usage.
+	 */
+	for (i = 0; i <= RUSAGE_MAX; i++) {
+		if (parent->p_container.c_resources[i] == 0 ||
+		    !container_resource_inheritable(i))
 			continue;
-		error = container_join(&child->p_container, container);
+
+		error = rusage_set(child, i, parent->p_container.c_resources[i]);
 		if (error) {
+			/*
+			 * XXX: The only purpose of these two lines is to prevent from
+			 * tripping checks in container_destroy().
+			 */
+			for (i = 0; i <= RUSAGE_MAX; i++)
+				rusage_set(child, i, 0);
 			container_destroy(&child->p_container);
 			goto out;
 		}
 	}
 
 	/*
-	 * Inherit resource usage.
+	 * Inherit containing containers from the parent.
 	 */
-	for (i = 0; i <= RUSAGE_MAX; i++) {
-		if (parent->p_container.c_resources[i] == 0 ||
-		    !container_resource_inheritable(i))
+	for (i = 0; i <= CONTAINER_PARENTS_MAX; i++) {
+		container = parent->p_container.c_parents[i];
+		if (container == NULL)
 			continue;
-
-		error = rusage_set(child, i, parent->p_container.c_resources[i]);
+		error = container_join(&child->p_container, container);
 		if (error) {
 			/*
 			 * XXX: The only purpose of these two lines is to prevent from
-			 * tripping checks in container_leave_parents().
+			 * tripping checks in container_destroy().
 			 */
 			for (i = 0; i <= RUSAGE_MAX; i++)
 				rusage_set(child, i, 0);


More information about the p4-projects mailing list