Re: Patch to set thread title for pthreaded viced
"Matt W. Benjamin" <[email protected]> Sat, 2 Apr 2011 17:55:19 -0400 (EDT)
| Newsgroups | gmane.comp.file-systems.openafs.freebsd |
|---|---|
| Message-ID | <862064200.10.1301781319687.JavaMail.root@thunderbeast.private.linuxbox.com> |
Hi, Do mean, relative to the fs request threads? I have changesets which create thread pools for various background and on-demand processing tasks, and I think they are effective. Matt ----- "Garrett Wollman" <[email protected]> wrote: > Some operating systems (at least FreeBSD and OpenBSD) have the > pthread_set_name_np(3) interface to set the thread title. Although > the manual page says: > > This is a debugging interface and using it on a day-by-day basis > makes no > sense. > > ...this is fact wrong: the thread title is pushed into the kernel, > where it can be observed by ps(1) and top(1), among others. Here's a > patch that makes the threads started by viced itself set names for > themselves. (Note that this has no effect on the threads that are > started through the Rx server API, but that's probably a good thing, > since the only thing it could say is "fileserver worker #42".) There > are other operating systems that allow threads to set an > application-specific identifier (string or numeric) so perhaps this > function should actually be abstracted out into a common library. > > I actually don't think that the current threading model used in the > fileserver actually makes much sense; I'll have more comments on that > when I've collected some actual data. > > -GAWollman > > > --- > acinclude.m4 | 8 ++++++++ > src/viced/viced.c | 6 ++++++ > 2 files changed, 14 insertions(+), 0 deletions(-) > > diff --git a/acinclude.m4 b/acinclude.m4 > index 7452cbc..d4005de 100644 > --- a/acinclude.m4 > +++ b/acinclude.m4 > @@ -1230,6 +1230,7 @@ AC_CHECK_HEADERS([ \ > ncurses.h \ > netdb.h \ > netinet/in.h \ > + pthread_np.h \ > pwd.h \ > regex.h \ > resolv.h \ > @@ -1499,6 +1500,13 @@ else > AC_MSG_RESULT(no) > fi > > +if test "$ac_cv_header_pthread_np_h" = "yes"; then > + openafs_old_LIBS="$LIBS" > + LIBS="$LIBS $PTHREAD_LIBS" > + AC_CHECK_FUNCS(pthread_set_name_np) > + LIBS="$openafs_old_LIBS" > +fi > + > AC_TYPE_SIGNAL > OPENAFS_RETSIGTYPE > AC_CHECK_SIZEOF(void *) > diff --git a/src/viced/viced.c b/src/viced/viced.c > index ce327e5..c5c3196 100644 > --- a/src/viced/viced.c > +++ b/src/viced/viced.c > @@ -87,6 +87,9 @@ > #include "host.h" > #ifdef AFS_PTHREAD_ENV > #include <afs/softsig.h> > +#ifdef HAVE_PTHREAD_NP_H > +#include <pthread_np.h> > +#endif /* HAVE_PTHREAD_NP_H */ > #endif > #if defined(AFS_SGI_ENV) > #include "sys/schedctl.h" > @@ -431,6 +434,9 @@ setThreadId(char *s) > /* set our 'thread-id' so that the host hold table works */ > pthread_setspecific(rx_thread_id_key, > (void *)(intptr_t)rx_NewThreadId()); > +#ifdef HAVE_PTHREAD_SET_NAME_NP > + pthread_set_name_np(pthread_self(), s); > +#endif > ViceLog(0, > ("Set thread id %p for '%s'\n", > pthread_getspecific(rx_thread_id_key), s)); > -- > 1.7.4.1 > _______________________________________________ > port-freebsd mailing list > [email protected] > https://lists.openafs.org/mailman/listinfo/port-freebsd -- Matt Benjamin The Linux Box 206 South Fifth Ave. Suite 150 Ann Arbor, MI 48104 http://linuxbox.com tel. 734-761-4689 fax. 734-769-8938 cel. 734-216-5309