From patchwork Sat Mar 23 17:32:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 87592 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 2CBFB3858C42 for ; Sat, 23 Mar 2024 17:39:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id DCE963858285 for ; Sat, 23 Mar 2024 17:35:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCE963858285 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DCE963858285 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::235 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215334; cv=none; b=KCd177FqnvNT5IneNuDOHi6LiXSSQOA7QmcZ1ncpnEF5J9t/fCBl4EKHlEvV64fIQZe8ltv8Iox7ULKweqklCoHhlZWh+OqJjpU2hj109YIL3mym8d94tSfU347bhx6NJKvlW5ntyF6huz6Y6Gtb8PF7dar/ZEncYp72NRgO25c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711215334; c=relaxed/simple; bh=gbkFhseru4P6cqQkSdCO4PRes9gIm2VH8g0Igaqmq6Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xujSIGbcfgLrV534JWmfDeY8rux2O/XMxkH4QhZv13AAolOym0Sg0kpdEmsChZnE37ImNvYpGAx/nLoo5AU983/dpzBrAQt9srOxgodrUrK74rtNn9DvlOT+9Xx57s/fD0d5p85bjvupy/QAnuP+jSZ4wxeDwOijSjrEb0e4Pc0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d094bc2244so42427391fa.1 for ; Sat, 23 Mar 2024 10:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711215330; x=1711820130; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KkLo4l19X/Uo8v+LOqFINnbFOYcn3QwN7BceQKDIvFU=; b=kzQ8M9pbCgL+TcmH7ShLv3ncb7q0hiICtlO5LO2kt+AODMqiREVx3NSZCv7vQlNFd+ T53X2NWrmd7Wk6iS60ZxpKSpj0JIqazpggwt4/PGM60zd3S4wlhY1pGw8zl1HZxTGhlY dgkch2bhj1Nemid1T993CaKEgF0F3S+ANnq89V2tqiv7OCn8zoDJmGjMupYpsmi6el1O xryyT7OS1l+gQN4I1itinXZuhjI6TuBTH6AMuEjazXNWgq8PpYGMuAYsFmJy5W/V+xng b4q50lFYk7s9kl3NbxVv9y6SDQHze/IoBKu7aLENXVafLL+wHLmLdeaO9bsi3KrZEtQP 1ezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711215330; x=1711820130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KkLo4l19X/Uo8v+LOqFINnbFOYcn3QwN7BceQKDIvFU=; b=ZWPpy61sfW//EES0oXZZfapotouACNG/enRIxYSP9tNlOjSeJGAs7PI8M+OkmfRXq8 UtAkIVbEqmPhOS16UDUCPLqRQ/taZJbTk0dqiSF2+tFSlm/yEKpBk4I102tsU11XrV6R 2n3J4l3b02Rektqf5Ap82I0EBu5U6Yyyv2UrGNgp3zoc31lZzZmcw2QjcxwkAGTywZpo Joxk2P6HV1LKKJ/sV26zOKilAlEhr1Mvh5j0MtAAGyfurw20Vuqf42Rq7ATUXjY06vCN 6HtVH4k+9nq/x0PtMMUExhSMc2XGHaFMQWjoJAdsKnPWWdYHTZqlXTTr7oRuRAv721Q2 OPsw== X-Gm-Message-State: AOJu0Yzy751dMB4y/5/o/BbA5+F8mO+prCxLJ2kYq+I+kXktIRJ8z2+5 4JSaTc6PuWVI8NwPSqRYAeh0qeE9GgQ2rJT1+E6yNNk9dTuHKF48/n6VBKNv X-Google-Smtp-Source: AGHT+IG0h7FplD1QhqAv5ytnXnwpsGokm7vTa3Ti32hqiBEbZzhi6R77tHfp8A518JWhWP3X3JjwtQ== X-Received: by 2002:a05:6512:3b12:b0:515:a670:3a6c with SMTP id f18-20020a0565123b1200b00515a6703a6cmr743559lfv.23.1711215329923; Sat, 23 Mar 2024 10:35:29 -0700 (PDT) Received: from surface-pro-6.. (79-139-171-253.dynamic.spd-mgts.ru. [79.139.171.253]) by smtp.gmail.com with ESMTPSA id g20-20020ac25394000000b00513973dee6fsm361290lfh.150.2024.03.23.10.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 10:35:29 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Maxim Kuvyrkov , Luca Subject: [PATCH v2 18/20] htl: Implement some support for TLS_DTV_AT_TP Date: Sat, 23 Mar 2024 20:32:59 +0300 Message-ID: <20240323173301.151066-19-bugaevc@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240323173301.151066-1-bugaevc@gmail.com> References: <20240323173301.151066-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Signed-off-by: Sergey Bugaev --- htl/pt-create.c | 2 ++ sysdeps/htl/dl-thread_gscope_wait.c | 16 ++++++++++++++-- sysdeps/mach/hurd/htl/pt-sysdep.c | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/htl/pt-create.c b/htl/pt-create.c index fac61f1b..8a735d99 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -177,7 +177,9 @@ __pthread_create_internal (struct __pthread **thread, err = ENOMEM; goto failed_thread_tls_alloc; } +#if TLS_TCB_AT_TP pthread->tcb->tcb = pthread->tcb; +#endif /* And initialize the rest of the machine context. This may include additional machine- and system-specific initializations that diff --git a/sysdeps/htl/dl-thread_gscope_wait.c b/sysdeps/htl/dl-thread_gscope_wait.c index 90a9a798..ee0a3165 100644 --- a/sysdeps/htl/dl-thread_gscope_wait.c +++ b/sysdeps/htl/dl-thread_gscope_wait.c @@ -20,6 +20,18 @@ #include #include +static inline int * +thread_gscope_flag (struct __pthread *t) +{ +#if TLS_TCB_AT_TP + return &t->tcb->gscope_flag; +#elif TLS_DTV_AT_TP + return &((tcbprehead_t *) t->tcb - 1)->gscope_flag; +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif +} + void __thread_gscope_wait (void) { @@ -33,10 +45,10 @@ __thread_gscope_wait (void) for (i = 0; i < GL (dl_pthread_num_threads); ++i) { t = GL (dl_pthread_threads[i]); - if (t == NULL || t->tcb->gscope_flag == THREAD_GSCOPE_FLAG_UNUSED) + if (t == NULL || *thread_gscope_flag (t) == THREAD_GSCOPE_FLAG_UNUSED) continue; - gscope_flagp = &t->tcb->gscope_flag; + gscope_flagp = thread_gscope_flag (t); /* We have to wait until this thread is done with the global scope. First tell the thread that we are waiting and diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c index 270e7753..5372cbf7 100644 --- a/sysdeps/mach/hurd/htl/pt-sysdep.c +++ b/sysdeps/mach/hurd/htl/pt-sysdep.c @@ -100,7 +100,16 @@ _init_routine (void *stack) to the new stack. Pretend it wasn't allocated so that it remains valid if the main thread terminates. */ thread->stack = 0; +#if TLS_TCB_AT_TP thread->tcb = THREAD_SELF; +#elif TLS_DTV_AT_TP + /* Assuming THREAD_SELF is implemented as subtracting TLS_PRE_TCB_SIZE + from the value of a thread pointer regsiter, this should optimize + down to simply reading that register. */ + thread->tcb = (tcbhead_t *) (((char *) THREAD_SELF) + TLS_PRE_TCB_SIZE); +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif #ifndef PAGESIZE __pthread_default_attr.__guardsize = __vm_page_size;