tcg/softmmu: Increase size of TLB caches
PATCH 1/1 tcg/softmmu: Increase size of TLB caches
This patch increases the number of entries cached in the TLB. I went over a few architectures to see if increasing it is problematic. Only armv6 seems to have a limitation that only 8 bits can be used for indexing these entries. For other architectures, the number of TLB entries is increased to a 4K-sized cache. The patch also doubles the number of victim TLB entries.
Some statistics collected from a build benchmark for various cache sizes is listed below:
| TLB bits\vTLB entires | 8 | 16 | 32 | | 8 | 952.94(+0.0%) | 929.99(+2.4%) | 919.02(+3.6%) | | 10 | 898.92(+5.6%) | 886.13(+7.0%) | 887.03(+6.9%) | | 12 | 878.56(+7.8%) | 873.53(+8.3%)* | 875.34(+8.1%) |
The best combination for this workload came out to be 12 bits for the TLB and a 16 entry vTLB cache.
--- include/exec/cpu-defs.h | 6 +++--- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 2 ++ tcg/ia64/tcg-target.h | 1 + tcg/mips/tcg-target.h | 2 ++ tcg/ppc/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tci/tcg-target.h | 1 + 10 files changed, 14 insertions(+), 3 deletions(-)
include/exec/cpu-defs.h +3 -3
@@ -57,8 +57,8 @@ typedef uint64_t target_ulong;#endif #if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG ) -/* use a fully associative victim tlb of 8 entries */ -#define CPU_VTLB_SIZE 8 +/* use a fully associative victim tlb of 16 entries */ +#define CPU_VTLB_SIZE 16#if HOST_LONG_BITS ==32 &&TARGET_LONG_BITS ==32 #define CPU_TLB_ENTRY_BITS 4
@@ -89,7 +89,7 @@ typedef uint64_t target_ulong;* of tlb_table inside env (which is non-trivial but not huge). */ #define CPU_TLB_BITS \ - MIN(8, \ + MIN(MIN(12, TCG_TARGET_TLB_MAX_INDEX_BITS), \ TCG_TARGET_TLB_DISPLACEMENT_BITS - CPU_TLB_ENTRY_BITS - \ (NB_MMU_MODES <= 1 ? 0 : \ NB_MMU_MODES <= 2 ? 1 : \
tcg/aarch64/tcg-target.h +1 -0
@@ -15,6 +15,7 @@#define TCG_TARGET_INSN_UNIT_SIZE 4#define TCG_TARGET_TLB_DISPLACEMENT_BITS 24 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 32#undef TCG_TARGET_STACK_GROWSUP typedef enum {
tcg/arm/tcg-target.h +1 -0
@@ -60,6 +60,7 @@ extern int arm_arch;#undef TCG_TARGET_STACK_GROWSUP#define TCG_TARGET_INSN_UNIT_SIZE 4#define TCG_TARGET_TLB_DISPLACEMENT_BITS 16 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 8 typedef enum { TCG_REG_R0 = 0,
tcg/i386/tcg-target.h +2 -0
@@ -162,6 +162,8 @@ extern bool have_popcnt;# define TCG_AREG0 TCG_REG_EBP#endif +#define TCG_TARGET_TLB_MAX_INDEX_BITS (32 - CPU_TLB_ENTRY_BITS) +static inline void flush_icache_range (uintptr_t start,uintptr_t stop) { }
tcg/ia64/tcg-target.h +1 -0
@@ -28,6 +28,7 @@#define TCG_TARGET_INSN_UNIT_SIZE 16#define TCG_TARGET_TLB_DISPLACEMENT_BITS 21 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 32 typedef struct { uint64_t lo __attribute__((aligned(16)));
tcg/mips/tcg-target.h +2 -0
@@ -39,6 +39,8 @@#define TCG_TARGET_TLB_DISPLACEMENT_BITS 16#define TCG_TARGET_NB_REGS 32 +#define TCG_TARGET_TLB_MAX_INDEX_BITS (16 - CPU_TLB_ENTRY_BITS) + typedef enum { TCG_REG_ZERO = 0, TCG_REG_AT,
tcg/ppc/tcg-target.h +1 -0
@@ -34,6 +34,7 @@#define TCG_TARGET_NB_REGS 32#define TCG_TARGET_INSN_UNIT_SIZE 4#define TCG_TARGET_TLB_DISPLACEMENT_BITS 16 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 32 typedef enum { TCG_REG_R0, TCG_REG_R1, TCG_REG_R2, TCG_REG_R3,
tcg/s390/tcg-target.h +1 -0
@@ -27,6 +27,7 @@#define TCG_TARGET_INSN_UNIT_SIZE 2#define TCG_TARGET_TLB_DISPLACEMENT_BITS 19 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 32 typedef enum TCGReg { TCG_REG_R0 = 0,
tcg/sparc/tcg-target.h +1 -0
@@ -29,6 +29,7 @@#define TCG_TARGET_INSN_UNIT_SIZE 4#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 12#define TCG_TARGET_NB_REGS 32 typedef enum {
tcg/tci/tcg-target.h +1 -0
@@ -43,6 +43,7 @@#define TCG_TARGET_INTERPRETER 1#define TCG_TARGET_INSN_UNIT_SIZE 1#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32 +#define TCG_TARGET_TLB_MAX_INDEX_BITS 32#if UINTPTR_MAX ==UINT32_MAX # define TCG_TARGET_REG_BITS 32
Signature · 1 line
2.13.0
Quoted 19 lines · Pranith Kumar
This patch increases the number of entries cached in the TLB. I went over a few architectures to see if increasing it is problematic. Only armv6 seems to have a limitation that only 8 bits can be used for indexing these entries. For other architectures, the number of TLB entries is increased to a 4K-sized cache. The patch also doubles the number of victim TLB entries.
Some statistics collected from a build benchmark for various cache sizes is listed below:
| TLB bits\vTLB entires | 8 | 16 | 32 | | 8 | 952.94(+0.0%) | 929.99(+2.4%) | 919.02(+3.6%) | | 10 | 898.92(+5.6%) | 886.13(+7.0%) | 887.03(+6.9%) | | 12 | 878.56(+7.8%) | 873.53(+8.3%)* | 875.34(+8.1%) |The best combination for this workload came out to be 12 bits for the TLB and a 16 entry vTLB cache.
Signed-off-by Pranith Kumar <[email protected]>
Quoted 12 lines
--- include/exec/cpu-defs.h | 6 +++--- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 2 ++ tcg/ia64/tcg-target.h | 1 + tcg/mips/tcg-target.h | 2 ++ tcg/ppc/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tci/tcg-target.h | 1 + 10 files changed, 14 insertions(+), 3 deletions(-)
r~
Quoted 10 lines · Pranith Kumar
This patch increases the number of entries cached in the TLB. I went over a few architectures to see if increasing it is problematic. Only armv6 seems to have a limitation that only 8 bits can be used for indexing these entries. For other architectures, the number of TLB entries is increased to a 4K-sized cache. The patch also doubles the number of victim TLB entries.
Some statistics collected from a build benchmark for various cache sizes is listed below:
Quoted 7 lines
| TLB bits\vTLB entires | 8 | 16 | 32 | | 8 | 952.94(+0.0%) | 929.99(+2.4%) | 919.02(+3.6%) | | 10 | 898.92(+5.6%) | 886.13(+7.0%) | 887.03(+6.9%) | | 12 | 878.56(+7.8%) | 873.53(+8.3%)* | 875.34(+8.1%) |The best combination for this workload came out to be 12 bits for the TLB and a 16 entry vTLB cache.
This significantly degrades performance of alpha-softmmu. It spends about 25% of all cpu time in memset.
r~
Quoted 16 lines · Richard Henderson
Quoted 15 lines · Pranith Kumar
This patch increases the number of entries cached in the TLB. I went over a few architectures to see if increasing it is problematic. Only armv6 seems to have a limitation that only 8 bits can be used for indexing these entries. For other architectures, the number of TLB entries is increased to a 4K-sized cache. The patch also doubles the number of victim TLB entries.
Some statistics collected from a build benchmark for various cache sizes is listed below:
| TLB bits\vTLB entires | 8 | 16 | 32 | | 8 | 952.94(+0.0%) | 929.99(+2.4%) | 919.02(+3.6%) | | 10 | 898.92(+5.6%) | 886.13(+7.0%) | 887.03(+6.9%) | | 12 | 878.56(+7.8%) | 873.53(+8.3%)* | 875.34(+8.1%) |
Quoted 5 lines
Quoted 2 lines
The best combination for this workload came out to be 12 bits for the TLB and a 16 entry vTLB cache.
This significantly degrades performance of alpha-softmmu. It spends about 25% of all cpu time in memset.
What workload does it degrade for? I will try to reproduce and see which memset is causing this.
Signature · 1 line
Pranith
Quoted 5 lines · Pranith Kumar
Quoted 2 lines
This significantly degrades performance of alpha-softmmu. It spends about 25% of all cpu time in memset.
What workload does it degrade for? I will try to reproduce and see which memset is causing this.
emerge --update --ask @world
which is a lot of python, iirc.
It is the tlb flush memset that is causing this. The tlb has grown from a few kB to 300kB with your patch.
r~
Quoted 7 lines · Richard Henderson
Quoted 5 lines · Pranith Kumar
Quoted 2 lines
This significantly degrades performance of alpha-softmmu. It spends about 25% of all cpu time in memset.
What workload does it degrade for? I will try to reproduce and see which memset is causing this.
Quoted 6 lines
emerge --update --ask @world
which is a lot of python, iirc.
It is the tlb flush memset that is causing this. The tlb has grown from a few kB to 300kB with your patch.
Hmm I wonder if this is QEMU doing global flushes which could actually be partial TLB flushes? emerge is quite a memory hog though so its conceivable we are generating a lot of churn as it runs.
--
Alex Bennée