All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	kan.liang@linux.intel.com, like.xu@linux.intel.com
Subject: Re: [BUG] Stack overflow when running perf and function tracer
Date: Fri, 30 Oct 2020 12:36:02 +0100	[thread overview]
Message-ID: <874kmcndy5.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20201030103220.GH2611@hirez.programming.kicks-ass.net>

On Fri, Oct 30 2020 at 11:32, Peter Zijlstra wrote:
> On Fri, Oct 30, 2020 at 11:26:01AM +0100, Thomas Gleixner wrote:
>
>> > The only thing I can come up with in a hurry is that that dummy_iregs
>> > thing really should be static. That's 168 bytes of stack out the window
>> > right there.
>> 
>> What's worse is perf_sample_data which is 384 bytes and is 64 bytes
>> aligned.

And there is also x86_perf_regs which is another 176 bytes ....

> Urgh, that thing just keeps on growing :/
>
> I'll try and have a look if we can both shrink the thing and move it off
> stack.

Even then we still need to worry about the stack depth because that
tracer code was not yet done. Throw some BPF at it and it goes south
again.

So the real question is what else is on that stack which blows it up
close to 4k? Btw, it would be massively helpful for this kind of crash
to print the actual stack depth per entry in the backtrace.

Here is the partial stack trace:
                                                Stack usage
  ring_buffer_lock_reserve+0x12c/0x380          
  trace_function+0x27/0x130
  function_trace_call+0x133/0x180
  perf_output_begin+0x4d/0x2d0                   64+
  perf_log_throttle+0x9a/0x120                  470+
  __perf_event_account_interrupt+0xa9/0x120
  __perf_event_overflow+0x2b/0xf0               
  __intel_pmu_pebs_event+0x2ec/0x3e0            760+
  intel_pmu_drain_pebs_nhm+0x268/0x330          200+
  handle_pmi_common+0xc2/0x2b0                  

The missing call chain is:

 intel_pmu_handle_irq or intel_pmu_handle_irq_v4
 perf_event_nmi_handler
 nmi
 
So the larger offenders accumulate to ~1.5k data on stack, but
where is the rest of the 4k?

It's about 15 calls. So to fill up the stack you'd need about 230 bytes
per call to go up to 4k.

Something is fishy.

Thanks,

        tglx

  reply	other threads:[~2020-10-30 11:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30  4:27 [BUG] Stack overflow when running perf and function tracer Steven Rostedt
2020-10-30  9:00 ` Peter Zijlstra
2020-10-30 10:26   ` Thomas Gleixner
2020-10-30 10:32     ` Peter Zijlstra
2020-10-30 11:36       ` Thomas Gleixner [this message]
2020-10-30 13:42         ` Thomas Gleixner
2020-10-30 10:59     ` [PATCH] perf/arch: Remove perf_sample_data::regs_user_copy Peter Zijlstra
2020-10-30 12:33       ` Steven Rostedt
2020-10-30 11:19   ` [PATCH] perf/x86: Make dummy_iregs static Peter Zijlstra

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=874kmcndy5.fsf@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=kan.liang@linux.intel.com \
    --cc=like.xu@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.