Re: [PATCH v12 2/5] target/ppc: make power8-pmu.c CONFIG_TCG only

2022-02-24 Thread Daniel Henrique Barboza




On 2/17/22 19:17, Richard Henderson wrote:

On 2/16/22 21:10, Daniel Henrique Barboza wrote:

  static void init_tcg_pmu_power8(CPUPPCState *env)
  {
-#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_TCG)
  /* Init PMU overflow timers */
  if (!kvm_enabled()) {
  cpu_ppc_pmu_init(env);
@@ -7872,10 +7872,9 @@ static void ppc_cpu_reset(DeviceState *dev)
  if (env->mmu_model != POWERPC_MMU_REAL) {
  ppc_tlb_invalidate_all(env);
  }
+    pmu_update_summaries(env);
  #endif /* CONFIG_TCG */
  #endif
-
-    pmu_update_summaries(env);


It looks like you could remove all of the ifdefs if you simply use 
tcg_enabled() rather than !kvm_enabled().  If !defined(CONFIG_TCG), 
tcg_enabled() will be constant false, and the block will be optimized away.



Just tested and it works. Thanks for the tip.

I'll re-send with this change.


Thanks,


Daniel




r~




Re: [PATCH v12 2/5] target/ppc: make power8-pmu.c CONFIG_TCG only

2022-02-17 Thread Richard Henderson

On 2/16/22 21:10, Daniel Henrique Barboza wrote:

  static void init_tcg_pmu_power8(CPUPPCState *env)
  {
-#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_TCG)
  /* Init PMU overflow timers */
  if (!kvm_enabled()) {
  cpu_ppc_pmu_init(env);
@@ -7872,10 +7872,9 @@ static void ppc_cpu_reset(DeviceState *dev)
  if (env->mmu_model != POWERPC_MMU_REAL) {
  ppc_tlb_invalidate_all(env);
  }
+pmu_update_summaries(env);
  #endif /* CONFIG_TCG */
  #endif
-
-pmu_update_summaries(env);


It looks like you could remove all of the ifdefs if you simply use tcg_enabled() rather 
than !kvm_enabled().  If !defined(CONFIG_TCG), tcg_enabled() will be constant false, and 
the block will be optimized away.



r~