From owner-freebsd-arch@FreeBSD.ORG Sun Jan 13 13:51:17 2013 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5DEF9B4A; Sun, 13 Jan 2013 13:51:17 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id AC6306A7; Sun, 13 Jan 2013 13:51:16 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r0DDpAYC042906; Sun, 13 Jan 2013 15:51:10 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.7.4 kib.kiev.ua r0DDpAYC042906 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r0DDpAKQ042905; Sun, 13 Jan 2013 15:51:10 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 13 Jan 2013 15:51:10 +0200 From: Konstantin Belousov To: Jilles Tjoelker Subject: Re: Fast sigblock (AKA rtld speedup) Message-ID: <20130113135110.GS2561@kib.kiev.ua> References: <20130107182235.GA65279@kib.kiev.ua> <20130111095459.GZ2561@kib.kiev.ua> <50EFE830.3030500@freebsd.org> <20130111204938.GD2561@kib.kiev.ua> <20130111232906.GA29017@stack.nl> <20130112053147.GH2561@kib.kiev.ua> <20130112162547.GA54954@stack.nl> <20130113133159.GA72462@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uc+LCsvbRhlIZa01" Content-Disposition: inline In-Reply-To: <20130113133159.GA72462@stack.nl> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: arch@freebsd.org, davidxu@freebsd.org, toolchain@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2013 13:51:17 -0000 --uc+LCsvbRhlIZa01 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 13, 2013 at 02:32:00PM +0100, Jilles Tjoelker wrote: > On Sat, Jan 12, 2013 at 05:25:47PM +0100, Jilles Tjoelker wrote: > > This suggests a different rather simpler change. Libthr can always use > > its rtld lock implementation instead of only when multiple threads > > exist. This avoids the sigprocmask() syscalls and should not be much > > slower than the default implementation in rtld because that also > > contains atomic operations (both the unpatched and the patched version). > > People that care about performance of exceptions can then link in libthr > > (in many cases, it is already linked in to allow for (the possibility > > of) threading). >=20 > > I have tested this and exceptions were indeed more than twice as fast in > > my test program if I created an extra thread doing nothing than in the > > fully single-threaded version (with or without libthr). >=20 > Here is a patch. It is lightly tested. >=20 > The function _thr_rtld_fini() can be removed afterwards because it is no > longer used. >=20 > Index: lib/libthr/thread/thr_init.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- lib/libthr/thread/thr_init.c (revision 244639) > +++ lib/libthr/thread/thr_init.c (working copy) > @@ -363,6 +363,7 @@ > _thr_signal_init(); > if (_thread_event_mask & TD_CREATE) > _thr_report_creation(curthread, curthread); > + _thr_rtld_init(); Please add a comment there, describing the reason for initializing threaded rtld locks. > } > } > =20 > Index: lib/libthr/thread/thr_kern.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- lib/libthr/thread/thr_kern.c (revision 244639) > +++ lib/libthr/thread/thr_kern.c (working copy) > @@ -57,11 +57,6 @@ > return (0); > =20 > __isthreaded =3D threaded; > - if (threaded !=3D 0) { > - _thr_rtld_init(); > - } else { > - _thr_rtld_fini(); > - } > return (0); > } I do not object. --uc+LCsvbRhlIZa01 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJQ8rvNAAoJEJDCuSvBvK1B2cgP/3syRxWJGr+UxICBCFjzuzTf qNJAC8zs4/ZaGLOaH3iRlQ13OnaR5JPq2PTIr5tImuy9f5/ixW0APcSfVq0fBUkF 68ZmPS7ACXvbclkJKVDJE0vazD+vrQ48Tl2KzeHX7ELVYaJI2yzAr7l/wF+z+Dmh GQu/rTS0J/uxjdSXnBwo53oIM2+boab+333Gvz5eUAY1xabPZBnlCoHqf6lhtFcy bIxVmQYRLix3kbRAyXCOtQvCOfKDSFyV7bi8E5UUSPjigXWSjCWXlzKaKT5xsbK1 tOyKFPObOte1GYkhj9nXe+fukImAsgUUeJlP6+42xGPajMhM41IVog8U6wuIjOB9 6VaXc8U1tr+r9zL4uWD/MW7cIThv/VL3Id8N+A1roIxvB/axJrMx7noGA/r/+89k f6zm4BxymXv100tZ7u7bT8VIDjkp4fpQXZCRdC9Qoqvi7UcfhJ7gxKUbbbOQf5Uo 893ysPRxW7oQpSgYiFyrrYTFL1e5mCEqVzO8PKuEv6BS5tuuPdeK1uRlRKTKrfW0 V1lBTFv7JehlLW6gYqmFyokDdbO/6zQmnUMeQIjtYfX+0xIq8UgiODBn8TsqzqlL F6afbDI+d8/2RrSm0vajSzYYPRoXjkbRwfLHEQ3Lbm1oiH7ifnKv3/3pNUMVACDW 0BKhbXfXmfIK78knovi5 =006m -----END PGP SIGNATURE----- --uc+LCsvbRhlIZa01--