From owner-p4-projects@FreeBSD.ORG Thu Jul 8 16:47:11 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EE53D1065672; Thu, 8 Jul 2010 16:47:10 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B2988106564A for ; Thu, 8 Jul 2010 16:47:10 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 879298FC0A for ; Thu, 8 Jul 2010 16:47:10 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o68GlAdP081775 for ; Thu, 8 Jul 2010 16:47:10 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o68GlAYs081758 for perforce@freebsd.org; Thu, 8 Jul 2010 16:47:10 GMT (envelope-from trasz@freebsd.org) Date: Thu, 8 Jul 2010 16:47:10 GMT Message-Id: <201007081647.o68GlAYs081758@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 180647 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2010 16:47:11 -0000 http://p4web.freebsd.org/@@180647?ac=10 Change 180647 by trasz@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);