Page MenuHomeFreeBSD

pmcstat: fix PPC kernel symbol resolution
ClosedPublic

Authored by luporl on Aug 18 2020, 7:26 PM.
Referenced Files
Unknown Object (File)
Feb 23 2024, 11:56 AM
Unknown Object (File)
Feb 23 2024, 11:56 AM
Unknown Object (File)
Feb 23 2024, 11:56 AM
Unknown Object (File)
Feb 23 2024, 11:56 AM
Unknown Object (File)
Feb 23 2024, 11:43 AM
Unknown Object (File)
Dec 26 2023, 7:03 PM
Unknown Object (File)
Dec 23 2023, 12:59 AM
Unknown Object (File)
Nov 9 2023, 1:36 AM

Details

Summary

PowerPC kernel is of DYN type and it has a base address where it is initially loaded, before being relocated.
As the start address passed to pmcstat_image_link() is where the kernel was relocated to, but the symbols always use the original base address, we need to subtract it to get the correct offset.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 33095
Build 30467: arc lint + arc unit

Event Timeline

luporl created this revision.

Makes sense to me. Is there a good way to test this?

Additionally, I believe this would also be relevant to ppc32, perhaps use the __powerpc__ ifdef instead.

jhibbits added inline comments.
lib/libpmcstat/libpmcstat_image.c
180

This probably affects all powerpc platforms, not just powerpc64. They're all ET_DYN, and I know on Book-E 32-bit does get relocated.

198

Same down here.

Makes sense to me. Is there a good way to test this?

Additionally, I believe this would also be relevant to ppc32, perhaps use the __powerpc__ ifdef instead.

I've tested it on Talos with D26110, D26111, D26112 and D26113, to collect samples and produce a callgraph:

cd /tmp
dd if=/dev/zero of=ddtmp bs=1m count=2048 &
pmcstat -O sample.out -S INSTR_COMPLETED -l 5
pmcstat -R sample.out -G sample.graph

The dd is to force a predictable kernel load, to know what functions to expect in the output.
Then sample.graph should have symbols resolved correctly and shows tmpfs_write and uiomove_object among functions that spent most time.
(I have /tmp mounted as tmpfs)

You could probably test this on a G5 too, but you'll need D26111 if you start getting panics and D26112 to avoid addresses being truncated to 32-bit.

I can change the #ifdef to __powerpc__, but it would be nice if someone could test it on a PPC32 machine to make sure it works.

luporl retitled this revision from pmcstat: fix PPC64 kernel symbol resolution to pmcstat: fix PPC kernel symbol resolution.
luporl edited the summary of this revision. (Show Details)

Address jhibbits' comments

bdragon set the repository for this revision to rS FreeBSD src repository - subversion.
bdragon added a project: PowerPC.
This revision is now accepted and ready to land.Nov 3 2020, 10:22 PM
This revision was automatically updated to reflect the committed changes.