Date: Sun, 14 Jul 2013 20:20:33 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 231154 for review Message-ID: <201307142020.r6EKKXE0070527@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@231154?ac=10 Change 231154 by rwatson@rwatson_cinnamon on 2013/07/14 20:20:23 It turns out not to be the case that all struct thread's go through UMA between the last thread exiting and a new one reusing the structure -- a previously used thread may be cached with a process when the process is returned to UMA, reducing process allocation overhead but leaving the thread ctor/dtor uninvoked. To handle this, also have TESLA per-thread storage hook the process constructor and properly reset TESLA state there. Thanks to John Baldwin for help with debugging this issue. Affected files ... .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class_perthread.c#7 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class_perthread.c#7 (text+ko) ==== @@ -36,7 +36,7 @@ /* * Routines for managing TESLA per-thread state, used in per-thread automata. * Kernel and userspace implementations differ quite a lot, due to very - * different guarantees for kernel per-thread storage and pthread + * different guarantees for kernel per-thread storage and perthread * thread-specific state. For example, the kernel implementation guarantees * that space will be available if the initial tesla_class allocation * succeedes, and instruments thread create and destroy to ensure this is the @@ -51,11 +51,22 @@ /* * Registration state for per-thread storage. */ -static eventhandler_tag tesla_perthread_ctor_tag; -static eventhandler_tag tesla_perthread_dtor_tag; +static eventhandler_tag tesla_perthread_thread_ctor_tag; +static eventhandler_tag tesla_perthread_thread_dtor_tag; +static eventhandler_tag tesla_perthread_process_dtor_tag; + +static void +tesla_perthread_process_dtor(__unused void *arg, struct proc *p) +{ + struct thread *td; + + td = FIRST_THREAD_IN_PROC(p); + if (td != NULL && td->td_tesla != NULL) + tesla_store_reset(td->td_tesla); +} static void -tesla_perthread_ctor(__unused void *arg, struct thread *td) +tesla_perthread_thread_ctor(__unused void *arg, struct thread *td) { struct tesla_store *store; uint32_t error; @@ -68,7 +79,7 @@ } static void -tesla_perthread_dtor(__unused void *arg, struct thread *td) +tesla_perthread_thread_dtor(__unused void *arg, struct thread *td) { struct tesla_store *store; @@ -81,10 +92,12 @@ tesla_perthread_sysinit(__unused void *arg) { - tesla_perthread_ctor_tag = EVENTHANDLER_REGISTER(thread_ctor, - tesla_perthread_ctor, NULL, EVENTHANDLER_PRI_ANY); - tesla_perthread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, - tesla_perthread_dtor, NULL, EVENTHANDLER_PRI_ANY); + tesla_perthread_process_dtor_tag = EVENTHANDLER_REGISTER(process_dtor, + tesla_perthread_process_dtor, NULL, EVENTHANDLER_PRI_ANY); + tesla_perthread_thread_ctor_tag = EVENTHANDLER_REGISTER(thread_ctor, + tesla_perthread_thread_ctor, NULL, EVENTHANDLER_PRI_ANY); + tesla_perthread_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, + tesla_perthread_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); } SYSINIT(tesla_perthread, SI_SUB_TESLA, SI_ORDER_FIRST, tesla_perthread_sysinit, NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307142020.r6EKKXE0070527>