unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song via Libc-alpha <libc-alpha@sourceware.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153]
Date: Fri, 6 Aug 2021 00:21:21 -0700	[thread overview]
Message-ID: <20210806072121.ses46tnfp2tirn2m@google.com> (raw)
In-Reply-To: <20210806001609.x5q2zkhoo7xeaf3c@google.com>

On 2021-08-05, Fangrui Song wrote:
>
>On 2021-08-05, H.J. Lu via Libc-alpha wrote:
>>Glibc assumes that ENTRY_POINT is the lowest address for which we need
>>to keep profiling records and BFD linker uses a linker script to place
>>the input sections.
>>
>>Starting from GCC 4.6, the main function is placed in .text.startup
>>section and starting from binutils 2.22, BFD linker with
>>
>>commit add44f8d5c5c05e08b11e033127a744d61c26aee
>>Author: Alan Modra <amodra@gmail.com>
>>Date:   Thu Nov 25 03:03:02 2010 +0000
>>
>>           * scripttempl/elf.sc: Group .text.exit, text.startup and .text.hot
>>           sections.
>>
>>places .text.startup section before .text section, which leave the main
>>function out of profiling records.
>>
>>Starting from binutils 2.15, linker provides __executable_start to mark
>>the lowest address of the executable.  Use __executable_start as the
>>lowest address to keep the main function in profiling records. This fixes
>>[BZ #28153].
>>
>>Tested on Linux/x86-64, Linux/x32 and Linux/i686 as well as with
>>build-many-glibcs.py.
>>---
>>csu/gmon-start.c              | 10 +++++++++-
>>gmon/tst-gmon-gprof.sh        |  2 ++
>>gmon/tst-gmon-static-gprof.sh |  2 ++
>>3 files changed, 13 insertions(+), 1 deletion(-)
>
>LGTM

[I had not subscribed the list until few days ago]

Comment to v2: gold/ld.lld don't necessarily place .text.unlikely
before other text sections.
GNU ld's fixed section ordering may make certain optimization difficult.

RISC architectures typically create range extension thunks to overcome the
limitation of short range branches. Hot code can usually be moved to the
middle to increase the chance that one range extension thunk can be
shared by more code.

8MiB cold
2MiB hot
8MiB cold

(
.text.sorted.* is a recent addition emulation link-time layout for
improving instruction cache and TLB. An optimized case may require the
sections to be interleaved with others.)

  reply	other threads:[~2021-08-06  7:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 12:09 [PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153] H.J. Lu via Libc-alpha
2021-08-06  0:16 ` Fangrui Song via Libc-alpha
2021-08-06  7:21   ` Fangrui Song via Libc-alpha [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-31 15:13 [PATCH v2] Place ENTRY_POINT in .text.unlikely section " H.J. Lu via Libc-alpha
2021-07-31 16:36 ` Florian Weimer via Libc-alpha
2021-07-31 17:06   ` H.J. Lu via Libc-alpha
2021-07-31 17:11     ` Florian Weimer via Libc-alpha
2021-07-31 17:43       ` [PATCH v3] Use __executable_start as the lowest address for profiling " H.J. Lu via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210806072121.ses46tnfp2tirn2m@google.com \
    --to=libc-alpha@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=maskray@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).