public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Greg Ungerer <gerg@linux-m68k.org>,
	Tomas Glozar <tglozar@redhat.com>
Subject: Re: [PATCH RFC 0/2] Add basic tracing support for m68k
Date: Wed, 20 Nov 2024 12:47:19 +0100	[thread overview]
Message-ID: <66e2b7cd-4a4f-4f60-9846-a14c476bd050@yoseli.org> (raw)
In-Reply-To: <20241119131035.3c42a533@gandalf.local.home>

Hi Steve,

On 19/11/2024 19:10, Steven Rostedt wrote:
> On Tue, 19 Nov 2024 19:06:45 +0100
> Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:
>>>
>>> It shouldn't crash, but it also found a bug in your code ;-)
>>
>> In my code is a really big assumption :-).
> 
> Well, not your personally, but I meant "your" as in m68k code.
> 
>>
>>> You reference two variables that are not part of the event:
>>>
>>>    "mem_map" and "m68k_memory[0].addr"
>>>
>>> Do these variables ever change? Because the TP_printk() part of the
>>> TRACE_EVENT() macro is called a long time after the event is recorded. It
>>> could be seconds, minutes, days or even months (and unlikely possibly
>>> years) later.
>>
>> I am really not the best placed to answer.
>> AFAIK, it sounds like those are never changing.
> 
> That would mean they are OK and will not corrupt the trace, but it will be
> meaningless for tools like perf and trace-cmd.
> 
>>
>>>
>>> The event takes place and runs the TP_fast_assign() to record the event in
>>> the ring buffer. Then some time later, when you read the "trace" file, the
>>> TP_printk() portion gets run. If you wait months before reading that, it is
>>> executed months later.
>>>
>>> Now you have "mem_map" and "m68k_memory[0].addr" in that output that gets
>>> run months after the fact. Are they constant throughout the boot?
>>
>> I don't know.
>>
>>> Now another issue is that user space has no idea what those values are. Now
>>> user space can not print the values. Currently the code crashes because you
>>> are the first one to reference a global value from a trace event print fmt.
>>> That should probably be fixed to simply fail to parse the event and ignore
>>> the print format logic (which defaults to just printing the raw fields).
>>
>> The patch you sent works...
>> But, it fails a bit later:
>> Dispatching timerlat u procs
>> starting loop
>> User-space timerlat pid 230 on cpu 0
>> Segmentation fault
>>
> 
> More printk? ;-)

Indeed, but the result is not straightforward this time :-(.

Long story short: it fails at kbuffer_load_subbuffer() call in
read_cpu_pages().

I added printf in the kbuffer helpers in libevent, and it finishes at:
__read_long_4: call read_4 at 0x600230c2
__read_4_sw: ptr=0x8044e2ac

static unsigned int __read_4_sw(void *ptr)
{
	printf("%s: ptr=%p, value: %08x\n", __func__, ptr, *(unsigned int *)ptr);
	unsigned int data = *(unsigned int *)ptr;
	printf("%s: data=%08x\n", __func__, data);

	return swap_4(data);
}

As soon as ptr is dereferenced, the segfault appears.
ptr should be ok though, as the address is valid afaik...

I must say that now I am stuck :-(.

Thanks,
JM

  reply	other threads:[~2024-11-20 11:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21  9:44 [PATCH RFC 0/2] Add basic tracing support for m68k Jean-Michel Hautbois
2024-10-21  9:44 ` [PATCH RFC 1/2] m68k: Add tracirqs Jean-Michel Hautbois
2024-10-22  5:28   ` Steven Rostedt
2024-10-22  5:42     ` Jean-Michel Hautbois
2024-10-22  8:30       ` Steven Rostedt
2024-10-22  9:21         ` Jean-Michel Hautbois
2024-10-23  8:47           ` Steven Rostedt
2024-10-23  9:07             ` Jean-Michel Hautbois
2024-10-23  9:13               ` Geert Uytterhoeven
2024-10-23  9:31                 ` Jean-Michel Hautbois
2024-10-23 10:30                   ` Jean-Michel Hautbois
2024-10-23  3:53   ` Michael Schmitz
2024-10-23  5:53     ` Jean-Michel Hautbois
2024-10-23  7:30       ` Michael Schmitz
2024-10-23  8:59         ` Jean-Michel Hautbois
2024-10-23  9:27           ` Steven Rostedt
2024-10-23  8:51       ` Eero Tamminen
2024-10-21  9:44 ` [PATCH RFC 2/2] arch: m68k: Add STACKTRACE support Jean-Michel Hautbois
2024-11-15  8:26 ` [PATCH RFC 0/2] Add basic tracing support for m68k Jean-Michel Hautbois
2024-11-15 15:25   ` Steven Rostedt
2024-11-15 15:33     ` Jean-Michel Hautbois
2024-11-15 19:55       ` Steven Rostedt
2024-11-18 10:11         ` Jean-Michel Hautbois
2024-11-18 20:20           ` Steven Rostedt
2024-11-19 14:24             ` Jean-Michel Hautbois
2024-11-19 15:26               ` Steven Rostedt
2024-11-19 16:28                 ` Steven Rostedt
2024-11-19 16:44                   ` Steven Rostedt
2024-11-19 18:06                   ` Jean-Michel Hautbois
2024-11-19 18:10                     ` Steven Rostedt
2024-11-20 11:47                       ` Jean-Michel Hautbois [this message]
2024-11-19 18:25                     ` Michael Schmitz

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=66e2b7cd-4a4f-4f60-9846-a14c476bd050@yoseli.org \
    --to=jeanmichel.hautbois@yoseli.org \
    --cc=geert@linux-m68k.org \
    --cc=gerg@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.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