qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm/helper.c: Don't flush the TLB if SCTLR is rewritten unchanged
@ 2014-05-08 14:40 Peter Maydell
  2014-05-08 15:07 ` Laurent Desnogues
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2014-05-08 14:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Desnogues, patches

Linux makes a habit of writing the same value to the SCTLR that it
already holds. In a sample boot of the kernel to a shell prompt
it wrote the SCTLR with the value it already held 325465 times,
and wrote different values just 3 times.

Skip flushing the TLB if the SCTLR value isn't actually being changed;
this speeds up my sample boot by 3-5%.

Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I believe there are kernel patches in the works to avoid being
quite so profligate with SCTLR writes, but there are still a
lot of older kernels out in the world, so this is worth having IMHO.

 target-arm/helper.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 3be917c..417161e 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2081,6 +2081,13 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
 {
     ARMCPU *cpu = arm_env_get_cpu(env);
 
+    if (env->cp15.c1_sys == value) {
+        /* Skip the TLB flush if nothing actually changed; Linux likes
+         * to do a lot of pointless SCTLR writes.
+         */
+        return;
+    }
+
     env->cp15.c1_sys = value;
     /* ??? Lots of these bits are not implemented.  */
     /* This may enable/disable the MMU, so do a TLB flush.  */
-- 
1.9.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] target-arm/helper.c: Don't flush the TLB if SCTLR is rewritten unchanged
  2014-05-08 14:40 [Qemu-devel] [PATCH] target-arm/helper.c: Don't flush the TLB if SCTLR is rewritten unchanged Peter Maydell
@ 2014-05-08 15:07 ` Laurent Desnogues
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Desnogues @ 2014-05-08 15:07 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel@nongnu.org, Patch Tracking

On Thu, May 8, 2014 at 4:40 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Linux makes a habit of writing the same value to the SCTLR that it
> already holds. In a sample boot of the kernel to a shell prompt
> it wrote the SCTLR with the value it already held 325465 times,
> and wrote different values just 3 times.
>
> Skip flushing the TLB if the SCTLR value isn't actually being changed;
> this speeds up my sample boot by 3-5%.
>
> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>

Thanks,

Laurent

> ---
> I believe there are kernel patches in the works to avoid being
> quite so profligate with SCTLR writes, but there are still a
> lot of older kernels out in the world, so this is worth having IMHO.
>
>  target-arm/helper.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 3be917c..417161e 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -2081,6 +2081,13 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
>  {
>      ARMCPU *cpu = arm_env_get_cpu(env);
>
> +    if (env->cp15.c1_sys == value) {
> +        /* Skip the TLB flush if nothing actually changed; Linux likes
> +         * to do a lot of pointless SCTLR writes.
> +         */
> +        return;
> +    }
> +
>      env->cp15.c1_sys = value;
>      /* ??? Lots of these bits are not implemented.  */
>      /* This may enable/disable the MMU, so do a TLB flush.  */
> --
> 1.9.2
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-08 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08 14:40 [Qemu-devel] [PATCH] target-arm/helper.c: Don't flush the TLB if SCTLR is rewritten unchanged Peter Maydell
2014-05-08 15:07 ` Laurent Desnogues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).