From: Peter Bergner <bergner@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, rs6000] Allow libitm to use HTM on newer hw and kernels
Date: Wed, 12 Dec 2018 19:47:00 -0000 [thread overview]
Message-ID: <c1a8493b-860f-8a24-53c9-80eca6c4c916@linux.ibm.com> (raw)
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?
Peter
* config/powerpc/target.h (PPC_FEATURE2_HTM_NO_SUSPEND): Conditionally
define.
(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>
#endif
+/* This is a fairly new feature bit, so handle it not being defined. */
+#ifndef PPC_FEATURE2_HTM_NO_SUSPEND
+# define PPC_FEATURE2_HTM_NO_SUSPEND 0
+#endif
+
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;
+#ifdef __BUILTIN_CPU_SUPPORTS__
+ if (__builtin_cpu_supports ("htm-no-suspend")
+ || __builtin_cpu_supports ("htm"))
+ return true;
+#else
+ if (getauxval (AT_HWCAP2)
+ & (PPC_FEATURE2_HAS_HTM | PPC_FEATURE2_HTM_NO_SUSPEND))
+ return true;
+#endif
+ return false;
}
static inline uint32_t
next reply other threads:[~2018-12-12 19:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 19:47 Peter Bergner [this message]
2018-12-12 20:52 ` Segher Boessenkool
2018-12-13 0:55 ` Peter Bergner
2018-12-13 11:12 ` Segher Boessenkool
2018-12-13 16:42 ` Peter Bergner
2018-12-13 18:11 ` Peter Bergner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1a8493b-860f-8a24-53c9-80eca6c4c916@linux.ibm.com \
--to=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).