Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.97 KB | None | 0 0
  1. commit b5b6c6b1f3d9d274428f7e69c8d491caaac3c7d0
  2. Author: Breno Leitao <breno.leitao@gmail.com>
  3. Date:   Wed Jun 21 17:01:33 2017 -0400
  4.  
  5.     powerpc/kernel: Disassociate FP and VEC laziness
  6.    
  7.     Currently, if an application only uses FP, then VEC registers will
  8.     continue to be saved and loaded on context switches independently if
  9.     they are being used or not.
  10.    
  11.     This change disassociate both of them, i.e, stop restoring VEC if it is
  12.     not used. The same thing for FP (if only VEC is being used).
  13.    
  14.     In order to do so, we are relaying on load_vec and load_fp, if they
  15.     overflow to zero, we stop restoring the registers until an exception
  16.     happens and load_{fp,vec} become positive again.
  17.    
  18.     Signed-off-by: Breno Leitao <leitao@debian.org>
  19.     Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
  20.  
  21. diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
  22. index 5d6af58270e6..9a4bd01094ef 100644
  23. --- a/arch/powerpc/kernel/process.c
  24. +++ b/arch/powerpc/kernel/process.c
  25. @@ -243,8 +243,6 @@ static int restore_fp(struct task_struct *tsk) { return 0; }
  26.  #endif /* CONFIG_PPC_FPU */
  27.  
  28.  #ifdef CONFIG_ALTIVEC
  29. -#define loadvec(thr) ((thr).load_vec)
  30. -
  31.  static void __giveup_altivec(struct task_struct *tsk)
  32.  {
  33.     unsigned long msr;
  34. @@ -323,7 +321,6 @@ static int restore_altivec(struct task_struct *tsk)
  35.     return 0;
  36.  }
  37.  #else
  38. -#define loadvec(thr) 0
  39.  static inline int restore_altivec(struct task_struct *tsk) { return 0; }
  40.  #endif /* CONFIG_ALTIVEC */
  41.  
  42. @@ -506,9 +503,16 @@ EXPORT_SYMBOL(giveup_all);
  43.  void restore_math(struct pt_regs *regs)
  44.  {
  45.     unsigned long msr;
  46. +   u8 load_fp = current->thread.load_fp;
  47. +   u8 load_vec = current->thread.load_vec;
  48.  
  49. -   if (!msr_tm_active(regs->msr) &&
  50. -       !current->thread.load_fp && !loadvec(current->thread))
  51. +   /* If in TM mode, force restore of vec and fp.
  52. +    * If not in TM and !load_vec and !load_fp, return now
  53. +    */
  54. +   if (msr_tm_active(regs->msr)) {
  55. +       load_vec = 1;
  56. +       load_fp = 1;
  57. +   } else if (!load_fp && !load_vec)
  58.         return;
  59.  
  60.     msr = regs->msr;
  61. @@ -518,10 +522,10 @@ void restore_math(struct pt_regs *regs)
  62.      * Only reload if the bit is not set in the user MSR, the bit BEING set
  63.      * indicates that the registers are hot
  64.      */
  65. -   if ((!(msr & MSR_FP)) && restore_fp(current))
  66. +   if (load_fp && (!(msr & MSR_FP)) && restore_fp(current))
  67.         msr |= MSR_FP | current->thread.fpexc_mode;
  68.  
  69. -   if ((!(msr & MSR_VEC)) && restore_altivec(current))
  70. +   if (load_vec && (!(msr & MSR_VEC)) && restore_altivec(current))
  71.         msr |= MSR_VEC;
  72.  
  73.     if ((msr & (MSR_FP | MSR_VEC)) == (MSR_FP | MSR_VEC) &&
  74.  
  75. commit 4055dd873df463db78461fda8849b4e07076f1ee
  76. Author: Breno Leitao <breno.leitao@gmail.com>
  77. Date:   Wed Jun 21 15:16:42 2017 -0400
  78.  
  79.     powerpc/kernel: Avoid redundancies on giveup_all
  80.    
  81.     Currently giveup_all() call __giveup_fpu(), __giveup_altivec() and
  82.     __giveup_vsx(), but, __giveup_vsx() calls __giveup_fpu() and
  83.     __giveup_altivec() again, in a redudant manner.
  84.    
  85.     Other than giving up FPU and Altivec, __giveup_vsx() also disables
  86.     MSR_VSX on MSR, but this is already done on by __giveup_{fp,altivec}().
  87.     As VSX could not be enabled alone (without FP and/or VEC enabled), this
  88.     is also a redundancy.
  89.    
  90.     This change improves giveup_all() in just 3%, but since giveup_all() is
  91.     called very frequently, around 8x per CPU per second, this change might
  92.     be interesting.
  93.    
  94.     Signed-off-by: Breno Leitao <leitao@debian.org>
  95.     Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
  96.  
  97. diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
  98. index 2ad725ef4368..5d6af58270e6 100644
  99. --- a/arch/powerpc/kernel/process.c
  100. +++ b/arch/powerpc/kernel/process.c
  101. @@ -494,10 +494,6 @@ void giveup_all(struct task_struct *tsk)
  102.     if (usermsr & MSR_VEC)
  103.         __giveup_altivec(tsk);
  104.  #endif
  105. -#ifdef CONFIG_VSX
  106. -   if (usermsr & MSR_VSX)
  107. -       __giveup_vsx(tsk);
  108. -#endif
  109.  #ifdef CONFIG_SPE
  110.     if (usermsr & MSR_SPE)
  111.         __giveup_spe(tsk);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement