mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aleksa Sarai <cyphar@cyphar.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Robert Richter <rric@kernel.org>,
	Brendan Gregg <bgregg@netflix.com>,
	linux-kernel@vger.kernel.org, oprofile-list@lists.sf.net
Subject: Re: [RFC] Merging ftrace_stack, perf_callchain, oprofile->backtrace and stack_trace
Date: Tue, 23 Oct 2018 02:26:12 +1100	[thread overview]
Message-ID: <20181022152612.ex5hkipgm5uzjrt5@ryuk> (raw)
In-Reply-To: <20181021201358.GF4931@worktop.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 1893 bytes --]

On 2018-10-21, Peter Zijlstra <peterz@infradead.org> wrote:
> > Hi all,
> > 
> > I'm currently working on a patchset to make kretprobes produce
> > reasonable stack traces[1], and it appears this is a generic problem
> > across the entire kernel -- you can see the same kretprobe_trampoline()
> > issue when using ftrace just as much as bpf_trace.
> > 
> > However, in working on this patch, I've noticed that there appear to be
> > several different implementations of "get the stack trace from this
> > pt_regs" which all appear quite similar. Namely:
> > 
> >   * struct ftrace_stack;
> >   * struct perf_callchain_entry; [**]
> >   * struct stack_trace;
> 
> the perf thing also does userspace stack, where the others do not afaik.

Ah right, I forgot about that. Though I wonder whether there would be a
strong argument against extending 'struct stack_trace' to contain the
ustack so we could use it then.

> And for the kernel part it already uses the regular kernel unwinder.
> I'm not sure what you're proposing.

They do use the kernel unwinder, but they are both implemented
per-architecture and use different structures to store and represent the
stack trace (even though at the end of the day they are just an array of
longs).

oprofile for instance (appears to) reimplement the following code
per-architecture:

  struct stack_trace trace;
  save_stack_trace(&trace);
  print_stack_trace(&trace, 0);

The same applies for perf_callchain_entry which is all implemented
per-architecture even though get_perf_callchain_kernel() could just
re-use save_stack_trace_regs().

But after looking at this a bit more, I think I'll write a patch which
does this the "silly" way and then I'll see whether maintainers prefer
it to be refactored.

-- 
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2018-10-22 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-21  9:31 Aleksa Sarai
2018-10-21  9:41 ` Aleksa Sarai
2018-10-21 20:13 ` Peter Zijlstra
2018-10-22 15:26   ` Aleksa Sarai [this message]

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=20181022152612.ex5hkipgm5uzjrt5@ryuk \
    --to=cyphar@cyphar.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bgregg@netflix.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oprofile-list@lists.sf.net \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rric@kernel.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

all inboxes | Powered by JetHome®