From patchwork Tue Jul 6 17:22:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44181 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BF95388F01A for ; Tue, 6 Jul 2021 17:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BF95388F01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625592197; bh=qGGJmIDmJVyTS5Hq1AbbIcUuM1mzjALKs2KFV3SK1uM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=H5X2Df0f0DmxhsCyGi+fAAomGnIRBbmuMXY2mgILKo0aEDGdjO69cJaxvRtbKNoe1 EOWXkY8v14JxiH2oKGvsQ5lwEkRBnnrVmn5GVx8p/wZL2k82CBCXlRcUGgVZzB7r+z tzLu80EudKcE24ERAYHqh7BaGv0SEIz3nXH0Bd0Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 2974A3861936 for ; Tue, 6 Jul 2021 17:22:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2974A3861936 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-wwGTsDx9P9Sr2WgBHNos0w-1; Tue, 06 Jul 2021 13:22:09 -0400 X-MC-Unique: wwGTsDx9P9Sr2WgBHNos0w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3CA61084F4C for ; Tue, 6 Jul 2021 17:22:08 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46DBC1036D05 for ; Tue, 6 Jul 2021 17:22:08 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 1/4] nptl: Use internal low-level lock type for !IS_IN (libc) In-Reply-To: References: X-From-Line: 12e42ea241149b8c10e43e60e8087ab4bc0ba01c Mon Sep 17 00:00:00 2001 Message-Id: <12e42ea241149b8c10e43e60e8087ab4bc0ba01c.1625591725.git.fweimer@redhat.com> Date: Tue, 06 Jul 2021 19:22:06 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This avoids an ABI hazard (types changing between different modules of glibc) without introducing linknamespace issues. In particular, NSS modules now call __lll_lock_wait_private@@GLIBC_PRIVATE to wait on internal locks (the unlock path is inlined and performs a direct system call). Reviewed-by: Adhemerval Zanella --- sysdeps/nptl/libc-lockP.h | 51 ++++----------------------------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index ef88a3e533..b66c938e44 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -33,18 +33,8 @@ #include #include -#if IS_IN (libpthread) -/* This gets us the declarations of the __pthread_* internal names, - and hidden_proto for them. */ -# include -#endif - /* Mutex type. */ -#if !IS_IN (libc) && !IS_IN (libpthread) -typedef pthread_mutex_t __libc_lock_t; -#else typedef int __libc_lock_t; -#endif typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t; typedef pthread_rwlock_t __libc_rwlock_t; @@ -108,56 +98,25 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0"); /* Initialize the named lock variable, leaving it in a consistent, unlocked state. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_init(NAME) \ - ((void) ((NAME) = LLL_LOCK_INITIALIZER)) -#else -# define __libc_lock_init(NAME) __pthread_mutex_init (&(NAME)) -#endif +#define __libc_lock_init(NAME) ((void) ((NAME) = LLL_LOCK_INITIALIZER)) #define __libc_rwlock_init(NAME) __pthread_rwlock_init (&(NAME), NULL) /* Finalize the named lock variable, which must be locked. It cannot be used again until __libc_lock_init is called again on it. This must be called on a lock variable before the containing storage is reused. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_fini(NAME) ((void) 0) -#else -# define __libc_lock_fini(NAME) __pthread_mutex_destroy (&(NAME)) -#endif +#define __libc_lock_fini(NAME) ((void) 0) #define __libc_rwlock_fini(NAME) ((void) 0) /* Lock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# ifndef __libc_lock_lock -# define __libc_lock_lock(NAME) \ - ({ lll_lock (NAME, LLL_PRIVATE); 0; }) -# endif -#else -# undef __libc_lock_lock -# define __libc_lock_lock(NAME) __pthread_mutex_lock (&(NAME)) -#endif +#define __libc_lock_lock(NAME) ({ lll_lock (NAME, LLL_PRIVATE); 0; }) #define __libc_rwlock_rdlock(NAME) __pthread_rwlock_rdlock (&(NAME)) #define __libc_rwlock_wrlock(NAME) __pthread_rwlock_wrlock (&(NAME)) /* Try to lock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# ifndef __libc_lock_trylock -# define __libc_lock_trylock(NAME) \ - lll_trylock (NAME) -# endif -#else -# undef __libc_lock_trylock -# define __libc_lock_trylock(NAME) \ - __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0) -#endif +#define __libc_lock_trylock(NAME) lll_trylock (NAME) /* Unlock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_unlock(NAME) \ - lll_unlock (NAME, LLL_PRIVATE) -#else -# define __libc_lock_unlock(NAME) __pthread_mutex_unlock (&(NAME)) -#endif +#define __libc_lock_unlock(NAME) lll_unlock (NAME, LLL_PRIVATE) #define __libc_rwlock_unlock(NAME) __pthread_rwlock_unlock (&(NAME)) #if IS_IN (rtld)