pcm icon indicating copy to clipboard operation
pcm copied to clipboard

Avoid using the hard-coded /usr/share/pcm/ path

Open amosawi9999 opened this issue 2 years ago • 9 comments

When running pcm-iio for monitoring PCIe bandwidth, tool says that detected IceLake-SP processors but doesn't have proper event file :

Detected Intel(R) Xeon(R) Silver 4310 CPU @ 2.10GHz "Intel(r) microarchitecture codename Icelake-SP" stepping 6 microcode level 0xd000375
Error info:event file opCode-106.txt or /usr/share/pcm/opCode-106.txt is not available. Copy it from PCM build directory.
Event configure file have the problem and cause the program exit, please double check it!

building from master branch, also copied opCode-106 to /usr/local/share/pcm but problem still exists.

some basic tools such pcm, pcm-memory, pcm-numa, pcm-pcie are working, but pcm-iio doesn't work.

amosawi9999 avatar Dec 16 '22 11:12 amosawi9999

thanks for reporting this issue. We had seen a similar one (introduced in the recent version) and which will be fixed in the next release. Could you please try the previous release: https://github.com/intel/pcm/releases/tag/202210

rdementi avatar Dec 16 '22 13:12 rdementi

It works fine, thanks for quick reply

amosawi9999 avatar Dec 16 '22 14:12 amosawi9999

another problem, pcm-iio running fine when executed from the build directory, but not when running from /usr/share/sbin/, seems that install script dont copy the opCode-* to /usr/share/pcm/, they're present in /usr/local/share/pcm but pcm-iio only looks for /usr/share/pcm. PS: is there any option to only show counters for specific socket/device not all of them?!

amosawi9999 avatar Dec 16 '22 15:12 amosawi9999

std::ifstream in(fn);
std::string line, item;
if (!in.is_open())
{
    const auto alt_fn = std::string("/usr/share/pcm/") + fn;
    in.open(alt_fn);
    if (!in.is_open())

The code looks in the current directory first, fn is only a file name, then in /usr/share/pcm/. This should be made configurable based on cmake parameters or enforced by the cmake magic to always install in this /usr/share/pcm directory. User should have last say so I think it should become configurable. Perhaps @markovamaria can make this change?

ogbrugge avatar Dec 16 '22 18:12 ogbrugge

This might be tricky because of rpm build process that need a custom ${CMAKE_INSTALL_PREFIX} during the rpm build process. For example: https://build.opensuse.org/package/live_build_log/home:opcm/OPCM/openSUSE_Leap_15.1/x86_64

When the rpm is installed pcm files should end up in /usr/share/pcm . For rpm the ${CMAKE_INSTALL_PREFIX} and the final location differ...

rdementi avatar Dec 19 '22 08:12 rdementi

Yes for this there is BUILDROOT, cmake has support for this and the rpm need to mention that it want to use BUILDROOT during building.

ogbrugge avatar Dec 19 '22 11:12 ogbrugge

Yes for this there is BUILDROOT, cmake has support for this and the rpm need to mention that it want to use BUILDROOT during building.

good to know. I would like to see how this works.

rdementi avatar Dec 19 '22 11:12 rdementi

https://stackoverflow.com/questions/8084796/what-actually-is-rpm-build-root The first answer explains it pretty well what the purpose of the rpm build root is.

cmake also supports DESTDIR With this you can retarget the installation path during building for packaging

make install DESTDIR=/my/special/buildroot/

and now everything will be installed using that as base root. The opCodeXYZ.txt fille will end up under /my/special/buildroot/usr/share/pcm/opCodeXYZ.txt. Buildroot set to this path in the SPEC file will cause this path to be added as base path for all files directives.

A normal installation can use / for DESTDIR and it all ends up where it was meant to go.

A BuildRoot like this "BuildRoot: %{_tmppath}/%{name}-buildroot-%{version}-%{release}" as proposed by MarkHu is good practise. It might be that SUSE, RedHat or Fedora defines its own BuildRoot in the default rpmrc file but the SPEC file overrides it anyway and does no harm, iirc it is cleaned up anyway after building.

ogbrugge avatar Dec 19 '22 12:12 ogbrugge

ok. Then we could pass ${CMAKE_INSTALL_PREFIX} to cpp with -D parameter and use it instead of the hard-coded path prefix and use make install DESTDIR during the rpm build.

rdementi avatar Dec 19 '22 13:12 rdementi