From patchwork Wed Jan 3 17:14:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 83258 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 7501E386EC0E for ; Wed, 3 Jan 2024 17:22:12 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 4C1BC38582B8 for ; Wed, 3 Jan 2024 17:15:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C1BC38582B8 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 4C1BC38582B8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302128; cv=none; b=AaeffAnwjIovx5tfN34OkuPd76CU5Q+DJG6USXwhJNtcndn8pCBVmVAm8kU+hcn7CYjq0pnWKB5bPqQ/K3pWMWkEwxV/HmKHLX/rmjZC+ZK8YOSF5gw00ixYbxKa/EjA6etxD4reklh3DI+KOrohbxkWHUdSmo52eAr3g7WXkrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704302128; c=relaxed/simple; bh=ROMiKIQWc8wffcvE3bzmlQZWpuu4FuO4DyjDe8JHDso=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AANQ5KWPYGTav/BwNL5PzfHeX6rbhDVw7rVGL0W4nQp6yQqkbycEymZvKz8BUDuGeF24Ok/K8ilDFJyVUQUk+qVBRLBVfURThSTXP1NyJCquf/6VzkKAuHPkWia7GX+BQrRWkP5E5cuwFNv6XdVD5Hk6hPi2+at4A67IXrgLycg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50e7b273352so7305035e87.1 for ; Wed, 03 Jan 2024 09:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704302124; x=1704906924; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FDEQwSt1u67zMVsxNREN3UpQS6HiQFnb/WbpL9H6J1k=; b=db32a57w0sGln72Ru13veh4Pke2+8FkbiNmaQNr31sEuWitK8YZ2wkJgk+LZstA55Z yP8LTBjSNygpGp36OkYeYqs0RTIgdA1nD5iH+3/jfeLaWeEmZzbSdZhhlu829RJzoQUl Nm3sZauB7YbZLuRSmfcAe2rfCxOd+qx5H2MTra9K6U4KxCHGThk6axLzrJ2kvG9oJbHw z3t/m13bqTdbZHllfXgYWOirVi697eC3P7OYbDHLtxQJUSR8upMHw536Wy3G5PrKmpY+ ykNg7hb8HVeiUBKtSuYurFKu8uTzCPIup5r8Ak5CTmWO4KQqYaMFMblBnGi9j8nYgiE2 6Gdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704302124; x=1704906924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDEQwSt1u67zMVsxNREN3UpQS6HiQFnb/WbpL9H6J1k=; b=QxXC7s0qmnibkjfzEhs/gS7qGqaHidcbBrqNmq+elNgtoPMGgpuz/ROre/ObhHm7Ss nV3hAmeA2wb5LYdL8XkIA2m2fwvL1hrCJmsLXawzG6pv3Asr34iuag8i8s5BJsZJ7cns gPzB+rSom2z58dhZiGe7xhTDf4Id6LWjAHI9SlGT8537Ou67KWa6n1Sq6Mu4sT/aEGGI 7gmMONvFQirG6CtYzMGmUHItZuCu8XtJyhp4L+WBNSEg905jFaQpdXxU8yzJ+zt3siT1 rKTkTBAt/nOMd+d8FNvMGi3kjBPPCkA1kQu/goCQDsgBhzViMf2vd5snVSp7V9+qvw2i pJAQ== X-Gm-Message-State: AOJu0YyNEU2R+rDWywmarQRAMarsd4efv4nEBCqo1EBy43vngPbNR+X4 tSukSsxgaDpE8ajwoG9MBsiLZQcE3M4= X-Google-Smtp-Source: AGHT+IFa5Kds4oYGeipH5qttHzdl/7zJKmFSUFp5oATDhiEusg7q9ZT4TG2C+klXBusKbHJrm+eoMA== X-Received: by 2002:a05:6512:3451:b0:50e:4fb2:a65d with SMTP id j17-20020a056512345100b0050e4fb2a65dmr7467838lfr.6.1704302124294; Wed, 03 Jan 2024 09:15:24 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:b32f:ebdc:fd0:376b:8006]) by smtp.gmail.com with ESMTPSA id y23-20020a196417000000b0050e6d84d177sm3546068lfb.279.2024.01.03.09.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:15:23 -0800 (PST) From: Sergey Bugaev To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [RFC PATCH 21/23] htl: Implement some support for TLS_DTV_AT_TP Date: Wed, 3 Jan 2024 20:14:54 +0300 Message-ID: <20240103171502.1358371-22-bugaevc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103171502.1358371-1-bugaevc@gmail.com> References: <20240103171502.1358371-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 --- Also untested. 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;