From: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
To: Pedro Terra Delboni <terra0009@gmail.com>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: how to collect information regarding function calls in run time?
Date: Tue, 14 May 2019 13:45:58 -0400 [thread overview]
Message-ID: <2216.1557855958@turing-police> (raw)
In-Reply-To: <CAHKDPP8hGP=N_NVpND8AUeUtOCq77Nr6owy-wH9iD_k3tfs=9Q@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 2377 bytes --]
On Tue, 14 May 2019 10:55:40 -0300, Pedro Terra Delboni said:
> Regarding bpftrace: This seemed like the best option since I could use it
> to count frames of the stack with depth 2, allowing me to know precisely
> the amount of times each specific call has been made. However, I could not
> use it because since I have to probe every function, it would raise an
> error related to open file limit. I've tried setting the open file limit to
> unlimited, but the command I used to do so said it was impossible, also the
> current limit is set to 1048576, so I'm guessing that probing every
> function isn't a viable solution.
What problem are you trying to solve?
If you're trying to count how often *every* function is called, and the fact
that one way to do it has an upper limit of a million is a problem, chances are
that you haven't figured out what the *question* is yet.
Usually, the number of calls isn't that important, the total runtime spent in
the function is important. A one-liner inline accessor function that compiles
down to 2-3 machine opcodes can be called tens of thousands of times a second
and not be noticed. A function that takes milliseconds to complete will be
noticed if it's called only a few dozen times a second.
If you're trying to figure out how the functions fit together, a static call
graph analysis tool to produce a map of what calls what may be what you need.
Having said that, a kernel built with gcov or ftrace support will give you the
info you need.
See kernel/gcove/Kconfig and http://heim.ifi.uio.no/~knuto/kernel/4.14/dev-tools/gcov.html
if you want to go that route.
Resources for ftrace call counts:
http://www.brendangregg.com/blog/2014-07-13/linux-ftrace-function-counting.html
https://wiki.linaro.org/KenWerner/Sandbox/ftrace and see section 'function profiler'.
Be prepared for your kernel to be quite slow, and have to do a *lot* of data
reduction.
Note that you'll probably need to run for at least several hours, and of course
the function counts will be *very* dependent on what you do - what gets called
while I'm doing stuff like writing e-mail is very different from what happens
during a kernel compile, and both of those are different from the function
counts that happen when I back up my laptop to an external USB disk.
(Note I've not *tried* any of the above - this laptop is slow enough as it is :)
[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2019-05-14 17:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 19:25 how to collect information regarding function calls in run time? Pedro Terra Delboni
2019-04-03 20:15 ` Bharath Vedartham
[not found] ` <CADFy_4FJODA9gT7Enb+eLt-bdJBkkgTmqhhb3AhJhjibgbzD2A@mail.gmail.com>
2019-05-14 13:55 ` Pedro Terra Delboni
2019-05-14 14:05 ` Greg KH
2019-05-14 14:14 ` Pedro Terra Delboni
2019-05-14 17:45 ` Valdis Klētnieks [this message]
2019-05-14 19:11 ` Pedro Terra Delboni
2019-05-17 14:09 ` Valdis Klētnieks
2019-05-17 16:19 ` Pedro Terra Delboni
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=2216.1557855958@turing-police \
--to=valdis.kletnieks@vt.edu \
--cc=kernelnewbies@kernelnewbies.org \
--cc=terra0009@gmail.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 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.