qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Patch] Clear memory using memset instead of handcoded loop
@ 2004-10-03 11:45 Daniel Egger
  2004-10-03 13:38 ` Fabrice Bellard
  2004-10-03 18:17 ` Karl Magdsick
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Egger @ 2004-10-03 11:45 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 547 bytes --]

Hija,

while profiling the lastest qemu snapshot on OS X I discovered
that one of the tb_hash clearing routines turnes up to be a
"hotspot" during my typical test procedure which includes
booting an installed Debian Sarge RC.

Attached patch turnes three handcoded memory clearing routines
into a call to memset which will be optimized by every serious
compiler into either a very optimized inline sequence for the
CPU or at least into a call of an optimized memory clearing
function (bzero on Darwin 7.5 with gcc 3.3).

Please CC me on replies.


[-- Attachment #1.2: diff --]
[-- Type: application/octet-stream, Size: 1255 bytes --]

diff -ur qemu-snapshot-2004-10-01_23/exec.c qemu-snapshot-2004-10-01_23.my/exec.c
--- qemu-snapshot-2004-10-01_23/exec.c	Fri Oct  1 00:22:08 2004
+++ qemu-snapshot-2004-10-01_23.my/exec.c	Sun Oct  3 12:39:17 2004
@@ -315,7 +316,6 @@
 /* XXX: tb_flush is currently not thread safe */
 void tb_flush(CPUState *env)
 {
-    int i;
 #if defined(DEBUG_FLUSH)
     printf("qemu: flush code_size=%d nb_tbs=%d avg_tb_size=%d\n", 
            code_gen_ptr - code_gen_buffer, 
@@ -323,12 +323,10 @@
            nb_tbs > 0 ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0);
 #endif
     nb_tbs = 0;
-    for(i = 0;i < CODE_GEN_HASH_SIZE; i++)
-        tb_hash[i] = NULL;
+    memset (tb_hash, 0, CODE_GEN_HASH_SIZE * sizeof (void *));
     virt_page_flush();
 
-    for(i = 0;i < CODE_GEN_PHYS_HASH_SIZE; i++)
-        tb_phys_hash[i] = NULL;
+    memset (tb_phys_hash, 0, CODE_GEN_HASH_SIZE * sizeof (void *));
     page_flush_tb();
 
     code_gen_ptr = code_gen_buffer;
@@ -1279,8 +1277,7 @@
     }
 
     virt_page_flush();
-    for(i = 0;i < CODE_GEN_HASH_SIZE; i++)
-        tb_hash[i] = NULL;
+    memset (tb_hash, 0, CODE_GEN_HASH_SIZE * sizeof (void *));
 
 #if !defined(CONFIG_SOFTMMU)
     munmap((void *)MMAP_AREA_START, MMAP_AREA_END - MMAP_AREA_START);

[-- Attachment #1.3: Type: text/plain, Size: 23 bytes --]



Servus,
       Daniel

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 478 bytes --]

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

end of thread, other threads:[~2004-10-04  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-03 11:45 [Qemu-devel] [Patch] Clear memory using memset instead of handcoded loop Daniel Egger
2004-10-03 13:38 ` Fabrice Bellard
2004-10-03 18:17 ` Karl Magdsick
2004-10-04  0:15   ` Daniel Egger

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).