Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Cc: linux-m68k@lists.linux-m68k.org, linux-trace-kernel@vger.kernel.org
Subject: Re: Adding ftrace support for coldfire ?
Date: Fri, 18 Oct 2024 12:45:11 -0400	[thread overview]
Message-ID: <20241018124511.70d29198@gandalf.local.home> (raw)
In-Reply-To: <12dbe761-d2e7-4289-88b1-4b7d548b4e8c@yoseli.org>

On Fri, 18 Oct 2024 16:37:39 +0200
Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:

> Hi there !
> 
> I always have been a fan of ftrace, in particular when it comes to 
> latency issues debugging.
> 
> I would love to use it on my coldfire custom board (M54418 based).
> I can see that it needs TRACE_IRQFLAGS_SUPPORT and STACKTRACE_SUPPORT, 
> both are missing.
> 
> Is it not doable ? If it is, what is required ? Implementing the 
> save_stack_trace() ? I suppose it is not enough :-) ?
> 
> Thanks in advance, as it would be a great helper !
> 

The TRACE_IRQFLAGS_SUPPORT requires the architecture to call
trace_hardirqs_off() when interrupts are disabled and trace_hardirqs_on()
when they are enabled. Now this is mostly done for you when you use the
function local_irq_save() and local_irq_restore() and friends from C code.

But each architecture needs to add those calls in the assembly for when
that happens, or even in C code where interrupts are being enabled or
disabled by other functions than generic code.

Now, x86 has been updated to basically enable interrupts almost immediately
when coming back into the kernel from a system call. Also the irq_enter()
and irq_exit() routines handle this for you too. Today x86 doesn't even call
trace_hardirqs_on/off() anywhere, but still supports TRACE_IRQFLAGS. It may
be possible that your architecture already supports TRACE_IRQFLAGS.

Basically, it is a requirement to use lockdep properly. If you enable
TRACE_IRQFLAGS_SUPPORT and enable lockdep, it will give you nasty warnings
if the architecture isn't keeping the irqflags in sync with the tracer. 

As for STACKTRACE_SUPPORT, you just need to implement save_stack_trace() or
arch_stack_walk() (which would be needed for live kernel patching). See the
code in kernel/stacktrace.c.

-- Steve


      reply	other threads:[~2024-10-18 16:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 14:37 Adding ftrace support for coldfire ? Jean-Michel Hautbois
2024-10-18 16:45 ` Steven Rostedt [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=20241018124511.70d29198@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=jeanmichel.hautbois@yoseli.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-trace-kernel@vger.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