[Bug 201753] AMD-Vi: Unable to write to IOMMU perf counter

bugzilla-daemon
2021-03-04T00:31:25Z

--- Comment #19 from David Coe (david.coe@live.co.uk) ---
Hi all!

It's a knotty problem: the Ryzen has IOMMU performance counters, but can't tell
you they're working without a (120 msec 2400g, > 200 msec 2200G) delay (not
popular with Paul or Alex). It can assume they are working pro-tem but check
later in the boot sequence (Alex's patch but Suravee has some products that
don't like this). It can assume they aren't working (although they are) and
leave the user-space application to handle the loss of facility (not at all
keen on this myself).

System OEM's will want clean boot interfaces and road-warriors with high-end
laptops hate unnecessary delay when they lift their lids. However, day-to-day
users of virtualisation software like (for example) KDM will notice if IOMMU/Vi
hardware acceleration is present but crippled by the OS (how do the Windows
drivers handle the same issue?). The usual solution for this sort of dilemma, I
think, is to put in a BIOS switch or have a boot command-line option.

The current default is to turn slow-reporting IOMMU performance counters off.
This gives problems later with:

# perf stat -a -e amd_iommu/mem_trans_total/ test
event syntax error: 'amd_iommu/mem_trans_total/'
\___ Cannot find PMU `amd_iommu'. Missing kernel support?

After either Suravee or Alex's patch:

# perf stat -a -e amd_iommu/mem_trans_total/ test
Performance counter stats for 'system wide':
897 amd_iommu/mem_trans_total/
0.000990106 seconds time elapsed

Installation checks for KVM like systool -m kvm_amd -v and kvm-ok then give
expected results about modules and hardware acceleration. In principle, I'm
sorted for the 2400G but repeatedly recompiling the kernel is not a lovely
solution. Very, very appreciative of all attempts to get a generally-acceptable
patch into the distributions!

Best regards

David