From patchwork Sat May 22 21:08:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 101679 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4ML8hoF030929 for ; Sat, 22 May 2010 21:08:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758380Ab0EVVIj (ORCPT ); Sat, 22 May 2010 17:08:39 -0400 Received: from mtagate6.de.ibm.com ([195.212.17.166]:44140 "EHLO mtagate6.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758278Ab0EVVIh (ORCPT ); Sat, 22 May 2010 17:08:37 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate6.de.ibm.com (8.13.1/8.13.1) with ESMTP id o4ML8WGu021521 for ; Sat, 22 May 2010 21:08:32 GMT Received: from d12av04.megacenter.de.ibm.com (d12av04.megacenter.de.ibm.com [9.149.165.229]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o4ML8WNJ909394 for ; Sat, 22 May 2010 23:08:32 +0200 Received: from d12av04.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o4ML8VmT021999 for ; Sat, 22 May 2010 23:08:31 +0200 Received: from stefan-thinkpad.ibm.com (sig-9-145-133-4.de.ibm.com [9.145.133.4]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o4ML8SrS021941; Sat, 22 May 2010 23:08:30 +0200 From: Stefan Hajnoczi To: , Cc: Jan Kiszka , Prerna Saxena , Anthony Liguori , Stefan Hajnoczi Subject: [PATCH 4/5] trace: Trace qemu_malloc() and qemu_vmalloc() Date: Sat, 22 May 2010 22:08:22 +0100 Message-Id: <1274562503-10713-5-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274562503-10713-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1274562503-10713-1-git-send-email-stefanha@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 22 May 2010 21:08:43 +0000 (UTC) diff --git a/osdep.c b/osdep.c index abbc8a2..8e4b8ea 100644 --- a/osdep.c +++ b/osdep.c @@ -50,6 +50,7 @@ #endif #include "qemu-common.h" +#include "trace.h" #include "sysemu.h" #include "qemu_socket.h" @@ -71,6 +72,8 @@ static void *oom_check(void *ptr) #if defined(_WIN32) void *qemu_memalign(size_t alignment, size_t size) { + trace_qemu_memalign(alignment, size); + if (!size) { abort(); } @@ -79,6 +82,8 @@ void *qemu_memalign(size_t alignment, size_t size) void *qemu_vmalloc(size_t size) { + trace_qemu_vmalloc(size); + /* FIXME: this is not exactly optimal solution since VirtualAlloc has 64Kb granularity, but at least it guarantees us that the memory is page aligned. */ @@ -90,6 +95,7 @@ void *qemu_vmalloc(size_t size) void qemu_vfree(void *ptr) { + trace_qemu_vfree(ptr); VirtualFree(ptr, 0, MEM_RELEASE); } @@ -97,6 +103,8 @@ void qemu_vfree(void *ptr) void *qemu_memalign(size_t alignment, size_t size) { + trace_qemu_memalign(alignment, size); + #if defined(_POSIX_C_SOURCE) && !defined(__sun__) int ret; void *ptr; @@ -122,6 +130,7 @@ void *qemu_vmalloc(size_t size) void qemu_vfree(void *ptr) { + trace_qemu_vfree(ptr); free(ptr); } diff --git a/qemu-malloc.c b/qemu-malloc.c index 6cdc5de..69fc3cf 100644 --- a/qemu-malloc.c +++ b/qemu-malloc.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" +#include "trace.h" #include static void *oom_check(void *ptr) @@ -39,6 +40,7 @@ void *get_mmap_addr(unsigned long size) void qemu_free(void *ptr) { + trace_qemu_free(ptr); free(ptr); } @@ -53,6 +55,7 @@ static int allow_zero_malloc(void) void *qemu_malloc(size_t size) { + trace_qemu_malloc(size); if (!size && !allow_zero_malloc()) { abort(); } @@ -61,6 +64,7 @@ void *qemu_malloc(size_t size) void *qemu_realloc(void *ptr, size_t size) { + trace_qemu_realloc(ptr, size); if (!size && !allow_zero_malloc()) { abort(); } diff --git a/trace-events b/trace-events index a37d3cc..a93ea29 100644 --- a/trace-events +++ b/trace-events @@ -22,3 +22,13 @@ # system may not have the necessary headers included. # # The should be a sprintf()-compatible format string. + +# qemu-malloc.c +qemu_malloc(size_t size) "size %zu" +qemu_realloc(void *ptr, size_t size) "ptr %p size %zu" +qemu_free(void *ptr) "ptr %p" + +# osdep.c +qemu_memalign(size_t alignment, size_t size) "alignment %zu size %zu" +qemu_valloc(size_t size) "size %zu" +qemu_vfree(void *ptr) "ptr %p"