On 23 September 2014 13:24, Konstantin Belousov <kostikbel_at_gmail.com> wrote: > In the patch, default behaviour is to provide RLIMIT_STACK sized stack > for the main thread. The knobs are there to restore the old AS layout > if my fears of the binary compatibility become real one day, and to > keep the interface compat with the stable/10, which already got a knob > merged. > > That said, below the patch with libthr.7 man page merged to libthr.3, > and with the editing applied. > > diff --git a/lib/libthr/libthr.3 b/lib/libthr/libthr.3 > index bfbebec..aa4572c 100644 > --- a/lib/libthr/libthr.3 > +++ b/lib/libthr/libthr.3 > _at__at_ -1,6 +1,11 _at__at_ > .\" Copyright (c) 2005 Robert N. M. Watson > +.\" Copyright (c) 2014 The FreeBSD Foundation, Inc. > .\" All rights reserved. > .\" > +.\" Part of this documentation was written by > +.\" Konstantin Belousov <kib_at_FreeBSD.org> under sponsorship > +.\" from the FreeBSD Foundation. > +.\" > .\" Redistribution and use in source and binary forms, with or without > .\" modification, are permitted provided that the following conditions > .\" are met: > _at__at_ -24,7 +29,7 _at__at_ > .\" > .\" $FreeBSD$ > .\" > -.Dd October 19, 2007 > +.Dd September 20, 2014 > .Dt LIBTHR 3 > .Os > .Sh NAME > _at__at_ -45,8 +50,216 _at__at_ has been optimized for use by applications expecting system scope thread > semantics, and can provide significant performance improvements > compared to > .Lb libkse . > +.Pp > +The library is tightly integrated with the run-time link editor > +.Xr ld-elf.so.1 1 > +and > +.Lb libc ; > +all three components must be built from the same source tree. > +Mixing > +.Li libc > +and > +.Nm > +libraries from different versions of > +.Fx > +is not supported. > +The run-time linker > +.Xr ld-elf.so.1 1 > +has some code to ensure backward-compatibility with older versions of > +.Nm . > +.Pp > +The man page documents the quirks and tunables of the > +.Nm . > +When linking with > +.Li -lpthread , > +the run-time dependency > +.Li libthr.so.3 > +is recorded in the produced object. > +.Sh MUTEX ACQUISITION > +A locked mutex (see > +.Xr pthread_mutex_lock 3 ) > +is represented by a volatile variable of type > +.Dv lwpid_t , > +which records the global system identifier of the thread > +owning the lock. > +.Nm > +performs a contested mutex acquisition in three stages, each of which > +is more resource-consuming than the previous. > +.Pp > +First, a spin loop > +is performed, where the library attempts to acquire the lock by > +.Xr atomic 9 > +operations. > +The loop count is controlled by the > +.Ev LIBPTHREAD_SPINLOOPS > +environment variable, with a default value of 2000. > +.Pp > +If the spin loop > +was unable to acquire the mutex, a yeild loop typo: yield [...] > .Sh SEE ALSO > -.Xr pthread 3 > +.Xr ktrace 1 , > +.Xr ld-elf.so.1 1 , > +.Xr getrlimit 2 , > +.Xr umtx 2 , > +.Xr dlclose 3 , > +.Xr dlopen 3 , > +.Xr errno 3 , > +.Xr getenv 3 , > +.Xr libc 3 , > +.Xr pthread_attr 3 , > +.Xr pthread_attr_setstacksize 3 , > +.Xr pthread_create 3 , > +.Xr signal 3 , > +.Xr atomic 9 . no pediod there per mdoc > .Sh AUTHORS > .An -nosplit > The > diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c > index 9bf0e29..72a067a 100644 > --- a/lib/libthr/thread/thr_init.c > +++ b/lib/libthr/thread/thr_init.c > _at__at_ -445,7 +445,7 _at__at_ init_private(void) > struct rlimit rlim; > size_t len; > int mib[2]; > - char *env; > + char *env, *env_bigstack, *env_splitstack; > > _thr_umutex_init(&_mutex_static_lock); > _thr_umutex_init(&_cond_static_lock); > _at__at_ -473,8 +473,9 _at__at_ init_private(void) > len = sizeof (_usrstack); > if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1) > PANIC("Cannot get kern.usrstack from sysctl"); > - env = getenv("LIBPTHREAD_BIGSTACK_MAIN"); > - if (env != NULL) { > + env_bigstack = getenv("LIBPTHREAD_BIGSTACK_MAIN"); > + env_splitstack = getenv("LIBPTHREAD_SPLITSTACK_MAIN"); > + if (bigstack != NULL || env_splitstack == NULL) { looks like a typo: s/bigstack/env_bigstack/ > if (getrlimit(RLIMIT_STACK, &rlim) == -1) > PANIC("Cannot get stack rlimit"); > _thr_stack_initial = rlim.rlim_cur; -- wbr, pluknetReceived on Tue Sep 23 2014 - 08:02:03 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:52 UTC