Bug 163602 - pmcstat(8) doesn't search symbols under /boot/modules
Summary: pmcstat(8) doesn't search symbols under /boot/modules
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-25 01:50 UTC by Jan Beich
Modified: 2018-05-21 00:00 UTC (History)
3 users (show)

See Also:


Attachments
pmcstat_modules.diff (2.30 KB, patch)
2014-01-14 19:44 UTC, Ulf Lilleengen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2011-12-25 01:50:10 UTC
pmcstat(8) should search under /boot/modules by default as that is the
place kernel modules are installed by ports/ framework. It could be
implemented similar to kldload(8) as a semicolon-separated list of paths
to search with default being kern.module_path sysctl.

Fix: 

A known workaround:

  $ cd /boot/kernel
  $ ln -s ../modules/*.ko* .
How-To-Repeat: $ sudo pmcstat -S instructions -O /tmp/all.pmc
^C

$ pmcstat -R /tmp/all.pmc -G all.graph
pmcstat: WARNING: Cannot determine the type of "/boot/kernel/nvidia.ko".
pmcstat: WARNING: Cannot determine the type of "/boot/kernel/uvhid.ko".
pmcstat: WARNING: Cannot determine the type of "unknown".
pmcstat: WARNING: Cannot determine the type of "/usr/local/bin/sudo".
[...]
CONVERSION STATISTICS:
 #exec/elf                                9
 #samples/total                           10915
 #samples/unknown-function                566
 #callchain/dubious-frames                62

$ grep '_nv.*rm' all.graph | sort -rk1 | head
Exit 1
Comment 1 Ulf Lilleengen freebsd_committer freebsd_triage 2014-01-14 19:44:15 UTC
I'm not able to reproduce this at the moment. Any tips on how? Or maybe 
you could test out this patch:

http://people.freebsd.org/~lulf/patches/pmcstat_modules.diff
Comment 2 Jan Beich freebsd_committer freebsd_triage 2015-01-18 14:37:58 UTC
Comment on attachment 120742 [details]
pmcstat_modules.diff

(In reply to Jan Beich from comment #0)
> $ pmcstat -R /tmp/all.pmc -G all.graph
> pmcstat: WARNING: Cannot determine the type of "/boot/kernel/nvidia.ko".

I can't reproduce the warnings, too. After applying the patch all.graph now contains references to nvidia.ko. Also, tested with a few more modules moved from /boot/kernel to /boot/modules.

Thanks.
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2016-03-24 00:55:29 UTC
This also bit us at $work after the `kern.bootfile` check was added to pmcstat in r282643 as loader doesn't keep the file extension for compressed kernels. I think that it would be wiser for `kern.bootfile` to maybe be replaced with `kern.module_path`. jhb: what do you think?
Comment 4 John Baldwin freebsd_committer freebsd_triage 2016-03-25 22:28:47 UTC
To be clear, prior to r282643, pmcstat always used /boot/kernel/kernel no matter what you booted (/boot/foo/kernel, or /boot/kernel/kernel.gz).  OTOH, it's not clear to me why pmcstat needs to do its own manual search in the module path to begin with.  The kernel stores the full path to each module (it's output if you use kldstat -v).  That is what kgdb uses to find module symbols rather than trying to guess by doing its own lookup.

It would be very trivial to fix pmc to export the full path instead.  Just change the hwpmc hook in sys/kern/kern_linker.c to use 'lf->pathname' instead of 'lf->filename'.  pmcstat could then use that path if it exists (or perhaps accept a '--sysroot' type option similar to solib-prefix in gdb for use when doing offline analysis on another machine)
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-21 00:00:10 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"
Comment 6 Eitan Adler freebsd_committer freebsd_triage 2018-05-21 00:00:36 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"