From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9B9693858280 for ; Wed, 7 Jun 2023 08:57:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B9693858280 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686128228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ElL678Wvvxg1uAwfRh05hh0zwVaL8iRPkBYSgE/apfA=; b=NL0FivNA3K/CxFDuT7qYLetVu9wPKxZH432DataPQiPLAZN5qb5uA6S3+AcuikrGd7VUCY Oy6BDs1qn5NXAyJghEXJt4oZgajG00tEAfPAMoaM9U2xdKajbMbVxyQyp5dnkVxlGDFA8m u8EdPlOxtxkdEiw2a5vu7KyiwZwJ0JE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-HiE4ZFDcOcCBxP5f7RxPlg-1; Wed, 07 Jun 2023 04:57:05 -0400 X-MC-Unique: HiE4ZFDcOcCBxP5f7RxPlg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E14B73C01C3A; Wed, 7 Jun 2023 08:57:04 +0000 (UTC) Received: from oldenburg3.str.redhat.com (unknown [10.39.194.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57F1340CFD46; Wed, 7 Jun 2023 08:57:04 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Netto Cc: libc-alpha@sourceware.org Subject: Re: _rtld_global, _rtld_global_ro (and local aliases) as an optimization References: <87bkhs9491.fsf@oldenburg3.str.redhat.com> <69f6c69b-52c2-fe57-ed48-3d80b83576ac@linaro.org> Date: Wed, 07 Jun 2023 10:57:03 +0200 In-Reply-To: <69f6c69b-52c2-fe57-ed48-3d80b83576ac@linaro.org> (Adhemerval Zanella Netto's message of "Tue, 6 Jun 2023 16:30:02 -0300") Message-ID: <8735338xb4.fsf@oldenburg3.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 List-Id: * Adhemerval Zanella Netto: > On 06/06/23 09:14, Florian Weimer via Libc-alpha wrote: >> We currently use _rtld_global, _rtld_global_ro to pass information from >> ld.so to the other shared objects. For this purpose, it is convenient >> to have everything in two structs because we do not need to add >> additional exports. >> >> There is another effect, though. Due to the local hidden aliases >> _rtld_local, _rtld_local_ro in ld.so (similar to >> rtld_hidden_proto/rtld_hidden_def, but implemented differently), the >> instruction sequence for field access is potentially shorter than it >> would be if all these fields were separate global variables (still with >> hidden visibility). On many RISC targets, constructing the address of a >> hidden global variable or a struct member needs two instructions. >> However, obtaining the address of a different struct member is just one >> instruction if you already have the address of another member. >> >> Is this optimization still important? It's often preferable not to add >> new fields to _rtld_global/_rtld_global_ro for data that is internal to >> ld.so, to avoid changing the internal GLIBC_PRIVATE ABI. This helps >> with backporting because it enables zero-downtime upgrades. > > It is not really clear which optimization are you referring here, do mean > using __rtld_local_attribute__ with section (".sdata") when the architecture > supports it (like mostly RISC targets)? Or having _rtld_global_ro being an > alias to _rtld_local_ro within the loader? Maintaining global variables as _rtld_global/_rtld_global_ro fields even if they are not needed outside ld.so. > Also, what kind of changing are you proposing? As a concrete example, we could turn GLRO(dl_dso_sort_algo) into static int dso_sort_algo; in elf/dl-sort-maps.c because it's not used outside the file. Thanks, Florian