This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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] PowerPC: Add functions for shared resources hints


PowerPC ISA 2.06 defines a set of hints about the usage of shared processor
resources using the 'or' instruction, also available under the form of the
extended mnemonics 'yield', 'mdoom' and 'mdoio' in newer gnu assembler. This
patch adds builtins for these hints using the 'or' form for compatibility with
older versions of binutils. In older processors that don't support these
instructions, it works like no-ops.

ChangeLog
2012-11-27  Edjunior Machado  <emachado@linux.vnet.ibm.com>

	* sysdeps/powerpc/Makefile: Add test-shared-resources.c.
	* sysdeps/powerpc/sys/platform/ppc.h: Add __ppc_yield(),
	__ppc_mdoio() and __ppc_mdoom().
	* sysdeps/powerpc/test-shared-resources.c: New file.
	* manual/platform.texi: Document new functions __ppc_yield(),
	__ppc_mdoio() and __ppc_mdoom().


---
 manual/platform.texi                    |   24 +++++++++++++++++++++
 sysdeps/powerpc/Makefile                |    2 +-
 sysdeps/powerpc/sys/platform/ppc.h      |   32 +++++++++++++++++++++++++++++
 sysdeps/powerpc/test-shared-resources.c |   34 +++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+), 1 deletions(-)
 create mode 100644 sysdeps/powerpc/test-shared-resources.c

diff --git a/manual/platform.texi b/manual/platform.texi
index e387ff4..64bed33 100644
--- a/manual/platform.texi
+++ b/manual/platform.texi
@@ -34,3 +34,27 @@ This frequency is not related to the processor clock or the bus clock.
 It is also possible that this frequency is not constant.  More information is
 available in @cite{Power ISA 2.06b - Book II - Section 5.2}.
 @end deftypefun
+
+The following functions provide hints about the usage of resources that are
+shared with other processors. They can be used, for example, if a program
+waiting on a lock intends to divert the shared resources to be used by other
+processors. More information is available in @cite{Power ISA 2.06b - Book II -
+Section 3.2}.
+
+@deftypefun {void} __ppc_yield (void)
+Provide a hint that performance will probably be improved if shared resources
+dedicated to the executing processor are released for use by other processors.
+@end deftypefun
+
+@deftypefun {void} __ppc_mdoio (void)
+Provide a hint that performance will probably be improved if shared resources
+dedicated to the executing processor are released until all outstanding storage
+accesses to caching-inhibited storage have been completed.
+@end deftypefun
+
+@deftypefun {void} __ppc_mdoom (void)
+Provide a hint that performance will probably be improved if shared resources
+dedicated to the executing processor are released until all outstanding storage
+accesses to cacheable storage for which the data is not in the cache have been
+completed.
+@end deftypefun
diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile
index 7442b67..57bff99 100644
--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -25,5 +25,5 @@ endif
 
 ifeq ($(subdir),misc)
 sysdep_headers += sys/platform/ppc.h
-tests += test-gettimebase
+tests += test-gettimebase test-shared-resources
 endif
diff --git a/sysdeps/powerpc/sys/platform/ppc.h b/sysdeps/powerpc/sys/platform/ppc.h
index 58948e8..36e74da 100644
--- a/sysdeps/powerpc/sys/platform/ppc.h
+++ b/sysdeps/powerpc/sys/platform/ppc.h
@@ -50,4 +50,36 @@ __ppc_get_timebase (void)
 #endif
 }
 
+/* The following functions provide hints about the usage of shared processor
+   resources, as defined in ISA 2.06 and newer. */
+
+/* Provides a hint that performance will probably be improved if shared
+   resources dedicated to the executing processor are released for use by other
+   processors.  */
+static inline void
+__ppc_yield (void)
+{
+  __asm__ volatile ("or 27,27,27\n");
+}
+
+/* Provides a hint that performance will probably be improved if shared
+   resources dedicated to the executing processor are released until
+   all outstanding storage accesses to caching-inhibited storage have been
+   completed.  */
+static inline void
+__ppc_mdoio (void)
+{
+  __asm__ volatile ("or 29,29,29\n");
+}
+
+/* Provides a hint that performance will probably be improved if shared
+   resources dedicated to the executing processor are released until all
+   outstanding storage accesses to cacheable storage for which the data is not
+   in the cache have been completed.  */
+static inline void
+__ppc_mdoom (void)
+{
+  __asm__ volatile ("or 30,30,30\n");
+}
+
 #endif  /* sys/platform/ppc.h */
diff --git a/sysdeps/powerpc/test-shared-resources.c b/sysdeps/powerpc/test-shared-resources.c
new file mode 100644
index 0000000..f3df4a4
--- /dev/null
+++ b/sysdeps/powerpc/test-shared-resources.c
@@ -0,0 +1,34 @@
+/* Check set of functions related to the shared resources hints.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <inttypes.h>
+#include <stdio.h>
+
+#include <sys/platform/ppc.h>
+
+static int
+do_test (void)
+{
+  __ppc_yield ();
+  __ppc_mdoio ();
+  __ppc_mdoom ();
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
-- 
1.7.1


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