[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-4.1 v2 01/36] tcg: Fold CPUTLBWindow into CPUTLB
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH for-4.1 v2 01/36] tcg: Fold CPUTLBWindow into CPUTLBDesc |
Date: |
Thu, 28 Mar 2019 13:03:29 -1000 |
Signed-off-by: Richard Henderson <address@hidden>
---
include/exec/cpu-defs.h | 17 ++++-------------
accel/tcg/cputlb.c | 24 ++++++++++++------------
2 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 8f2a848bf5..52d150aaf1 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -127,18 +127,6 @@ typedef struct CPUIOTLBEntry {
MemTxAttrs attrs;
} CPUIOTLBEntry;
-/**
- * struct CPUTLBWindow
- * @begin_ns: host time (in ns) at the beginning of the time window
- * @max_entries: maximum number of entries observed in the window
- *
- * See also: tlb_mmu_resize_locked()
- */
-typedef struct CPUTLBWindow {
- int64_t begin_ns;
- size_t max_entries;
-} CPUTLBWindow;
-
typedef struct CPUTLBDesc {
/*
* Describe a region covering all of the large pages allocated
@@ -148,9 +136,12 @@ typedef struct CPUTLBDesc {
*/
target_ulong large_page_addr;
target_ulong large_page_mask;
+ /* host time (in ns) at the beginning of the time window */
+ int64_t window_begin_ns;
+ /* maximum number of entries observed in the window */
+ size_t window_max_entries;
/* The next index to use in the tlb victim table. */
size_t vindex;
- CPUTLBWindow window;
size_t n_used_entries;
} CPUTLBDesc;
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 88cc8389e9..23586f9974 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -79,11 +79,11 @@ static inline size_t sizeof_tlb(CPUArchState *env,
uintptr_t mmu_idx)
return env->tlb_mask[mmu_idx] + (1 << CPU_TLB_ENTRY_BITS);
}
-static void tlb_window_reset(CPUTLBWindow *window, int64_t ns,
+static void tlb_window_reset(CPUTLBDesc *desc, int64_t ns,
size_t max_entries)
{
- window->begin_ns = ns;
- window->max_entries = max_entries;
+ desc->window_begin_ns = ns;
+ desc->window_max_entries = max_entries;
}
static void tlb_dyn_init(CPUArchState *env)
@@ -94,7 +94,7 @@ static void tlb_dyn_init(CPUArchState *env)
CPUTLBDesc *desc = &env->tlb_d[i];
size_t n_entries = 1 << CPU_TLB_DYN_DEFAULT_BITS;
- tlb_window_reset(&desc->window, get_clock_realtime(), 0);
+ tlb_window_reset(desc, get_clock_realtime(), 0);
desc->n_used_entries = 0;
env->tlb_mask[i] = (n_entries - 1) << CPU_TLB_ENTRY_BITS;
env->tlb_table[i] = g_new(CPUTLBEntry, n_entries);
@@ -151,18 +151,18 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int
mmu_idx)
int64_t now = get_clock_realtime();
int64_t window_len_ms = 100;
int64_t window_len_ns = window_len_ms * 1000 * 1000;
- bool window_expired = now > desc->window.begin_ns + window_len_ns;
+ bool window_expired = now > desc->window_begin_ns + window_len_ns;
- if (desc->n_used_entries > desc->window.max_entries) {
- desc->window.max_entries = desc->n_used_entries;
+ if (desc->n_used_entries > desc->window_max_entries) {
+ desc->window_max_entries = desc->n_used_entries;
}
- rate = desc->window.max_entries * 100 / old_size;
+ rate = desc->window_max_entries * 100 / old_size;
if (rate > 70) {
new_size = MIN(old_size << 1, 1 << CPU_TLB_DYN_MAX_BITS);
} else if (rate < 30 && window_expired) {
- size_t ceil = pow2ceil(desc->window.max_entries);
- size_t expected_rate = desc->window.max_entries * 100 / ceil;
+ size_t ceil = pow2ceil(desc->window_max_entries);
+ size_t expected_rate = desc->window_max_entries * 100 / ceil;
/*
* Avoid undersizing when the max number of entries seen is just below
@@ -182,7 +182,7 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int
mmu_idx)
if (new_size == old_size) {
if (window_expired) {
- tlb_window_reset(&desc->window, now, desc->n_used_entries);
+ tlb_window_reset(desc, now, desc->n_used_entries);
}
return;
}
@@ -190,7 +190,7 @@ static void tlb_mmu_resize_locked(CPUArchState *env, int
mmu_idx)
g_free(env->tlb_table[mmu_idx]);
g_free(env->iotlb[mmu_idx]);
- tlb_window_reset(&desc->window, now, 0);
+ tlb_window_reset(desc, now, 0);
/* desc->n_used_entries is cleared by the caller */
env->tlb_mask[mmu_idx] = (new_size - 1) << CPU_TLB_ENTRY_BITS;
env->tlb_table[mmu_idx] = g_try_new(CPUTLBEntry, new_size);
--
2.17.1
- [Qemu-devel] [PATCH for-4.1 v2 27/36] target/unicore32: Use env_cpu, env_archcpu, (continued)
- [Qemu-devel] [PATCH for-4.1 v2 27/36] target/unicore32: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 12/36] target/i386: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 08/36] target/alpha: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 15/36] target/microblaze: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 02/36] tcg: Split out target/arch/cpu-param.h, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 04/36] cpu: Define CPUArchState with typedef, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 16/36] target/mips: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 11/36] target/hppa: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 07/36] cpu: Introduce env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 05/36] cpu: Define ArchCPU, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 01/36] tcg: Fold CPUTLBWindow into CPUTLBDesc,
Richard Henderson <=
- [Qemu-devel] [PATCH for-4.1 v2 09/36] target/arm: Use env_cpu, env_archcpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 06/36] cpu: Replace ENV_GET_CPU with env_cpu, Richard Henderson, 2019/03/28
- [Qemu-devel] [PATCH for-4.1 v2 03/36] tcg: Create struct CPUTLB, Richard Henderson, 2019/03/28
- Re: [Qemu-devel] [PATCH for-4.1 v2 00/36] tcg: Move the softmmu tlb to CPUNegativeOffsetState, no-reply, 2019/03/28