public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "tomas.vanek at fbl dot cz" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/29738] Arm M-profile dwarf2 unwinder performance suffers from exponential growth
Date: Fri, 04 Nov 2022 11:04:29 +0000	[thread overview]
Message-ID: <bug-29738-4717-0fIPU30bjt@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29738-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29738

--- Comment #5 from tomas.vanek at fbl dot cz ---
(In reply to Luis Machado from comment #1)
> My understanding is that there is only one active SP at any point, ...
> 
> We should probably have code to figure out what is the expected stack
> pointer register before we go about fetching values. That should bring the
> number of requests down. Does that sound reasonable?

Let's have M-profile without sec ext.
To figure out the active stack pointer we need xPSR and CONTROL registers.
So we need to fetch 2 registers and the 3rd fetch will get the active stack
pointer. Provided that fetching xPSR and CONTROL does not generate additional
requests we need approx n^2 + 2n calls get_frame_register_unsigned() where n is
frame level. It's much better than exponential but not a great performance...
And the code would be kind of balancing on the edge: if somebody adds fetching
one more register we get into an exponential again.

Why not use a cache to ensure linear dependency to the frame level?

The prologue cache is occupied by dwarf2 unwinder.
We need small changes in dwarf2/frame.c code to allow
arm_dwarf2_prev_register()
to allocate struct arm_prologue_cache and store the this_cache pointer to
struct dwarf2_frame_cache as a secondary, cascaded cache. This would allow
re-using the stack pointer related code in arm_make_prologue_cache(),
arm_cache_switch_prev_sp() and arm_cache_set_active_sp_value()

Or alternatively modify dwarf2/frame.c to allow changing struct
dwarf2_frame_state_reg on the fly from arm_dwarf2_prev_register().
arm_dwarf2_frame_init_reg() initializes
  reg->how = DWARF2_FRAME_REG_FN;
  reg->loc.fn = arm_dwarf2_prev_register;
The first arm_dwarf2_prev_register() call makes the decision which sp is active
and sets
  reg->how = DWARF2_FRAME_REG_CFA;
for the active sp and
  reg->how = DWARF2_FRAME_REG_SAME_VALUE;
for an inactive sp.
All following get_frame_register_unsigned() will reuse the decision cached in
reg->how and fetch the selected register directly.

What do you thing?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-11-04 11:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 18:18 [Bug tdep/29738] New: Arm v8 M-profile secure extension dwarf2 unwinder performance tomas.vanek at fbl dot cz
2022-11-02  8:16 ` [Bug tdep/29738] " luis.machado at arm dot com
2022-11-02 16:26 ` luis.machado at arm dot com
2022-11-03  8:20 ` luis.machado at arm dot com
2022-11-03  8:43 ` [Bug tdep/29738] Arm M-profile dwarf2 unwinder performance suffers from exponential grows tomas.vanek at fbl dot cz
2022-11-03  8:44 ` [Bug tdep/29738] Arm M-profile dwarf2 unwinder performance suffers from exponential growth tomas.vanek at fbl dot cz
2022-11-04 11:04 ` tomas.vanek at fbl dot cz [this message]
2022-11-04 15:27 ` torbjorn.svensson at st dot com
2023-02-02  3:43 ` brobecker at gnat dot com

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

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

  git send-email \
    --in-reply-to=bug-29738-4717-0fIPU30bjt@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).