This is an archive of the discontinued LLVM Phabricator instance.

[XRay] Probe for CPU features that XRay needs
ClosedPublic

Authored by dberris on Feb 1 2017, 8:27 PM.

Details

Summary

In llvm.org/PR31756 it's pointed out that sometimes rdtscp isn't
available. We fix it here by checking first whether it's availble before
installing the logging handler. In future commits we can have
alternative implementations, maybe working around some of the
constraints on some systems.

This change enables us to make that determination, but report an error
instead when the features aren't available.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris created this revision.Feb 1 2017, 8:27 PM

Nitpick (user-first): When false, the user will only see "Some CPU features are missing", not which ones. I'd do another Report in the amd64 function specifically bragging about RDTSCP. Most of these will be because of people running in too-restrictive VMs and will be resolved by "d'oh!" and fixing the support.

dberris updated this revision to Diff 86770.Feb 1 2017, 11:30 PM
  • Add more specific logging for probing errors.

Nitpick (user-first): When false, the user will only see "Some CPU features are missing", not which ones. I'd do another Report in the amd64 function specifically bragging about RDTSCP. Most of these will be because of people running in too-restrictive VMs and will be resolved by "d'oh!" and fixing the support.

All good, that's a good idea anyway. I've made a change, PTAL?

pelikan accepted this revision.Feb 1 2017, 11:59 PM

LGTM.

This revision is now accepted and ready to land.Feb 1 2017, 11:59 PM
This revision was automatically updated to reflect the committed changes.
jbulow added a subscriber: jbulow.Oct 9 2017, 5:40 AM

probeRequiredCPUFeatures does not detect rdtscp correctly.

compiler-rt/trunk/lib/xray/xray_x86_64.cc
211–213

1u<<26 == 0x4000000

Changing 26 to 27 solves this problem when running with xray enabled:

==20069==Missing rdtscp support.
dberris marked an inline comment as done.Oct 10 2017, 5:44 AM
dberris added inline comments.
compiler-rt/trunk/lib/xray/xray_x86_64.cc
211–213

Oh wow, that's embarrassing! Good catch, thanks @jbulow!