Skip to contentSkip to conversation

target-ppc: gen_pause for instructions: yield, mdoio, mdoom, miso

PATCH Applied Aaron Larson 3 participants 4 messages Jun 24, 2016 – Jun 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: gen_pause for instructions: yield, mdoio, mdoom, miso

Call gen_pause for all "or rx,rx,rx" encodings other nop. This provides a reasonable implementation for yield, and a better approximation for mdoio, mdoom, and miso. The choice to pause for all encodings !=0 leverages the PowerISA admonition that the reserved encodings might change program priority, providing a slight "future proofing".

---
 target-ppc/translate.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
target-ppc/translate.c +8 -7
index 2f1c591..c4559b6 100644
@@ -1471,7 +1471,7 @@ static void gen_or(DisasContext *ctx)
     } else if (unlikely(Rc(ctx->opcode) != 0)) {
         gen_set_Rc0(ctx, cpu_gpr[rs]);
 #if defined(TARGET_PPC64)
-    } else {
+    } else if (rs != 0) { /* 0 is nop */
         int prio = 0;
 
         switch (rs) {
@@ -1514,7 +1514,6 @@ static void gen_or(DisasContext *ctx)
             break;
 #endif
         default:
-            /* nop */
             break;
         }
         if (prio) {
@@ -1524,13 +1523,15 @@ static void gen_or(DisasContext *ctx)
             tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
             gen_store_spr(SPR_PPR, t0);
             tcg_temp_free(t0);
-            /* Pause us out of TCG otherwise spin loops with smt_low
-             * eat too much CPU and the kernel hangs
-             */
+        }
 #if !defined(CONFIG_USER_ONLY)
-            gen_pause(ctx);
+        /* Pause out of TCG otherwise spin loops with smt_low eat too much
+         * CPU and the kernel hangs.  This applies to all encodings other
+         * than no-op, e.g., miso(rs=26), yield(27), mdoio(29), mdoom(30),
+         * and all currently undefined.
+         */
+        gen_pause(ctx);
 #endif
-        }
 #endif
     }
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 9 lines · Aaron Larson

Call gen_pause for all "or rx,rx,rx" encodings other nop. This provides a reasonable implementation for yield, and a better approximation for mdoio, mdoom, and miso. The choice to pause for all encodings !=0 leverages the PowerISA admonition that the reserved encodings might change program priority, providing a slight "future proofing".

As far as I can tell, this is ok. However, I'd like to get a second opinion from agraf or BenH before I apply it.

Quoted 46 lines
---
 target-ppc/translate.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
target-ppc/translate.c +8 -7
index 2f1c591..c4559b6 100644
@@ -1471,7 +1471,7 @@ static void gen_or(DisasContext *ctx)
     } else if (unlikely(Rc(ctx->opcode) != 0)) {
         gen_set_Rc0(ctx, cpu_gpr[rs]);
 #if defined(TARGET_PPC64)
-    } else {
+    } else if (rs != 0) { /* 0 is nop */
         int prio = 0;
 
         switch (rs) {
@@ -1514,7 +1514,6 @@ static void gen_or(DisasContext *ctx)
             break;
 #endif
         default:
-            /* nop */
             break;
         }
         if (prio) {
@@ -1524,13 +1523,15 @@ static void gen_or(DisasContext *ctx)
             tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
             gen_store_spr(SPR_PPR, t0);
             tcg_temp_free(t0);
-            /* Pause us out of TCG otherwise spin loops with smt_low
-             * eat too much CPU and the kernel hangs
-             */
+        }
 #if !defined(CONFIG_USER_ONLY)
-            gen_pause(ctx);
+        /* Pause out of TCG otherwise spin loops with smt_low eat too much
+         * CPU and the kernel hangs.  This applies to all encodings other
+         * than no-op, e.g., miso(rs=26), yield(27), mdoio(29), mdoom(30),
+         * and all currently undefined.
+         */
+        gen_pause(ctx);
 #endif
-        }
 #endif
     }
 }
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Acked-by on v1 1/1
#2 lore raw
In reply to Aaron Larson
Quoted 9 lines · Aaron Larson

Call gen_pause for all "or rx,rx,rx" encodings other nop.  This provides a reasonable implementation for yield, and a better approximation for mdoio, mdoom, and miso.  The choice to pause for all
encodings !=0 leverages the PowerISA admonition that the reserved encodings might change program priority, providing a slight "future proofing".

Quoted 49 lines

---
 target-ppc/translate.c | 15 ++++++++-------

 1 file changed, 8 insertions(+), 7 deletions(-)
target-ppc/translate.c +1 -1
index 2f1c591..c4559b6 100644
@@ -1471,7 +1471,7 @@ static void gen_or(DisasContext *ctx)
      } else if (unlikely(Rc(ctx->opcode) != 0)) {
          gen_set_Rc0(ctx, cpu_gpr[rs]);
  #if defined(TARGET_PPC64)
-    } else {
+    } else if (rs != 0) { /* 0 is nop */
          int prio = 0;


         switch (rs) {

target-ppc/translate.c +0 -0
@@ -1514,7 +1514,6 @@ static void gen_or(DisasContext *ctx)
              break;
  #endif

         default:
-            /* nop */
             break;
         }
         if (prio) {

target-ppc/translate.c +2 -4
@@ -1524,13 +1523,15 @@ static void gen_or(DisasContext *ctx)
              tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
              gen_store_spr(SPR_PPR, t0);
              tcg_temp_free(t0);
-            /* Pause us out of TCG otherwise spin loops with smt_low
-             * eat too much CPU and the kernel hangs
-             */
+        }
  #if !defined(CONFIG_USER_ONLY)
-            gen_pause(ctx);
+        /* Pause out of TCG otherwise spin loops with smt_low eat

too much
+         * CPU and the kernel hangs.  This applies to all encodings other
+         * than no-op, e.g., miso(rs=26), yield(27), mdoio(29), mdoom(30),
+         * and all currently undefined.
+         */
+        gen_pause(ctx);
 #endif
-        }
 #endif
     }
 }

Applied
#3 lore raw
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 8 lines · Aaron Larson

Call gen_pause for all "or rx,rx,rx" encodings other nop.  This provides a reasonable implementation for yield, and a better approximation for mdoio, mdoom, and miso.  The choice to pause for all
encodings !=0 leverages the PowerISA admonition that the reserved encodings might change program priority, providing a slight "future proofing".

Quoted 3 lines
Quoted 1 line

Applied to ppc-for-2.7, thanks.

Quoted 50 lines
Quoted 49 lines

---
 target-ppc/translate.c | 15 ++++++++-------

 1 file changed, 8 insertions(+), 7 deletions(-)
target-ppc/translate.c +1 -1
index 2f1c591..c4559b6 100644
@@ -1471,7 +1471,7 @@ static void gen_or(DisasContext *ctx)
      } else if (unlikely(Rc(ctx->opcode) != 0)) {
          gen_set_Rc0(ctx, cpu_gpr[rs]);
  #if defined(TARGET_PPC64)
-    } else {
+    } else if (rs != 0) { /* 0 is nop */
          int prio = 0;


         switch (rs) {

target-ppc/translate.c +0 -0
@@ -1514,7 +1514,6 @@ static void gen_or(DisasContext *ctx)
              break;
  #endif

         default:
-            /* nop */
             break;
         }
         if (prio) {

target-ppc/translate.c +2 -4
@@ -1524,13 +1523,15 @@ static void gen_or(DisasContext *ctx)
              tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
              gen_store_spr(SPR_PPR, t0);
              tcg_temp_free(t0);
-            /* Pause us out of TCG otherwise spin loops with smt_low
-             * eat too much CPU and the kernel hangs
-             */
+        }
  #if !defined(CONFIG_USER_ONLY)
-            gen_pause(ctx);
+        /* Pause out of TCG otherwise spin loops with smt_low eat

too much
+         * CPU and the kernel hangs.  This applies to all encodings other
+         * than no-op, e.g., miso(rs=26), yield(27), mdoio(29), mdoom(30),
+         * and all currently undefined.
+         */
+        gen_pause(ctx);
 #endif
-        }
 #endif
     }
 }

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson