qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: pl@kamp.de, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 06/19] buffer: add tracing
Date: Fri, 30 Oct 2015 12:10:01 +0100	[thread overview]
Message-ID: <1446203414-4013-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1446203414-4013-1-git-send-email-kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 trace-events  |  6 ++++++
 util/buffer.c | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/trace-events b/trace-events
index bdfe79f..050d45b 100644
--- a/trace-events
+++ b/trace-events
@@ -1387,6 +1387,12 @@ ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "ad
 prep_io_800_writeb(uint32_t addr, uint32_t val) "0x%08" PRIx32 " => 0x%02" PRIx32
 prep_io_800_readb(uint32_t addr, uint32_t retval) "0x%08" PRIx32 " <= 0x%02" PRIx32
 
+# io/buffer.c
+buffer_resize(const char *buf, size_t olen, size_t len) "%s: old %zd, new %zd"
+buffer_move_empty(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
+buffer_move(const char *buf, size_t len, const char *from) "%s: %zd bytes from %s"
+buffer_free(const char *buf, size_t len) "%s: capacity %zd"
+
 # util/hbitmap.c
 hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
 hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
diff --git a/util/buffer.c b/util/buffer.c
index 234e33d..ae2907e 100644
--- a/util/buffer.c
+++ b/util/buffer.c
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/buffer.h"
+#include "trace.h"
 
 #define BUFFER_MIN_INIT_SIZE     4096
 #define BUFFER_MIN_SHRINK_SIZE  65536
@@ -34,6 +35,8 @@ void buffer_init(Buffer *buffer, const char *name, ...)
 
 void buffer_shrink(Buffer *buffer)
 {
+    size_t old;
+
     /*
      * Only shrink in case the used size is *much* smaller than the
      * capacity, to avoid bumping up & down the buffers all the time.
@@ -44,17 +47,25 @@ void buffer_shrink(Buffer *buffer)
         return;
     }
 
+    old = buffer->capacity;
     buffer->capacity = pow2ceil(buffer->offset);
     buffer->capacity = MAX(buffer->capacity, BUFFER_MIN_SHRINK_SIZE);
     buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
+    trace_buffer_resize(buffer->name ?: "unnamed",
+                        old, buffer->capacity);
 }
 
 void buffer_reserve(Buffer *buffer, size_t len)
 {
+    size_t old;
+
     if ((buffer->capacity - buffer->offset) < len) {
+        old = buffer->capacity;
         buffer->capacity = pow2ceil(buffer->offset + len);
         buffer->capacity = MAX(buffer->capacity, BUFFER_MIN_INIT_SIZE);
         buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
+        trace_buffer_resize(buffer->name ?: "unnamed",
+                            old, buffer->capacity);
     }
 }
 
@@ -75,6 +86,7 @@ void buffer_reset(Buffer *buffer)
 
 void buffer_free(Buffer *buffer)
 {
+    trace_buffer_free(buffer->name ?: "unnamed", buffer->capacity);
     g_free(buffer->buffer);
     g_free(buffer->name);
     buffer->offset = 0;
@@ -98,6 +110,9 @@ void buffer_advance(Buffer *buffer, size_t len)
 
 void buffer_move_empty(Buffer *to, Buffer *from)
 {
+    trace_buffer_move_empty(to->name ?: "unnamed",
+                            from->offset,
+                            from->name ?: "unnamed");
     assert(to->offset == 0);
 
     g_free(to->buffer);
@@ -117,6 +132,9 @@ void buffer_move(Buffer *to, Buffer *from)
         return;
     }
 
+    trace_buffer_move(to->name ?: "unnamed",
+                      from->offset,
+                      from->name ?: "unnamed");
     buffer_reserve(to, from->offset);
     buffer_append(to, from->buffer, from->offset);
 
-- 
1.8.3.1

  parent reply	other threads:[~2015-10-30 11:10 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 11:09 [Qemu-devel] [PATCH 00/19] buffer/vnc: improve vnc buffer hsndling Gerd Hoffmann
2015-10-30 11:09 ` [Qemu-devel] [PATCH 01/19] buffer: make the Buffer capacity increase in powers of two Gerd Hoffmann
2015-10-30 12:06   ` Daniel P. Berrange
2015-10-30 11:09 ` [Qemu-devel] [PATCH 02/19] buffer: add buffer_init Gerd Hoffmann
2015-10-30 12:07   ` Daniel P. Berrange
2015-10-30 11:09 ` [Qemu-devel] [PATCH 03/19] buffer: add buffer_move_empty Gerd Hoffmann
2015-10-30 12:11   ` Daniel P. Berrange
2015-10-30 12:34     ` Daniel P. Berrange
2015-10-30 11:09 ` [Qemu-devel] [PATCH 04/19] buffer: add buffer_move Gerd Hoffmann
2015-10-30 12:12   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 05/19] buffer: add buffer_shrink Gerd Hoffmann
2015-10-30 12:13   ` Daniel P. Berrange
2015-10-30 11:10 ` Gerd Hoffmann [this message]
2015-10-30 12:14   ` [Qemu-devel] [PATCH 06/19] buffer: add tracing Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 07/19] vnc: attach names to buffers Gerd Hoffmann
2015-10-30 12:15   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 08/19] vnc: kill jobs queue buffer Gerd Hoffmann
2015-10-30 12:16   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 09/19] vnc-jobs: move buffer reset, use new buffer move Gerd Hoffmann
2015-10-30 12:17   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 10/19] vnc: zap dead code Gerd Hoffmann
2015-10-30 12:18   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 11/19] vnc: add vnc_width+vnc_height helpers Gerd Hoffmann
2015-10-30 12:19   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 12/19] vnc: factor out vnc_update_server_surface Gerd Hoffmann
2015-10-30 12:22   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 13/19] vnc: use vnc_{width, height} in vnc_set_area_dirty Gerd Hoffmann
2015-10-30 12:23   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 14/19] vnc: only alloc server surface with clients connected Gerd Hoffmann
2015-10-30 12:24   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 15/19] vnc: fix local state init Gerd Hoffmann
2015-10-30 12:26   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 16/19] vnc: recycle empty vs->output buffer Gerd Hoffmann
2015-10-30 12:27   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 17/19] buffer: factor out buffer_req_size Gerd Hoffmann
2015-10-30 12:28   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 18/19] buffer: factor out buffer_adj_size Gerd Hoffmann
2015-10-30 12:29   ` Daniel P. Berrange
2015-10-30 11:10 ` [Qemu-devel] [PATCH 19/19] buffer: allow a buffer to shrink gracefully Gerd Hoffmann
2015-10-30 12:33   ` Daniel P. Berrange
2015-11-03  7:10   ` Peter Lieven
2015-10-30 12:36 ` [Qemu-devel] [PATCH 00/19] buffer/vnc: improve vnc buffer hsndling Daniel P. Berrange
2015-11-03  7:13 ` Peter Lieven
2015-11-03  8:23   ` Gerd Hoffmann
2015-11-03  9:01     ` Peter Lieven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446203414-4013-7-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).