[PATCH] D29742: [XRay] Implement powerpc64le xray.

Tim Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 02:52:11 PST 2017


timshen marked an inline comment as done.
timshen added inline comments.


================
Comment at: compiler-rt/lib/xray/xray_powerpc64.cc:34
+
+uint64_t cycleFrequency() XRAY_NEVER_INSTRUMENT { return NanosecondsPerSecond; }
+
----------------
dberris wrote:
> Just curious -- does ppc not have an equivalent for `rdtscp` instruction in userspace?
> 
> If it does, we should try and use that as well as get the actual cycle frequency in Linux through the various possible means.
It's a good question.

It turns out, Power CPU keeps track of the ticks as well as x86 does, but in a different frequency, not necessarily the CPU clock frequency. The frequency is configurable.

Luckily, glibc exposes two functions to get the frequency as well as the current tick: https://www.gnu.org/software/libc/manual/html_node/PowerPC.html. I think this is exactly what we need.

However, currently the xray_utils.h interfaces are designed in a way to assume the TSC frequency is the same as CPU clock frequency, and every logging module is asking for CPU frequency.

I think a more proper change is to generalize CPU frequency to a "timer frequency" or something, but I'd better do that in a succeeding patch, leaving this patch a bit cleaner. I can check in the frequency change first.


================
Comment at: compiler-rt/lib/xray/xray_utils.cc:175
+// icache invalidation for PPC and ARM.
+#if defined(__APPLE__)
+
----------------
dberris wrote:
> As far as I can tell, we don't build XRay for Mac OS (unless this is being done for other reasons). Will this work just fine without `#if defined(__APPLE__)` here?
Done. I realized that compiler_rt, as well as libgcc, has this __clear_cache function, but they seem to do poorly on the job. I moved the clearCache function into xray_powerpc64.cc and kept powerpc64 case only.


https://reviews.llvm.org/D29742





More information about the llvm-commits mailing list