From patchwork Tue Sep 7 13:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 44887 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 D84E63857836 for ; Tue, 7 Sep 2021 13:34:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D84E63857836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631021651; bh=Q0GJLuIfYsw0RR/sVdGelYbVnEOGZM5pvPMv2X9eyWo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qP3AISeRyS3/f6UteDhZifp2AAsJy0G0FAM6llR/jBUJ+hJ4Yrhe5VY6mL1M6aZls DO5reAll+tE2iFCXG1FDjTyQlBMcqx9fpuXA0kbCN/v3VOcgKKljCsZqL9YFcI0gq3 0TVk0BH0Skn2XlLKx6a75DPUTN4KYFc+kfOzYUSQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 2E82C385842D for ; Tue, 7 Sep 2021 13:33:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E82C385842D Received: by mail-lj1-x236.google.com with SMTP id q21so16558893ljj.6 for ; Tue, 07 Sep 2021 06:33:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q0GJLuIfYsw0RR/sVdGelYbVnEOGZM5pvPMv2X9eyWo=; b=F44fpDUuS+LXpkHsoXiAEaeUYpU3OJEJLP6w+JyXXFD56SiGROdz/CpLrbgl4ucxi/ 8G2bzkDkNJNitenPE+Y2f29n/TD63EEJNaNtpIpA+9/Qch26Uxn8SP10THMGOgE4f5XK wtQxLJdf2SHY0HJ6Jeh2KnFBxvlozBduM9JhnwRSPHxdZvERC9G0HipDz4Rtrf6JDAFa FrdzFJDLSEEUX0uNjihji9lLAu+xJgRVReTu4LmbyncDmt//W3Ldhxbn/kZ8Xkc5tJmo exnuARYxTh2Ut8ZYbtK9R699SELm/Il6yX4wgwM60nJJoxoP/LST/2riCHLGlGFqcaCW aVXQ== X-Gm-Message-State: AOAM5328tmrs1ec6srMP1qioWVPCdvKXIaJxibg776eRaxR9/6eG3Lau y1CM8OJ6uBz6BwPS0VZChLx9RThlP5idLfHP X-Google-Smtp-Source: ABdhPJwC6pjdjZKwC/8J+WwVi17z12NalulRapKBcJ6X7vGn9LFQ/e/W8vZZXymfVxXEgY3MMAGgsA== X-Received: by 2002:a2e:2406:: with SMTP id k6mr15336814ljk.258.1631021626953; Tue, 07 Sep 2021 06:33:46 -0700 (PDT) Received: from badwolf.office.smartdec.ru ([81.23.5.115]) by smtp.googlemail.com with ESMTPSA id u15sm1012348lfk.26.2021.09.07.06.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 06:33:46 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH htl v3 0/5] Rewrite THREAD_GSCOPE Date: Tue, 7 Sep 2021 16:33:20 +0300 Message-Id: <20210907133325.255690-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Cc: samuel.thibault@gnu.org, Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Hello, this is yet another revision of the same patchset to stop issuing many redundant gsync_wake () calls. Following the brief feedback I got the last time, it switches most users of THREAD_GSCOPE_IN_TCB to PTHREAD_IN_LIBC, then actually introduces the new GSCOPE implementation, and then finally drops the remaining uses of THREAD_GSCOPE_IN_TCB entirely, since it's not always on. Things still seem to build and work somewhat (tested on GNU/Hurd i686 and GNU/Linux x86_64). rpctrace uname still shows that there are no more gsync_wake () calls. Apparently dlopen (RTLD_GLOBAL) is a good way to trigger THREAD_GSCOPE_WAIT (). I have written a test program that spawns 100 threads, then each of the threads dlopen's 100 shared objects, then dlclose's them back. On GNU/Linux, I have verified with GDB that it hits NPTL's __thread_gscope_wait (). I haven't been able to verify the same on the Hurd due to the general flakiness of GDB there, but I have ran the program with the patched glibc multiple times and it doesn't crash, so I assume it's working fine. Sergey Bugaev (5): elf: Replace most uses of THREAD_GSCOPE_IN_TCB htl: Move thread table to ld.so htl: Reimplement GSCOPE elf: Remove THREAD_GSCOPE_IN_TCB testrun.sh: Add support for --tool=rpctrace Makefile | 9 +++- elf/dl-reloc.c | 4 +- elf/dl-support.c | 3 +- elf/dl-tls.c | 6 +-- elf/dl-tls_init_tp.c | 2 +- htl/Versions | 2 - htl/pt-alloc.c | 50 +++++++++------------ htl/pt-create.c | 11 ++--- htl/pt-internal.h | 23 +++------- sysdeps/aarch64/nptl/tls.h | 1 - sysdeps/alpha/nptl/tls.h | 1 - sysdeps/arc/nptl/tls.h | 1 - sysdeps/arm/nptl/tls.h | 1 - sysdeps/csky/nptl/tls.h | 1 - sysdeps/generic/ldsodefs.h | 18 +++++--- sysdeps/generic/tls.h | 6 --- sysdeps/hppa/nptl/tls.h | 1 - sysdeps/htl/dl-support.c | 23 ++++++++++ sysdeps/htl/dl-thread_gscope_wait.c | 55 ++++++++++++++++++++++++ sysdeps/htl/pt-key-delete.c | 8 ++-- sysdeps/htl/pthreadP.h | 2 - sysdeps/htl/raise.c | 8 +++- sysdeps/htl/thrd_current.c | 7 ++- sysdeps/i386/nptl/tls.h | 1 - sysdeps/ia64/nptl/tls.h | 1 - sysdeps/m68k/nptl/tls.h | 1 - sysdeps/mach/hurd/htl/pt-sigstate-init.c | 2 +- sysdeps/mach/hurd/htl/pt-sysdep.c | 2 +- sysdeps/mach/hurd/htl/pt-sysdep.h | 2 +- sysdeps/mach/hurd/i386/tls.h | 19 ++++++++ sysdeps/mach/hurd/tls.h | 20 --------- sysdeps/microblaze/nptl/tls.h | 1 - sysdeps/mips/nptl/tls.h | 1 - sysdeps/nios2/nptl/tls.h | 1 - sysdeps/powerpc/nptl/tls.h | 1 - sysdeps/riscv/nptl/tls.h | 1 - sysdeps/s390/nptl/tls.h | 1 - sysdeps/sh/nptl/tls.h | 1 - sysdeps/sparc/nptl/tls.h | 1 - sysdeps/x86_64/nptl/tls.h | 1 - 40 files changed, 172 insertions(+), 128 deletions(-) create mode 100644 sysdeps/htl/dl-support.c create mode 100644 sysdeps/htl/dl-thread_gscope_wait.c