bryantcurto
bryantcurto

Reputation: 63

Perf Sampling - Null Physical Address

While sampling memory loads and stores via Perf, I'm attempting to capture the physical address of the memory location accessed. However, I'm finding that many accesses to kernel space (as determined by their associated virtual addresses) have an associated physical address that is null (i.e., 0x0).

Why are these physical addresses null? Is null reported because the physical address could not be determined? If null is the valid physical address, what does a physical address of null mean?

An easy way to observe this is to run the following:

sudo perf record -e mem_uops_retired.all_loads:p --count 1000 --data --phys-data timeout 2 yes
sudo perf report -i perf.data -D | grep -A2 PERF_RECORD_SAMPLE | grep phys_addr | sort | uniq -c | sort -n

I'm seeing the following:

...
   2765  .. phys_addr: 0x100e849b8
   3204  .. phys_addr: 0x10c553478
   3588  .. phys_addr: 0x10c553480
   4148  .. phys_addr: 0x10c5534a8
 135328  .. phys_addr: 0x0

I'm running on Ubuntu v20.04.1 with Intel Xeon CPU D-1540.

Upvotes: 0

Views: 220

Answers (1)

bryantcurto
bryantcurto

Reputation: 63

Looking at the notes associated with the patch introducing physical address sampling:

For kernel direct mapping addresses, the patch uses virt_to_phys to convert the virtual addresses from DLA to physical address. For user virtual addresses, __get_user_pages_fast is used to walk the pages tables for user physical address. This does not work for vmalloc addresses. Right now these are not resolved, but code to do that could be added.

Checking the Linux source, the physical address of a vmalloc address still cannot be determined (at the time of this posting). Instead, the physical address returned is null (i.e., 0).

Upvotes: 1

Related Questions