From owner-svn-src-all@FreeBSD.ORG Sat May 16 16:40:22 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CBEAF427 for ; Sat, 16 May 2015 16:40:22 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AED3419EC for ; Sat, 16 May 2015 16:40:22 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.9/8.14.9) with ESMTP id t4GGeMq1010049 for ; Sat, 16 May 2015 16:40:22 GMT (envelope-from bdrewery@freefall.freebsd.org) Received: (from bdrewery@localhost) by freefall.freebsd.org (8.14.9/8.14.9/Submit) id t4GGeMU9010045 for svn-src-all@freebsd.org; Sat, 16 May 2015 16:40:22 GMT (envelope-from bdrewery) Received: (qmail 3910 invoked from network); 16 May 2015 11:40:21 -0500 Received: from unknown (HELO ?10.10.1.139?) (freebsd@shatow.net@10.10.1.139) by sweb.xzibition.com with ESMTPA; 16 May 2015 11:40:21 -0500 Message-ID: <555772FA.2080408@FreeBSD.org> Date: Sat, 16 May 2015 11:40:26 -0500 From: Bryan Drewery Organization: FreeBSD User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Konstantin Belousov , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r282948 - head/lib/libthr/thread References: <201505150840.t4F8eHhM000804@svn.freebsd.org> In-Reply-To: <201505150840.t4F8eHhM000804@svn.freebsd.org> OpenPGP: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="V2VQqCUxc38WfvmkBeTmRbEMAdALPOMfx" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2015 16:40:23 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --V2VQqCUxc38WfvmkBeTmRbEMAdALPOMfx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 5/15/2015 3:40 AM, Konstantin Belousov wrote: > Author: kib > Date: Fri May 15 08:40:17 2015 > New Revision: 282948 > URL: https://svnweb.freebsd.org/changeset/base/282948 >=20 > Log: > Some third-party malloc(3) implementations use pthread_setspecific(3)= > to handle per-thread information. Since our pthread_setspecific() > implementation calls calloc(3) to allocate per-thread specific data > storage, things get complicated. > =20 > Switch the allocator to use bare mmap(2). There is some loss of the > allocated page, since e.g. on amd64, PTHREAD_KEYS_MAX * sizeof(struct= > pthread_specific_elem) is 3K (it actually spans whole page due to > padding), but I believe it is more acceptable than additional code fo= r > specialized allocator(). > =20 > The alternatives would either to make the specific data array be part= of > the struct thread, or use internal bindings to call the libc malloc, > avoiding interposing. > =20 > Also do the style pass over the thr_spec.c, esp. simplify the > conditionals nesting by returning early when an error detected. > Remove trivial comments. > =20 > Found by: yuri@rawbw.com > PR: 200138 > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks >=20 > Modified: > head/lib/libthr/thread/thr_spec.c >=20 Thank you for this! I have a lot of patches at Isilon for adding a libc cleanup function to free all caching, for use in memory leak detectors such as valgrind. I even fixed valgrind to utilize it. This particular code was problematic. I wrote up an arch mail about my patch a few months ago and it ended up being several pages about libthr. I never sent it because it became too long. I need to revisit that work and get an arch@ discussion going on my proposal and the various issues I ran into with libthr. While developing this cleanup feature, and working on a malloc wrapper (dmalloc), I had a lot of problems with pthread_mutext_t (and similar primitives) using calloc(3). I found that David Xu actually did do most of the work to change this but abandoned it (it's all in SVN still). Using pthreads from a malloc wrapper is really painful to get right. --=20 Regards, Bryan Drewery --V2VQqCUxc38WfvmkBeTmRbEMAdALPOMfx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJVV3L6AAoJEDXXcbtuRpfPV5IIAOET2XsUZhEavP/dvKuBQK46 L0HGVyexgUcx/2Zmb9HhI21xaPl6uTsgc7wycJgJXGjXNpqRipSursGogvqEcrTW c50aTnPgzGj2jC9hOWcjK34MdVU0Q/Amkj/mkeToYDAaxRVYszdOuc1Xvg3nlnDn ZFioXGT6FzpjYcyZAOaKi9xeKJm+4Y2f65fEOF4kXjwhXbFtDdQ9QDPUQ/avzL5x Ddladk6VAbKssJKWmuJkR7zVRWHHlAGcmPOZ5v2NPP/aXyaYE/429rGsmDMwqMdR uHhN0j4QdJ+wjWT29lyneDUS9FQVJIAEnpaHbJJqyGEzoeU7dkIkMQbAcxMADIQ= =roz7 -----END PGP SIGNATURE----- --V2VQqCUxc38WfvmkBeTmRbEMAdALPOMfx--