[llvm-bugs] [Bug 40377] New: Improve comments about __builtin_readcyclecounter

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 18 17:10:30 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40377

            Bug ID: 40377
           Summary: Improve comments about __builtin_readcyclecounter
           Product: Documentation
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: General docs
          Assignee: unassignedbugs at nondot.org
          Reporter: pgut001 at cs.auckland.ac.nz
                CC: llvm-bugs at lists.llvm.org

The documentation currently says:

  Note that even if present, its use may depend on run-time privilege or other
  OS controlled state.

but this is somewhat misleading in terms of indicating how risky use of
__builtin_readcyclecounter is on non-x86 systems.  That is, it's technically
accurate, but doesn't convey how bad the situation really is.  For example on
ARM systems access to the Performance Monitoring Unit (PMU) is privileged,
which means that any use of __builtin_readcyclecounter will lead to an illegal
instruction trap (unless a custom kernel patch is applied to allow user-space
access or some similar measure is taken).  The current note doesn't really
convey this, it just says "this might not work in some cases" when, at least in
the case of ARM CPUs, it's guaranteed to fail.  I would suggest amending the
wording to something like:

  On non-x86 systems, use of __builtin_readcyclecounter is often dependent on
  runtime privilege, and may lead to protection or instruction faults if
  called from non-kernel-mode code.  It is recommended that the usability of
  this intrinsic be evaluated in a small test program before using it in
  actual code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190119/f8a5797f/attachment.html>


More information about the llvm-bugs mailing list