Skip to content

[BUG] Multiple PerfCountersTest failures with counter.num_counters() zero on some s390x systems #2174

@musicinmybrain

Description

@musicinmybrain

Describe the bug
While looking at enabling libpfm support in Fedora’s google-benchmark package, we’ve found that multiple tests withing PerfCountersTest fail on our s390x build systems with counter.num_counters() zero after the tests have asked for INSTRUCTIONS and/or CYCLES counters and expected them to be successfully configured.

I think this might just reflect libpfm not supporting the platform all that well. PerfCounters::kSupported is true, because we compiled with libfpm (BENCHMARK_ENABLE_LIBPFM:BOOL=ON), but CYCLES and INSTRUCTIONS counters aren’t supported in practice on these particular systems. Looking at https://sourceforge.net/p/perfmon2/libpfm4/merge-requests/?status=open and reading the actual texts of relevant merge requests, it seems like this should work on z13 but maybe not z14. The machines in Fedora’s infrastructure are (mostly or all) machine type 3931, which is z16.

System
Which OS, compiler, and compiler version are you using:

  • OS: Fedora Rawhide, s390x
  • Compiler and version: gcc (GCC) 16.0.1 20260416 (Red Hat 16.0.1-0)

To reproduce

Build the library with -DBENCHMARK_ENABLE_LIBPFM:BOOL=ON, and run the test suite (in particular, perf_counters_test), on an s390x host.

I conjecture, based on libpfm upstream merge requests, that this should fail on s390x hosts that are z14 or later, but may succeed on those that are z13. I don’t have a good way to verify this claim.

I can also reproduce this in a mock chroot, emulating s390x on an x86_64 host via qemu-user-static.

Expected behavior
All tests pass.

Screenshots

78/84 Test #79: perf_counters_gtest ........................***Failed    0.05 sec
Running main() from gmock_main.cc
[==========] Running 9 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 9 tests from PerfCountersTest
[ RUN      ] PerfCountersTest.Init
[       OK ] PerfCountersTest.Init (0 ms)
[ RUN      ] PerfCountersTest.OneCounter
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:35: Failure
Expected equality of these values:
  PerfCounters::Create({kGenericPerfEvent1}).num_counters()
    Which is: 0
  1
[  FAILED  ] PerfCountersTest.OneCounter (0 ms)
[ RUN      ] PerfCountersTest.NegativeTest
A performance counter name was the empty string
Unknown performance counter name: not a counter name
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
A performance counter name was the empty string
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:56: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  2
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:57: Failure
Expected equality of these values:
  counter.names()
    Which is: {}
  std::vector<std::string>( {kGenericPerfEvent2, kGenericPerfEvent1})
    Which is: { "INSTRUCTIONS", "CYCLES" }
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
Unknown performance counter name: not a counter name
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:64: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  2
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:65: Failure
Expected equality of these values:
  counter.names()
    Which is: {}
  std::vector<std::string>( {kGenericPerfEvent2, kGenericPerfEvent1})
    Which is: { "INSTRUCTIONS", "CYCLES" }
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:70: Failure
Expected equality of these values:
  PerfCounters::Create({kGenericPerfEvent1, kGenericPerfEvent2}) .num_counters()
    Which is: 0
  2
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
Unknown performance counter name: bad event name
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:78: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  2
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:79: Failure
Expected equality of these values:
  counter.names()
    Which is: {}
  std::vector<std::string>( {kGenericPerfEvent1, kGenericPerfEvent2})
    Which is: { "CYCLES", "INSTRUCTIONS" }
[  FAILED  ] PerfCountersTest.NegativeTest (0 ms)
[ RUN      ] PerfCountersTest.Read1Counter
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:90: Failure
Expected equality of these values:
  counters.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:97: Failure
Expected: (values2[0]) > (values1[0]), actual: 4396356672224 vs 4397072344808
[  FAILED  ] PerfCountersTest.Read1Counter (0 ms)
[ RUN      ] PerfCountersTest.Read2Counters
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:107: Failure
Expected equality of these values:
  counters.num_counters()
    Which is: 0
  2
[  FAILED  ] PerfCountersTest.Read2Counters (0 ms)
[ RUN      ] PerfCountersTest.ReopenExistingCounters
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
[       OK ] PerfCountersTest.ReopenExistingCounters (0 ms)
[ RUN      ] PerfCountersTest.CreateExistingMeasurements
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
/builddir/build/BUILD/google-benchmark-1.9.5-build/benchmark-1.9.5/test/perf_counters_gtest.cc:174: Failure
Expected equality of these values:
  counter.num_counters()
    Which is: 0
  1
[  FAILED  ] PerfCountersTest.CreateExistingMeasurements (0 ms)
[ RUN      ] PerfCountersTest.MultiThreaded
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
***WARNING** Failed to get a file descriptor for performance counter CYCLES. Ignoring
***WARNING** Failed to get a file descriptor for performance counter INSTRUCTIONS. Ignoring
[       OK ] PerfCountersTest.MultiThreaded (48 ms)
[ RUN      ] PerfCountersTest.HardwareLimits
***WARNING** Failed to get a file descriptor for performance counter cycles. Ignoring
***WARNING** Failed to get a file descriptor for performance counter instructions. Ignoring
***WARNING** Failed to get a file descriptor for performance counter branch-misses. Ignoring
[       OK ] PerfCountersTest.HardwareLimits (0 ms)
[----------] 9 tests from PerfCountersTest (49 ms total)
[----------] Global test environment tear-down
[==========] 9 tests from 1 test suite ran. (49 ms total)
[  PASSED  ] 4 tests.
[  FAILED  ] 5 tests, listed below:
[  FAILED  ] PerfCountersTest.OneCounter
[  FAILED  ] PerfCountersTest.NegativeTest
[  FAILED  ] PerfCountersTest.Read1Counter
[  FAILED  ] PerfCountersTest.Read2Counters
[  FAILED  ] PerfCountersTest.CreateExistingMeasurements
 5 FAILED TESTS

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions