From owner-freebsd-arch@freebsd.org Thu May 5 17:31:40 2016 Return-Path: Delivered-To: freebsd-arch@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 0E398B2E650 for ; Thu, 5 May 2016 17:31:40 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id F157518A9 for ; Thu, 5 May 2016 17:31:39 +0000 (UTC) (envelope-from martin@lispworks.com) Received: by mailman.ysv.freebsd.org (Postfix) id F086FB2E64D; Thu, 5 May 2016 17:31:39 +0000 (UTC) Delivered-To: arch@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 F00B5B2E64C; Thu, 5 May 2016 17:31:39 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from lwfs1-cam.cam.lispworks.com (mail.lispworks.com [46.17.166.21]) by mx1.freebsd.org (Postfix) with ESMTP id 9D40218A8; Thu, 5 May 2016 17:31:39 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (higson.cam.lispworks.com [192.168.1.7]) by lwfs1-cam.cam.lispworks.com (8.14.9/8.14.9) with ESMTP id u45HKZYM011908; Thu, 5 May 2016 18:20:35 +0100 (BST) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (localhost.localdomain [127.0.0.1]) by higson.cam.lispworks.com (8.14.4) id u45HKZlO021098; Thu, 5 May 2016 18:20:35 +0100 Received: (from martin@localhost) by higson.cam.lispworks.com (8.14.4/8.14.4/Submit) id u45HKZ76021094; Thu, 5 May 2016 18:20:35 +0100 Date: Thu, 5 May 2016 18:20:35 +0100 Message-Id: <201605051720.u45HKZ76021094@higson.cam.lispworks.com> From: Martin Simmons To: Konstantin Belousov CC: threads@freebsd.org, arch@freebsd.org In-reply-to: <20160505131029.GE2422@kib.kiev.ua> (message from Konstantin Belousov on Thu, 5 May 2016 16:10:29 +0300) Subject: Re: Robust mutexes implementation References: <20160505131029.GE2422@kib.kiev.ua> X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2016 17:31:40 -0000 There is a potential bug in enqueue_mutex when it tests m1 == NULL and m1 != NULL. These tests only work because m_lock is the first slot in struct pthread_mutex and hence 0 in curthread->robust_list is converted to NULL (rather than a negative value). Also, is it safe to assume memory ordering between the assignments of m->m_lock.m_rb_lnk and curthread->robust_list? Maybe it is OK because the kernel will never read curthread->robust_list until after the CPU executing enqueue_mutex has passed a memory barrier? __Martin