Patchwork [3/4] target/ppc: improve performance of large BAT invalidations

login
register
mail settings
Submitter Artyom Tarasenko
Date April 12, 2019, 9:06 p.m.
Message ID <1555103178-21894-4-git-send-email-atar4qemu@gmail.com>
Download mbox | patch
Permalink /patch/772155/
State New
Headers show

Comments

Artyom Tarasenko - April 12, 2019, 9:06 p.m.
Performing a complete flush is ~ 100 times faster than flushing
256MiB of 4KiB pages. Set a limit of 1024 pages and perform a complete
flush afterwards.

This patch significantly speeds up AIX 5.1 and NetBSD-ofppc.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
---
 target/ppc/mmu_helper.c | 7 +++++++
 1 file changed, 7 insertions(+)
Hervé Poussineau - April 14, 2019, 3:43 p.m.
Le 12/04/2019 à 23:06, Artyom Tarasenko a écrit :
> Performing a complete flush is ~ 100 times faster than flushing
> 256MiB of 4KiB pages. Set a limit of 1024 pages and perform a complete
> flush afterwards.
> 
> This patch significantly speeds up AIX 5.1 and NetBSD-ofppc.
> 
> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
> ---
>   target/ppc/mmu_helper.c | 7 +++++++
>   1 file changed, 7 insertions(+)

Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
David Gibson - April 15, 2019, 12:20 a.m.
On Fri, Apr 12, 2019 at 11:06:17PM +0200, Artyom Tarasenko wrote:
> Performing a complete flush is ~ 100 times faster than flushing
> 256MiB of 4KiB pages. Set a limit of 1024 pages and perform a complete
> flush afterwards.
> 
> This patch significantly speeds up AIX 5.1 and NetBSD-ofppc.
> 
> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>

LGTM, applied to ppc-for-4.1.

> ---
>  target/ppc/mmu_helper.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
> index 4a6be4d..d7eed3a 100644
> --- a/target/ppc/mmu_helper.c
> +++ b/target/ppc/mmu_helper.c
> @@ -1809,6 +1809,13 @@ static inline void do_invalidate_BAT(CPUPPCState *env, target_ulong BATu,
>  
>      base = BATu & ~0x0001FFFF;
>      end = base + mask + 0x00020000;
> +    if (((end - base) >> TARGET_PAGE_BITS) > 1024) {
> +        /* Flushing 1024 4K pages is slower than a complete flush */
> +        LOG_BATS("Flush all BATs\n");
> +        tlb_flush(CPU(cs));
> +        LOG_BATS("Flush done\n");
> +        return;
> +    }
>      LOG_BATS("Flush BAT from " TARGET_FMT_lx " to " TARGET_FMT_lx " ("
>               TARGET_FMT_lx ")\n", base, end, mask);
>      for (page = base; page != end; page += TARGET_PAGE_SIZE) {

Patch

diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
index 4a6be4d..d7eed3a 100644
--- a/target/ppc/mmu_helper.c
+++ b/target/ppc/mmu_helper.c
@@ -1809,6 +1809,13 @@  static inline void do_invalidate_BAT(CPUPPCState *env, target_ulong BATu,
 
     base = BATu & ~0x0001FFFF;
     end = base + mask + 0x00020000;
+    if (((end - base) >> TARGET_PAGE_BITS) > 1024) {
+        /* Flushing 1024 4K pages is slower than a complete flush */
+        LOG_BATS("Flush all BATs\n");
+        tlb_flush(CPU(cs));
+        LOG_BATS("Flush done\n");
+        return;
+    }
     LOG_BATS("Flush BAT from " TARGET_FMT_lx " to " TARGET_FMT_lx " ("
              TARGET_FMT_lx ")\n", base, end, mask);
     for (page = base; page != end; page += TARGET_PAGE_SIZE) {