From patchwork Thu Dec 4 20:57:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torvald Riegel X-Patchwork-Id: 417916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 406391400DD for ; Fri, 5 Dec 2014 07:57:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:in-reply-to:references :content-type:date:message-id:mime-version; q=dns; s=default; b= FRcqEFAMejxWMTzUywZkTc2GyP4L31B2xdi/0A28UfPjiXlZQ9BK2YaduBXT2xo8 xtSDM6FjsczB55gXsqfgK32KpEG/kNgoZxkgeAHgAMnXwDrHfjZg+M1X6yq7x6VW QbHehOq4FTsKifrIvzlqYOGB5ujOdaI485WL8hXjxq8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:from:to:in-reply-to:references :content-type:date:message-id:mime-version; s=default; bh=uoQvQb uSMzjzrGTU4kdsuXyIV3I=; b=LBeMO+O9SselN9uTzSamjxHP7typVMZ0ZrEFUX Blpz4E99Laq01CJqIW9jfQfDb3Gqu/2QvcejoI9PjFdAZ2YW8RFo/bD1ZCQ3I9I4 4la+z7ocAnSjfhgl4u6eLKw+f6HYwruMiAg0g4iQlN69IiA0MgDcopnTrw1JM4lI TJ3xI= Received: (qmail 3888 invoked by alias); 4 Dec 2014 20:57:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 3867 invoked by uid 89); 4 Dec 2014 20:57:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Subject: [PATCH 2/2] pthread_once: Use futex wrappers with error checking. From: Torvald Riegel To: GLIBC Devel In-Reply-To: <1417726487.22797.48.camel@triegel.csb> References: <1417726487.22797.48.camel@triegel.csb> Date: Thu, 04 Dec 2014 21:57:15 +0100 Message-ID: <1417726635.22797.50.camel@triegel.csb> Mime-Version: 1.0 This uses the new glibc-internal futex wrappers from Patch 1/2 in pthread_once. Tested on x86 and x86_64. 2014-12-05 Torvald Riegel * nptl/pthread_once.c (clear_once_control): Use futex wrappers with error checking. (__pthread_once_slow): Likewise. commit d9cf9ffe8b1df575a3d9c9a8fd08e5b7463a1c38 Author: Torvald Riegel Date: Thu Dec 4 14:29:27 2014 +0100 pthread_once: Use futex wrappers with error checking. diff --git a/nptl/pthread_once.c b/nptl/pthread_once.c index 9bb82e9..61ccd13 100644 --- a/nptl/pthread_once.c +++ b/nptl/pthread_once.c @@ -17,7 +17,7 @@ . */ #include "pthreadP.h" -#include +#include #include @@ -35,7 +35,7 @@ clear_once_control (void *arg) get interrupted (see __pthread_once), so all we need to relay to other threads is the state being reset again. */ atomic_store_relaxed (once_control, 0); - lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE); + futex_wake (once_control, INT_MAX, FUTEX_PRIVATE); } @@ -100,8 +100,11 @@ __pthread_once_slow (pthread_once_t *once_control, void (*init_routine) (void)) is set and __PTHREAD_ONCE_DONE is not. */ if (val == newval) { - /* Same generation, some other thread was faster. Wait. */ - lll_futex_wait (once_control, newval, LLL_PRIVATE); + /* Same generation, some other thread was faster. Wait and + retry. Ignore the return value because all possible + values (0, -EWOULDBLOCK, -EINTR) need to be handled the + same. */ + futex_wait (once_control, newval, FUTEX_PRIVATE); continue; } } @@ -122,7 +125,7 @@ __pthread_once_slow (pthread_once_t *once_control, void (*init_routine) (void)) atomic_store_release (once_control, __PTHREAD_ONCE_DONE); /* Wake up all other threads. */ - lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE); + futex_wake (once_control, INT_MAX, FUTEX_PRIVATE); break; }