Blame SOURCES/glibc-rh731833-misc-4.patch

147e83
This is a combination of two commits:
147e83
147e83
From 42b373ad467ba426610a358d90034bcf68abb15f Mon Sep 17 00:00:00 2001
147e83
From: Edjunior Machado <emachado@linux.vnet.ibm.com>
147e83
Date: Thu, 23 May 2013 10:06:24 -0500
147e83
Subject: [PATCH 31/42] PowerPC: Add functions for shared resources hints.
147e83
 (cherry picked from commit
147e83
 9323d39baea2fb0cca3735136abe263eff405133)
147e83
147e83
From a6d45052042c1fc962523633c0489634864e1a02 Mon Sep 17 00:00:00 2001
147e83
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
147e83
Date: Fri, 24 May 2013 13:29:30 -0500
147e83
Subject: [PATCH 32/42] PowerPC: Program Priority Register support
147e83
147e83
This patch add inline functions to change the Program Priority Register
147e83
from ISA 2.05.
147e83
(cherry picked from commit d116b7c414c8239b677e341ac517745db689ac2d)
147e83
147e83
diff -pruN glibc-2.17-c758a686/manual/platform.texi glibc-2.17-c758a686/manual/platform.texi
147e83
--- glibc-2.17-c758a686/manual/platform.texi	2012-12-25 08:32:13.000000000 +0530
147e83
+++ glibc-2.17-c758a686/manual/platform.texi	2013-08-05 19:06:49.523550318 +0530
147e83
@@ -34,3 +34,48 @@ This frequency is not related to the pro
147e83
 It is also possible that this frequency is not constant.  More information is
147e83
 available in @cite{Power ISA 2.06b - Book II - Section 5.2}.
147e83
 @end deftypefun
147e83
+
147e83
+The following functions provide hints about the usage of resources that are
147e83
+shared with other processors.  They can be used, for example, if a program
147e83
+waiting on a lock intends to divert the shared resources to be used by other
147e83
+processors.  More information is available in @cite{Power ISA 2.06b - Book II -
147e83
+Section 3.2}.
147e83
+
147e83
+@deftypefun {void} __ppc_yield (void)
147e83
+Provide a hint that performance will probably be improved if shared resources
147e83
+dedicated to the executing processor are released for use by other processors.
147e83
+@end deftypefun
147e83
+
147e83
+@deftypefun {void} __ppc_mdoio (void)
147e83
+Provide a hint that performance will probably be improved if shared resources
147e83
+dedicated to the executing processor are released until all outstanding storage
147e83
+accesses to caching-inhibited storage have been completed.
147e83
+@end deftypefun
147e83
+
147e83
+@deftypefun {void} __ppc_mdoom (void)
147e83
+Provide a hint that performance will probably be improved if shared resources
147e83
+dedicated to the executing processor are released until all outstanding storage
147e83
+accesses to cacheable storage for which the data is not in the cache have been
147e83
+completed.
147e83
+@end deftypefun
147e83
+
147e83
+@deftypefun {void} __ppc_set_ppr_med (void)
147e83
+Set the Program Priority Register to medium value (default).
147e83
+
147e83
+The @dfn{Program Priority Register} (PPR) is a 64-bit register that controls
147e83
+the program's priority.  By adjusting the PPR value the programmer may
147e83
+improve system throughput by causing the system resources to be used
147e83
+more efficiently, especially in contention situations.
147e83
+The three unprivileged states available are covered by the functions
147e83
+@code{__ppc_set_ppr_med} (medium -- default), @code{__ppc_set_ppc_low} (low)
147e83
+and @code{__ppc_set_ppc_med_low} (medium low).  More information
147e83
+available in @cite{Power ISA 2.06b - Book II - Section 3.1}.
147e83
+@end deftypefun
147e83
+
147e83
+@deftypefun {void} __ppc_set_ppr_low (void)
147e83
+Set the Program Priority Register to low value.
147e83
+@end deftypefun
147e83
+
147e83
+@deftypefun {void} __ppc_set_ppr_med_low (void)
147e83
+Set the Program Priority Register to medium low value.
147e83
+@end deftypefun
147e83
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/sys/platform/ppc.h glibc-2.17-c758a686/sysdeps/powerpc/sys/platform/ppc.h
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/sys/platform/ppc.h	2012-12-25 08:32:13.000000000 +0530
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/sys/platform/ppc.h	2013-08-05 19:06:49.523550318 +0530
147e83
@@ -50,4 +50,66 @@ __ppc_get_timebase (void)
147e83
 #endif
147e83
 }
147e83
 
147e83
+/* The following functions provide hints about the usage of shared processor
147e83
+   resources, as defined in ISA 2.06 and newer. */
147e83
+
147e83
+/* Provides a hint that performance will probably be improved if shared
147e83
+   resources dedicated to the executing processor are released for use by other
147e83
+   processors.  */
147e83
+static inline void
147e83
+__ppc_yield (void)
147e83
+{
147e83
+  __asm__ volatile ("or 27,27,27");
147e83
+}
147e83
+
147e83
+/* Provides a hint that performance will probably be improved if shared
147e83
+   resources dedicated to the executing processor are released until
147e83
+   all outstanding storage accesses to caching-inhibited storage have been
147e83
+   completed.  */
147e83
+static inline void
147e83
+__ppc_mdoio (void)
147e83
+{
147e83
+  __asm__ volatile ("or 29,29,29");
147e83
+}
147e83
+
147e83
+/* Provides a hint that performance will probably be improved if shared
147e83
+   resources dedicated to the executing processor are released until all
147e83
+   outstanding storage accesses to cacheable storage for which the data is not
147e83
+   in the cache have been completed.  */
147e83
+static inline void
147e83
+__ppc_mdoom (void)
147e83
+{
147e83
+  __asm__ volatile ("or 30,30,30");
147e83
+}
147e83
+
147e83
+
147e83
+/* ISA 2.05 and beyond support the Program Priority Register (PPR) to adjust
147e83
+   thread priorities based on lock acquisition, wait and release. The ISA
147e83
+   defines the use of form 'or Rx,Rx,Rx' as the way to modify the PRI field.
147e83
+   The unprivileged priorities are:
147e83
+     Rx = 1 (low)
147e83
+     Rx = 2 (medium)
147e83
+     Rx = 6 (medium-low/normal)
147e83
+   The 'or' instruction form is a nop in previous hardware, so it is safe to
147e83
+   use unguarded. The default value is 'medium'.
147e83
+ */
147e83
+
147e83
+static inline void
147e83
+__ppc_set_ppr_med (void)
147e83
+{
147e83
+  __asm__ volatile ("or 2,2,2");
147e83
+}
147e83
+
147e83
+static inline void
147e83
+__ppc_set_ppr_med_low (void)
147e83
+{
147e83
+  __asm__ volatile ("or 6,6,6");
147e83
+}
147e83
+
147e83
+static inline void
147e83
+__ppc_set_ppr_low (void)
147e83
+{
147e83
+  __asm__ volatile ("or 1,1,1");
147e83
+}
147e83
+
147e83
 #endif  /* sys/platform/ppc.h */