kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: "Billie Alsup (balsup)" <balsup@cisco.com>
To: Dawei Li <daweilics@gmail.com>
Cc: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>,
	"kernelnewbies@kernelnewbies.org"
	<kernelnewbies@kernelnewbies.org>
Subject: Re: when/how is the schedule() function actually called?
Date: Thu, 14 Dec 2023 17:13:37 +0000	[thread overview]
Message-ID: <BYAPR11MB35275E57925910C54988DB37D98CA@BYAPR11MB3527.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAG5MgCrRx6YKXTc-Yv=0rjCBXpU2ARSq-meJEtw9iGzHbOGxgw@mail.gmail.com>


> But I don't see any code that is calling the schedule or __schedule function.

I think with a little investigation, you will be able to figure it out.  For example, arch/x86/entry/common.c
in function do_syscall_64 calls syscall_entr_from_user_mode and syscall_exit_to_user_mode.   I could guess
we eventually reach exit_to_user_mode_loop, which will conditionally call schedule() which calls __schedule
(although I didn't investigate this chain, so am just guessing).

I'm a newbie to this stuff as well, but it is not too difficult to follow this.  I would guess there are
IDEs available that can help you with diagramming the flow if you don't want to manually find things
one layer at a time.  The Documentation folder also has a lot of good information.  For example,
Documentation/trace/histogram.rst shows some backtraces with __schedule, and you can see
examples of how it is called from do_syscall_64 and ret_from_fork.  Other traces are available in
Documentation/trace/ftrace.rst

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

  reply	other threads:[~2023-12-14 17:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 16:16 when/how is the schedule() function actually called? Dawei Li
2023-12-08 17:44 ` Valdis Klētnieks
2023-12-08 18:21   ` Dawei Li
2023-12-08 19:10     ` Billie Alsup (balsup)
2023-12-10 16:59       ` Dawei Li
2023-12-14 17:13         ` Billie Alsup (balsup) [this message]
2023-12-08 19:47     ` iso m

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=BYAPR11MB35275E57925910C54988DB37D98CA@BYAPR11MB3527.namprd11.prod.outlook.com \
    --to=balsup@cisco.com \
    --cc=daweilics@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=valdis.kletnieks@vt.edu \
    /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;
as well as URLs for NNTP newsgroup(s).