This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, rs6000] Allow libitm to use HTM on newer hw and kernels

Libitm on POWER hardware looks for the "htm" bit in AT_HWCAP2 to determine
whether it can use HTM when executing code within __transaction_atomic
code blocks.  However, on newer hardware and kernels, the "htm" bit is no
longer set and instead the "htm-no-suspend" bit is set, so we currently
don't use HTM on new hw and kernels.  The following patch adds support
for htm-no-suspend to libitm.  I have also added code to use the
__builtin_cpu_supports() builtin if it is available, since that is
much faster than using the getauxval libc call.

This passed bootstrap and regtesting with no errors and someone within
IBM how had a POWER9 box with a newish kernel how ran into the problem
confirmed it works for his test case.

Ok for mainline?  Should be backport this?


	* config/powerpc/target.h (PPC_FEATURE2_HTM_NO_SUSPEND): Conditionally
	(htm_available):  Add support for PPC_FEATURE2_HTM_NO_SUSPEND.
	Use __builtin_cpu_supports if available.

Index: libitm/config/powerpc/target.h
--- libitm/config/powerpc/target.h	(revision 267062)
+++ libitm/config/powerpc/target.h	(working copy)
@@ -26,6 +26,11 @@
 #include <sys/auxv.h>
+/* This is a fairly new feature bit, so handle it not being defined.  */
 namespace GTM HIDDEN {
 typedef int v128 __attribute__((vector_size(16), may_alias, aligned(16)));
@@ -81,7 +86,16 @@ cpu_relax (void)
 static inline bool
 htm_available (void)
-  return (getauxval (AT_HWCAP2) & PPC_FEATURE2_HAS_HTM) ? true : false;
+  if (__builtin_cpu_supports ("htm-no-suspend")
+      || __builtin_cpu_supports ("htm"))
+    return true;
+  if (getauxval (AT_HWCAP2)
+    return true;
+  return false;
 static inline uint32_t

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]