* [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries
@ 2013-12-06 21:44 Richard Henderson
2013-12-06 21:44 ` [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays Richard Henderson
2013-12-22 18:04 ` [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Aurelien Jarno
0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2013-12-06 21:44 UTC (permalink / raw)
To: qemu-devel
The size of tlb_table is 4k on a 64-bit host. For overwriting
memory at this size, cacheline tricks can help.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
cputlb.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/cputlb.c b/cputlb.c
index fff0afb..d2da404 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -33,13 +33,6 @@
/* statistics */
int tlb_flush_count;
-static const CPUTLBEntry s_cputlb_empty_entry = {
- .addr_read = -1,
- .addr_write = -1,
- .addr_code = -1,
- .addend = -1,
-};
-
/* NOTE:
* If flush_global is true (the usual case), flush all tlb entries.
* If flush_global is false, flush (at least) all tlb entries not
@@ -55,7 +48,6 @@ static const CPUTLBEntry s_cputlb_empty_entry = {
void tlb_flush(CPUArchState *env, int flush_global)
{
CPUState *cpu = ENV_GET_CPU(env);
- int i;
#if defined(DEBUG_TLB)
printf("tlb_flush:\n");
@@ -64,14 +56,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
links while we are modifying them */
cpu->current_tb = NULL;
- for (i = 0; i < CPU_TLB_SIZE; i++) {
- int mmu_idx;
-
- for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
- env->tlb_table[mmu_idx][i] = s_cputlb_empty_entry;
- }
- }
-
+ memset(env->tlb_table, -1, sizeof(env->tlb_table));
memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
env->tlb_flush_addr = -1;
@@ -87,7 +72,7 @@ static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)
(TARGET_PAGE_MASK | TLB_INVALID_MASK)) ||
addr == (tlb_entry->addr_code &
(TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
- *tlb_entry = s_cputlb_empty_entry;
+ memset(tlb_entry, -1, sizeof(*tlb_entry));
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays
2013-12-06 21:44 [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Richard Henderson
@ 2013-12-06 21:44 ` Richard Henderson
2013-12-22 18:04 ` Aurelien Jarno
2013-12-22 18:04 ` [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Aurelien Jarno
1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2013-12-06 21:44 UTC (permalink / raw)
To: qemu-devel
Don't duplicate the array length computation in the memset
when plain sizeof can produce the correct results.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
cputlb.c | 2 +-
translate-all.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cputlb.c b/cputlb.c
index d2da404..9270055 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -57,7 +57,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
cpu->current_tb = NULL;
memset(env->tlb_table, -1, sizeof(env->tlb_table));
- memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
+ memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
env->tlb_flush_addr = -1;
env->tlb_flush_mask = 0;
diff --git a/translate-all.c b/translate-all.c
index aeda54d..66755b1 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -699,11 +699,10 @@ void tb_flush(CPUArchState *env1)
CPU_FOREACH(cpu) {
CPUArchState *env = cpu->env_ptr;
- memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
+ memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
}
- memset(tcg_ctx.tb_ctx.tb_phys_hash, 0,
- CODE_GEN_PHYS_HASH_SIZE * sizeof(void *));
+ memset(tcg_ctx.tb_ctx.tb_phys_hash, 0, sizeof(tcg_ctx.tb_ctx.tb_phys_hash));
page_flush_tb();
tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries
2013-12-06 21:44 [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Richard Henderson
2013-12-06 21:44 ` [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays Richard Henderson
@ 2013-12-22 18:04 ` Aurelien Jarno
2013-12-23 14:37 ` Andreas Färber
1 sibling, 1 reply; 5+ messages in thread
From: Aurelien Jarno @ 2013-12-22 18:04 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Sat, Dec 07, 2013 at 10:44:51AM +1300, Richard Henderson wrote:
> The size of tlb_table is 4k on a 64-bit host. For overwriting
> memory at this size, cacheline tricks can help.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> cputlb.c | 19 ++-----------------
> 1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/cputlb.c b/cputlb.c
> index fff0afb..d2da404 100644
> --- a/cputlb.c
> +++ b/cputlb.c
> @@ -33,13 +33,6 @@
> /* statistics */
> int tlb_flush_count;
>
> -static const CPUTLBEntry s_cputlb_empty_entry = {
> - .addr_read = -1,
> - .addr_write = -1,
> - .addr_code = -1,
> - .addend = -1,
> -};
> -
> /* NOTE:
> * If flush_global is true (the usual case), flush all tlb entries.
> * If flush_global is false, flush (at least) all tlb entries not
> @@ -55,7 +48,6 @@ static const CPUTLBEntry s_cputlb_empty_entry = {
> void tlb_flush(CPUArchState *env, int flush_global)
> {
> CPUState *cpu = ENV_GET_CPU(env);
> - int i;
>
> #if defined(DEBUG_TLB)
> printf("tlb_flush:\n");
> @@ -64,14 +56,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
> links while we are modifying them */
> cpu->current_tb = NULL;
>
> - for (i = 0; i < CPU_TLB_SIZE; i++) {
> - int mmu_idx;
> -
> - for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
> - env->tlb_table[mmu_idx][i] = s_cputlb_empty_entry;
> - }
> - }
> -
> + memset(env->tlb_table, -1, sizeof(env->tlb_table));
> memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
>
> env->tlb_flush_addr = -1;
> @@ -87,7 +72,7 @@ static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)
> (TARGET_PAGE_MASK | TLB_INVALID_MASK)) ||
> addr == (tlb_entry->addr_code &
> (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
> - *tlb_entry = s_cputlb_empty_entry;
> + memset(tlb_entry, -1, sizeof(*tlb_entry));
> }
> }
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays
2013-12-06 21:44 ` [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays Richard Henderson
@ 2013-12-22 18:04 ` Aurelien Jarno
0 siblings, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2013-12-22 18:04 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
On Sat, Dec 07, 2013 at 10:44:52AM +1300, Richard Henderson wrote:
> Don't duplicate the array length computation in the memset
> when plain sizeof can produce the correct results.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> cputlb.c | 2 +-
> translate-all.c | 5 ++---
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/cputlb.c b/cputlb.c
> index d2da404..9270055 100644
> --- a/cputlb.c
> +++ b/cputlb.c
> @@ -57,7 +57,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
> cpu->current_tb = NULL;
>
> memset(env->tlb_table, -1, sizeof(env->tlb_table));
> - memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
> + memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
>
> env->tlb_flush_addr = -1;
> env->tlb_flush_mask = 0;
> diff --git a/translate-all.c b/translate-all.c
> index aeda54d..66755b1 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -699,11 +699,10 @@ void tb_flush(CPUArchState *env1)
> CPU_FOREACH(cpu) {
> CPUArchState *env = cpu->env_ptr;
>
> - memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
> + memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
> }
>
> - memset(tcg_ctx.tb_ctx.tb_phys_hash, 0,
> - CODE_GEN_PHYS_HASH_SIZE * sizeof(void *));
> + memset(tcg_ctx.tb_ctx.tb_phys_hash, 0, sizeof(tcg_ctx.tb_ctx.tb_phys_hash));
> page_flush_tb();
>
> tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries
2013-12-22 18:04 ` [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Aurelien Jarno
@ 2013-12-23 14:37 ` Andreas Färber
0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-12-23 14:37 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, Aurelien Jarno
Am 22.12.2013 19:04, schrieb Aurelien Jarno:
> On Sat, Dec 07, 2013 at 10:44:51AM +1300, Richard Henderson wrote:
>> The size of tlb_table is 4k on a 64-bit host. For overwriting
>> memory at this size, cacheline tricks can help.
>>
>> Signed-off-by: Richard Henderson <rth@twiddle.net>
>> ---
>> cputlb.c | 19 ++-----------------
>> 1 file changed, 2 insertions(+), 17 deletions(-)
[...]
>
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Don't spot a matching cover letter - thanks, applied both to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-23 14:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06 21:44 [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Richard Henderson
2013-12-06 21:44 ` [Qemu-devel] [PATCH 2/2] cputlb: Tidy memset of arrays Richard Henderson
2013-12-22 18:04 ` Aurelien Jarno
2013-12-22 18:04 ` [Qemu-devel] [PATCH 1/2] cputlb: Use memset when flushing entries Aurelien Jarno
2013-12-23 14:37 ` Andreas Färber
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).