From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by sourceware.org (Postfix) with ESMTPS id 14C7938582BE for ; Mon, 21 Nov 2022 17:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14C7938582BE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-xc36.google.com with SMTP id v7-20020a4aa507000000b00496e843fdfeso1884183ook.7 for ; Mon, 21 Nov 2022 09:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MAgoTwbG7evb2qyZuSaJi1dmUZs9daLGAoNewt3tfQ4=; b=Gy3yGipJvMe74VDfOLNrLrRv+dI5Xe8Blz3heRxQSfAbH1V1A0Ic4yQxYCfx5f/LBI 15YwU7Nz9FfRHmBVWtHXrHU6UJTecikGhHQhCJVYdxIDCTYIgBP71Vdn0U/Fsw4I2Emj 91G3mrYlZWHRLlwN/BJgEjxtcmJR0lWmhyCChrCH4W5sWryI7BzrepzshH0SDyhHYX4W tMXmANvOGGmSmHD1zKqn1lPM2sIw3Zmb/+ir/0Aa+F0LLiaK5PXy1xYMmezd/Zi2B857 A7i4lzBYNiG8HD4kkLM3dUjx3oDILL54EN9nLtQ32guWIlPHFHpWPVc6dhAQxK2FtHCe JGag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MAgoTwbG7evb2qyZuSaJi1dmUZs9daLGAoNewt3tfQ4=; b=yhMD9bVzBiOHHThHt52GnTMBXp+q2CH+/6Pxc3spqVRCXOIRdxHxPYyHRJyoox4Mwg Gg/k9DctvJDx6ilSamy768mD8OBTrgkSUojY4Tgc1hpxmw9wXnpoYoDVnTJYiOrCOAop VSoJP7J/xc7BDBHBknIyKlGox+I27RW2KTNVJSKg2YhiCwG6qk+YjFjFqTsjLu62XkzT 6wgYyKSXerE57OZBUJYh8GqQoBeFNjIZ3u5s/wXvdqE7XOiYe4udd5uGdNHIyTvVuuEy 45iZ5hpgDPNowh0TPOAnMjpyMwwDHH/0coKjD1WEcfWEoB1q+3GFIGwGLOgjqHnOlB0J 5esQ== X-Gm-Message-State: ANoB5plm1LMqAf4Cly9vWrgEGLYn0eclXDmsI38R71vPHAZZ9DFvfzrh eNu0LKl8mHrAxn3dIKTWcHropYxv/mbgIJjUFOc= X-Google-Smtp-Source: AA0mqf7kowx3aAGui+9sxVVt+G9yxCSD4IAC1KyPs87wzsg7Af01bgLKCPYxQNiWgSRElnaH1oUcp9A0uQBP7oju12M= X-Received: by 2002:a05:6820:1524:b0:49f:b32b:b0af with SMTP id ay36-20020a056820152400b0049fb32bb0afmr8935794oob.16.1669050849322; Mon, 21 Nov 2022 09:14:09 -0800 (PST) MIME-Version: 1.0 References: <2a4776b9-9271-bb3c-a626-d5ec22dae6f3@in.tum.de> In-Reply-To: From: "H.J. Lu" Date: Mon, 21 Nov 2022 09:13:33 -0800 Message-ID: Subject: Re: [PATCH v4] eliminate mutex in fast path of __register_frame To: Jakub Jelinek Cc: Thomas Neumann , Tamar Christina , "gcc-patches@gcc.gnu.org" , Jason Merrill , Florian Weimer , Jonathan Wakely Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3017.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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 List-Id: On Mon, Nov 21, 2022 at 3:49 AM Jakub Jelinek via Gcc-patches wrote: > > On Mon, Nov 21, 2022 at 12:22:32PM +0100, Thomas Neumann via Gcc-patches wrote: > > > When dynamically linking a fast enough machine hides the latency, but when > > > Statically linking or on slower devices this change caused a 5x increase in > > > Instruction count and 2x increase in cycle count before getting to main. > > > > > > This has been quite noticeable on smaller devices. Is there a reason the btree > > > can't be initialized lazily? It seems a bit harsh to pay the cost of unwinding at > > > startup even when you don't throw exceptions.. > > > > we cannot easily do that lazily because otherwise we need a mutex for lazy > > initialization, which is exactly what we wanted to get rid of. > > > > Having said that, I am surprised that you saw a noticeable difference. On > > most platforms there should not be dynamic frame registration at all, as the > > regular frames are directly read from the ELF data. > > > > Can you please send me an precise description on how to reproduce the issue? > > (Platform, tools, a VM if you have one would be great). I will then debug > > this to improve the startup time. > > I can see it being called as well for -static linked binaries. > -static links in crtbeginT.o which is libgcc/crtstuff.c built with > CRTSTUFFT_O macro being defined among other things, and that disables > USE_PT_GNU_EH_FRAME: > #if defined(OBJECT_FORMAT_ELF) \ > && !defined(OBJECT_FORMAT_FLAT) \ > && defined(HAVE_LD_EH_FRAME_HDR) \ > && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \ > && defined(__GLIBC__) && __GLIBC__ >= 2 > #include > /* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h. > But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */ > # if !defined(__UCLIBC__) \ > && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ > || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) > # define USE_PT_GNU_EH_FRAME > # endif > #endif > > I think .eh_frame_hdr was never used for statically linked programs, > see already https://gcc.gnu.org/legacy-ml/gcc-patches/2001-12/msg01383.html > We don't pass --eh-frame-hdr when linking statically and dl_iterate_phdr > doesn't handle those. > Now, if -static -Wl,--eh-frame-hdr is passed when linking to the driver, > .eh_frame_hdr section is created and __GNU_EH_FRAME_HDR symbol points to > the start of that section, so at least that section could be found > if something in the crt files and libgcc is adjusted. But e.g. > i?86, nios2, frv and bfin we also need to find the got. Also, would it > work even for static PIEs? > > Jakub > There is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54568 -- H.J.