Date: Thu, 8 Jul 2010 16:47:10 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 180647 for review Message-ID: <201007081647.o68GlAYs081758@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007081647.o68GlAYs081758>