From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by sourceware.org (Postfix) with ESMTPS id D1EAC3858401 for ; Wed, 10 Aug 2022 13:13:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D1EAC3858401 Received: by mail-vs1-xe2f.google.com with SMTP id 66so15076210vse.4 for ; Wed, 10 Aug 2022 06:13:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=6oA/uhRr/qFyKcZkLKYpMEun9/QQV+3agdXQldxZyEY=; b=u4vc9cg7POC5HrmwvVI5RwOBcQAk53OXQNgu1S/LQA3yD4TcyPmoT+Fxu227gSpT0w RCQMLtHrzUw+6baOtESg7TyuusqwwYKBFoUbpNZzltCux/ciUtt3znLs/g/BWP2WC9Kx uKdipyeKB9LMAIxDdcK7W1Tuvlokwy4dGF3wHoUrUK1It9NxCw1FfxU7kdYuDgAWf907 f8YD/QWDTHgWy5feg/e7un119WRLtAIqBLwEkvbWj4ZuxccP/sGxYYP9OSKV4CYueSAs ZbyR3ZdlSRrAFQ/BhcvjojL3BecA5dlTIHi5qKS6iL7p/UNmZiZD4gj3ltTUM7xVI662 rwCw== X-Gm-Message-State: ACgBeo23yFl5SjwZv08SppEKa5JWqH0iZ6LQWCwgk+9/AuT+IQx1RcME xIrWihq4ZJpxwJ/Pk5FWKLcqgMapCYhWcw== X-Google-Smtp-Source: AA6agR4r5l6SKLxIi0WHcXKc/MIdwjRzFlCAPHR7t4YPew8mHF95XzVieQPBN6YJXWK0qScCRb1yZA== X-Received: by 2002:a05:6102:e95:b0:388:d486:4a63 with SMTP id l21-20020a0561020e9500b00388d4864a63mr3992062vst.39.1660137182158; Wed, 10 Aug 2022 06:13:02 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:930b:c8c3:715b:6901:2e81? ([2804:431:c7ca:930b:c8c3:715b:6901:2e81]) by smtp.gmail.com with ESMTPSA id f9-20020ab014c9000000b00384ca77a9e8sm13044097uae.27.2022.08.10.06.13.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Aug 2022 06:13:01 -0700 (PDT) Message-ID: <86e720fc-2586-22c3-5e1d-e29a48dce46d@linaro.org> Date: Wed, 10 Aug 2022 10:12:59 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.1 Subject: Re: [PATCH] elf: Remove -fno-tree-loop-distribute-patterns usage on dl-support Content-Language: en-US To: "H.J. Lu" , Siddhesh Poyarekar Cc: GNU C Library References: <20220808200021.763123-1-adhemerval.zanella@linaro.org> <8edb1934-df86-6956-b90c-16032ff67df9@linaro.org> <9e01cc4b-7acd-5719-6615-8fb3cb6bf80b@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_STOCKGEN, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2022 13:13:04 -0000 On 09/08/22 18:51, H.J. Lu wrote: > On Tue, Aug 9, 2022 at 12:40 PM Adhemerval Zanella Netto > wrote: >> >> >> >> On 09/08/22 16:34, H.J. Lu wrote: >>> On Tue, Aug 9, 2022 at 12:32 PM Adhemerval Zanella Netto >>> wrote: >>>> >>>> >>>> >>>> On 09/08/22 16:06, H.J. Lu wrote: >>>>> On Tue, Aug 9, 2022 at 11:48 AM Adhemerval Zanella Netto >>>>> wrote: >>>>>> >>>>>> >>>>>> >>>>>> On 09/08/22 15:31, H.J. Lu wrote: >>>>>>> On Tue, Aug 9, 2022 at 5:11 AM Adhemerval Zanella Netto >>>>>>> wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On 08/08/22 19:16, H.J. Lu wrote: >>>>>>>> >>>>>>>>>> --- a/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S >>>>>>>>>> +++ b/sysdeps/x86_64/multiarch/memset-evex-unaligned-erms.S >>>>>>>>>> @@ -44,4 +44,7 @@ >>>>>>>>>> >>>>>>>>>> # define USE_LESS_VEC_MASK_STORE 1 >>>>>>>>>> # include "memset-vec-unaligned-erms.S" >>>>>>>>>> +# if !defined NO_MULTIARCH && MINIMUM_X86_ISA_LEVEL >= 4 >>>>>>>>>> +strong_alias (__memset_evex_unaligned, __memset_generic) >>>>>>>>>> +# endif >>>>>>>>>> #endif >>>>>>>>> >>>>>>>>> This will define 2 __memset_generic for -march=x86-64-v4. >>>>>>>> >>>>>>>> Are you sure? Check with a x86_64 build with -march=x86-64-v4 I am seeing: >>>>>>>> >>>>>>>> $ readelf -Ws string/memset*.os | grep -w __memset_generic | wc -l >>>>>>>> 1 >>>>>>>> >>>>>>>> And it is indeed provided only by string/memset-evex-unaligned-erms.os. >>>>>>> >>>>>>> You are right. Since dl-symbol-hacks.h defines memset to an alias, >>>>>>> should it be moved to sysdes/generic and each arch can provide a >>>>>>> suitable alias? >>>>>> >>>>>> The dl-symbol-hacks.h is meant to be used solely by loader code (that's >>>>>> why I have added to elf/), but I don't have a strong preference. >>>>> >>>>> The default should be no alias. Only IFUNC targets need to define a >>>>> proper alias. >>>> >>>> Alright, although I added the alias on all targets to avoid adding another >>>> hook to specify whether memset is implemented by IFUNC (to enable the >>>> symbol redirection instead of use the default symbol name). I am not sure >>>> if making arch-specific will simplify the required code here. >>> >>> But your patch adds alias to all targets. >> >> Yes, because otherwise we will need something like HAVE_MEMSET_IFUNC to add: >> >> #if defined SHARED && HAVE_MEMSET_IFUNC >> asm ("memset = __memset_generic"); >> #endif >> >> I don't have a strong preference, although it is another this will require >> to have kernel-features.h (which we usually add the HAVE_*) on elf objects. > > There are > > elf/Makefile:CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns > elf/Makefile:CFLAGS-rtld.c += -fno-tree-loop-distribute-patterns Unfortunately we can't really remove these two without refactoring the code to avoid the memset constructions because functions call are not really allowed. For dl-tunables.c I am not sure if we actually need to filter out the invalid options to create a new tunable, since we already do not set them for glibc itself. The program will see the original value, but it show not matter since glibc would already have handle it anyway and it might avoid the need to strdup the GLIBC_TUNABLES. > elf/Makefile:CFLAGS-dl-support.c = -fno-tree-loop-distribute-patterns > include/libc-symbols.h: __attribute__ ((__optimize__ > ("-fno-tree-loop-distribute-patterns"))) We need this to void the memset recursion when gcc see the memset implementation as memset itself. > string/test-string.h: __attribute__ ((__optimize__ > ("-fno-tree-loop-distribute-patterns"))) > > There should be no check on SHARED. It can be something like > > #define SYMBOL_STR1(s) #s > #define SYMBOL_STR(s) SYMBOL_STR1(s) > > #ifdef DEFAULT_MEMSET > asm ("memset = " _SYMBOL_STR (DEFAULT_MEMSET)); > #endif Yeah, it could work. I will redo based on this, it should simplify the changes for other ports.