kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Using printk, how can I know where the kernel jumps after schedule() function?
@ 2022-08-26 10:04 Chan Kim
  2022-10-08 20:43 ` Fabio M. De Francesco
  0 siblings, 1 reply; 2+ messages in thread
From: Chan Kim @ 2022-08-26 10:04 UTC (permalink / raw)
  To: kernelnewbies

Hello experts,

I am faced with a problem on my experiment. (arm64)
When the linux kernel boots and after it jumped to /bin/sh in the initramfs
(by busybox), it hangs after the program jumps the schedule() function.
I can see it comes out of schedule() function using printk, but I don't know
where it had gone(or returned).
I tried printing the bottom two values in the schedule() function, because
the x29(=fp) and x30(=lr) is stored at the stack bottom during any function.
But the lr value is somewhere in then init stack(by examining the
System.map). So I guessed that lr value, a virtual address is a user virtual
address.. Is my guess correct or should the lr value point to a point in
kernel text section?

Actually I don't know exactly  how a user program is interrupted by the
schedule function initiated by the timer interrupt so I would be grateful if
someone explain it.
( I tried reading part of a book or web posts but didn't get what I want
yet). 

Thank you!
Regards,

Chan Kim





_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Using printk, how can I know where the kernel jumps after schedule() function?
  2022-08-26 10:04 Using printk, how can I know where the kernel jumps after schedule() function? Chan Kim
@ 2022-10-08 20:43 ` Fabio M. De Francesco
  0 siblings, 0 replies; 2+ messages in thread
From: Fabio M. De Francesco @ 2022-10-08 20:43 UTC (permalink / raw)
  To: kernelnewbies; +Cc: Chan Kim

On Friday, August 26, 2022 12:04:41 PM CEST Chan Kim wrote:
> Hello experts,
> 
> I am faced with a problem on my experiment. (arm64)
> When the linux kernel boots and after it jumped to /bin/sh in the initramfs
> (by busybox), it hangs after the program jumps the schedule() function.
> I can see it comes out of schedule() function using printk, but I don't know
> where it had gone(or returned).
> I tried printing the bottom two values in the schedule() function, because
> the x29(=fp) and x30(=lr) is stored at the stack bottom during any function.
> But the lr value is somewhere in then init stack(by examining the
> System.map). So I guessed that lr value, a virtual address is a user virtual
> address.. Is my guess correct or should the lr value point to a point in
> kernel text section?
> 
> Actually I don't know exactly  how a user program is interrupted by the
> schedule function initiated by the timer interrupt so I would be grateful if
> someone explain it.
> ( I tried reading part of a book or web posts but didn't get what I want
> yet). 
> 
> Thank you!
> Regards,
> 
> Chan Kim
> 
I suppose that "ftrace" is your best friend in this case.

YouTube videos may be the easiest introductions. I have not the links to 
provide, however you may search them using something like the "ftrace Steven 
Rostedt" keywords (Steven is the author and maintainer).

Otherwise read the man pages of the "trace-cmd" set of related userspace 
programs built with the purpose to serve as interfaces to the kernel "ftrace".

In case you need more, you'll have to learn how ftrace actually works and how 
to write your custom tracers in the kernel. If so, you have no other choice 
than learning from the official docs at https://docs.kernel.org/trace/
index.html.

Regards,

Fabio




_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-08 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 10:04 Using printk, how can I know where the kernel jumps after schedule() function? Chan Kim
2022-10-08 20:43 ` Fabio M. De Francesco

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 NNTP newsgroup(s).