From owner-svn-doc-all@freebsd.org Tue Apr 12 21:50:03 2016 Return-Path: Delivered-To: svn-doc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F7B3B0D66B; Tue, 12 Apr 2016 21:50:03 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 ED8C81A22; Tue, 12 Apr 2016 21:50:02 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3CLo2fV056899; Tue, 12 Apr 2016 21:50:02 GMT (envelope-from wblock@FreeBSD.org) Received: (from wblock@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3CLo2sf056898; Tue, 12 Apr 2016 21:50:02 GMT (envelope-from wblock@FreeBSD.org) Message-Id: <201604122150.u3CLo2sf056898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wblock set sender to wblock@FreeBSD.org using -f From: Warren Block Date: Tue, 12 Apr 2016 21:50:02 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r48585 - head/en_US.ISO8859-1/htdocs/news/status X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2016 21:50:03 -0000 Author: wblock Date: Tue Apr 12 21:50:01 2016 New Revision: 48585 URL: https://svnweb.freebsd.org/changeset/doc/48585 Log: Add process-shared locks report from Konstantin Belousov . Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml Modified: head/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml ============================================================================== --- head/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml Tue Apr 12 21:48:48 2016 (r48584) +++ head/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml Tue Apr 12 21:50:01 2016 (r48585) @@ -748,4 +748,89 @@ + + + Process-Shared locks for libthr + + + + + Konstantin + Belousov + + + kib@FreeBSD.org + + + + +

POSIX specifies several kinds of pthread locks, for this + report the private and process-shared variants are considered. + Private locks can be used only by the threads of the same + process, which share the address space. Process-shared locks + can be used by threads from any process, assuming the process + can map the lock memory into its address space.

+ +

Our libthr, the library implementing the POSIX threads and + locking operations, uses a pointer as the internal + representation behind a lock. The pointer contains the + address of the actual structure carrying the lock. This has + unfortunate consequences for implementing the + PTHREAD_PROCESS_SHARED attribute for locks, since + really only the pointer is shared when the lock is mapped into + distinct address spaces.

+ +

A common opinion was that we have no choice but to break the + libthr Application Binary Interface (ABI) by changing the lock + types to be the actual lock structures (and padding for future + ABI extension). This is very painful for users, as our + previous experience with non-versioned libc and libc_r + shown.

+ +

Instead, I proposed and implemented a scheme where + process-shared locks can be implemented without breaking the + ABI. The lock memory is used as a key into the system-global + hash of the shared memory objects (off-pages), which carry the + real lock structures.

+ +

New umtx operations to create or look up the shared object, + by the memory key, were added. Libthr is modified to lookup + the object and use it for shared locks, instead of using + malloc() as for private locks.

+ +

The pointer value in the user-visible lock type contains a + canary for shared locks. Libthr detects the canary and + switches into the shared-lock mode.

+ +

The proposal of inlining the lock structures, besides the + drawbacks of breaking ABI, has its merits. Most important, + the inlining avoids the need of indirection. Another + important advantage over the off-page page approach is that no + off-page object needs to be maintained, and the lifecycle of + the shared lock naturally finishes with the destruction of the + shared memory, without explicit cleanup. Right now, off-pages + hook into vm object termination to avoid leakage, but long + liviness of the vnode vm object prolonges the off-page + existence for shared locks backed by files, however unlikely + they may be.

+ +

Libthr with inlined locks become informally known as libthr2 + project, since the library name better be changed instead of + only bumping the library version. The rtld should ensure that + libthr and libthr2 do not become simultaneously loaded into a + single address space.

+ + + The FreeBSD Foundation + + + +

Implement robust mutexes.

+
+ + +

Evaluate and implement libthr2.

+
+
+