This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Unset HAVE_LIBPFM if the kernel is too old.
ClosedPublic

Authored by oontvoo on Jul 17 2020, 4:10 PM.

Diff Detail

Event Timeline

oontvoo created this revision.Jul 17 2020, 4:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2020, 4:10 PM
mgorny requested changes to this revision.Jul 17 2020, 7:36 PM

You shouldn't be checking the running kernel but the version of the kernel headers. Think of build hosts building LLVM for an entirely different system altogether.

This revision now requires changes to proceed.Jul 17 2020, 7:36 PM

You shouldn't be checking the running kernel but the version of the kernel headers. Think of build hosts building LLVM for an entirely different system altogether.

To add to that, you shouldn't hardcode version, but instead check that the problematic field is present or not.
And, i'm not sure this is a good idea. If the kernel is too old, i'd suggest only disabling the functionality
that wants that new field, not the entire libpfm

oontvoo updated this revision to Diff 280015.Jul 22 2020, 8:18 PM

Use Cmake's CheckStructHasMember to check for cycles field.

You shouldn't be checking the running kernel but the version of the kernel headers. Think of build hosts building LLVM for an entirely different system altogether.

To add to that, you shouldn't hardcode version, but instead check that the problematic field is present or not.
And, i'm not sure this is a good idea. If the kernel is too old, i'd suggest only disabling the functionality
that wants that new field, not the entire libpfm

Good point! I've updated the cmake file to look for the field and set a new flag accordingly
Thanks!

Did you forget to include a patch that uses LIBPFM_HAS_FIELD_CYCLES?

Did you forget to include a patch that uses LIBPFM_HAS_FIELD_CYCLES?

No, actually. The patch that uses it is D77422
I was planning on letting this one go in first, then rebase the other one.

oontvoo updated this revision to Diff 280262.Jul 23 2020, 2:35 PM

CheckStructHasMember didn't work (because cycles is a bit field) so updated it to just compile a small program that accesses .cycles.

ondrasej added inline comments.Jul 23 2020, 11:36 PM
llvm/cmake/modules/FindLibpfm.cmake
20

the field 'cycles'.

21

I'd finish the sentence with something like '...because 'cycles' is a bit field which is not supported by CheckStructHasMember.'

23

In https://reviews.llvm.org/D77422, we're including perfmon/perf_event.h, we should use the same header in both places.

29

Nit: Consider indenting the C++ source (two spaces more than CHECK_CXX_SOURCE_COMPILES), or moving it into a variable so that it doesn't break the indentation of the CMake code.

llvm/include/llvm/Config/config.h.cmake
100 ↗(On Diff #280262)
  1. Remove one space between 'struct' and 'has'.
  2. Add a period at the end of the sentence.
  3. ...the 'perf_branch_entry' struct... (to be consistent with using apostrophes for names in the rest of this file).
oontvoo updated this revision to Diff 280477.Jul 24 2020, 8:58 AM
oontvoo marked 5 inline comments as done.

Updated diff

ondrasej added inline comments.Jul 24 2020, 9:10 AM
llvm/cmake/modules/FindLibpfm.cmake
20

Nit: cycles (the field name is in plural)

oontvoo updated this revision to Diff 280499.Jul 24 2020, 9:36 AM
oontvoo marked an inline comment as done.

'cycle' -> 'cycles'

mgorny resigned from this revision.Jul 24 2020, 9:47 AM

I'll remove my earlier protest but let's give others a chance to review.

gchatelet accepted this revision.Jul 27 2020, 2:35 AM
This revision is now accepted and ready to land.Jul 27 2020, 2:35 AM
This revision was automatically updated to reflect the committed changes.