From owner-freebsd-threads@FreeBSD.ORG Sun Jul 21 16:39:42 2013 Return-Path: Delivered-To: freebsd-threads@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 77C681B6; Sun, 21 Jul 2013 16:39:42 +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 A55B296C; Sun, 21 Jul 2013 16:39:41 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id r6LGdbaV020320; Sun, 21 Jul 2013 19:39:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua r6LGdbaV020320 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id r6LGdbWO020319; Sun, 21 Jul 2013 19:39:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 21 Jul 2013 19:39:37 +0300 From: Konstantin Belousov To: Jilles Tjoelker Subject: Re: Mutexes and error checking Message-ID: <20130721163937.GD5991@kib.kiev.ua> References: <51E71D4F.5030502@marcuscom.com> <51E8061B.60906@marcuscom.com> <51EB5EC4.6050802@marcuscom.com> <20130721160220.GA38417@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oFGQ2VdWvpciDCpb" Content-Disposition: inline In-Reply-To: <20130721160220.GA38417@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: Joe Marcus Clarke , Daniel Eischen , freebsd-threads@freebsd.org, Koop Mast X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jul 2013 16:39:42 -0000 --oFGQ2VdWvpciDCpb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 21, 2013 at 06:02:20PM +0200, Jilles Tjoelker wrote: > On Sun, Jul 21, 2013 at 12:08:36AM -0400, Joe Marcus Clarke wrote: > > On 7/19/13 1:55 AM, Daniel Eischen wrote: > > > It seems Solaris behaves like Linux with PTHREAD_MUTEX_NORMAL > > > and _unlocking_ mutexes owned by other threads (dead or not). > > > Solaris only returns EPERM for PTHREAD_MUTEX_ERRORCHECK > > > mutexes. >=20 > > Given that, should we do the same? >=20 > According to http://sourceware.org/glibc/wiki/LockElisionGuide, it seems > like glibc wants to change behaviour here. If a mutex is implemented via > some sort of transactional memory, it may not work correctly if the > mutex is used as a semaphore with a different thread unlocking it. In > particular, attempting to commit a transaction via the XEND instruction > will cause a general protection fault if no transaction is in progress. > Adding software checks against these conditions will use up valuable > transactional memory tracking space. For the XEND, Intel advises to use XTEST before to distinguish between transactional and not transactional executions. The elided unlock routine has to test the value of lock anyway, to distinguish between elided and fallback locking. Then, it is not too hard to add a check for the case 'locked, but not by us', since we have to check to avoid XEND for non-elided locks already. >=20 > So I think allowing pthread_mutex_unlock() by a different thread would > be a step backwards. But this is true regardless of the TSX. --oFGQ2VdWvpciDCpb Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJR7A7IAAoJEJDCuSvBvK1BsZ4P/jSfrnAgJcy4h2RRdMpzLL4M ERjZI2wEupkjF45NVayRVx9uBDzyd5R7CCL/uK164/9JeHYkDPSZ7XeMWZwpRMTs h7ErRco8mrThqh0nuReIw99vJUTA51xF7ZQhiTVTjIsR1A/SQrzBIMMpGkY0nGvT HGV4NK8fXMas8b5Gcsg+k0kyidyGqt6cql+/iaNL6ANfh8SbOJM9//u0PHVTzMZu jmYO81SNOjl9M8mC3qmDJlbFS5zAHlsIuB6NhEkTg3yg9ZB+WpBwGz6cPAsyFa5L G3FR4d6PKiJjypHI8teAlM7Ne8WiEw0sXs1HocBvY+rDHIl/LcCqjc6Wu7UYClL8 fFxpxJYiJyqOaSEFwmSJ7yf8dD1PC2rKpU0VnOQZp8/I6KxjqyA0HFYoPEvjwqRf C15tstROA2gPM1ODjoUuOczk9hhMbSJuCrFXgeTjzsCtVJXcMpky2EVaHAYvZJcl ewRpmBv81673IEP4h875zna6mF0LWjv3fkSekrPGmiP4TVe22SpWybQ/LB4UnVMj BYs4GCGcQe2QUFa+7FO1M90PqfQOmtz84xCFTYkyahR8V9ajQ+gyUUgSDsdJPyAO jzAGjFJopTQ10SAOm1AT/wcCLxf6ZKmfg6j0scpSVEopIwQQsgo2J7kPdyA9TEvR /WbO07t87hXfULlChIel =M74n -----END PGP SIGNATURE----- --oFGQ2VdWvpciDCpb--