[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/3] trace: Example of "centralized" recorder tracing
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH v2 3/3] trace: Example of "centralized" recorder tracing |
Date: |
Tue, 30 Jun 2020 13:41:36 +0100 |
User-agent: |
Mutt/1.14.3 (2020-06-14) |
On Fri, Jun 26, 2020 at 06:27:06PM +0200, Christophe de Dinechin wrote:
> This is an example showing how the recorder can be used to have one
> "topic" covering multiple entries. Here, the topic is "lock".
>
> Here are a few use cases:
>
> - Checking locks:
> RECORDER_TRACES=lock qemu
> - Graphic visualization of locks:
> RECORDER_TRACES="lock=state,id" qemu &
> recorder_scope state
> <Hit the 't' key to toggle timing display>
> <Hit the 'c' key to dump the screen data as CSV>
> cat recorder_scope_data-1.csv
>
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
> util/qemu-thread-common.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/util/qemu-thread-common.h b/util/qemu-thread-common.h
> index 2af6b12085..0de07a471f 100644
> --- a/util/qemu-thread-common.h
> +++ b/util/qemu-thread-common.h
> @@ -15,6 +15,9 @@
>
> #include "qemu/thread.h"
> #include "trace.h"
> +#include "trace/recorder.h"
> +
> +RECORDER_DEFINE(lock, 16, "Lock state");
>
> static inline void qemu_mutex_post_init(QemuMutex *mutex)
> {
> @@ -23,12 +26,14 @@ static inline void qemu_mutex_post_init(QemuMutex *mutex)
> mutex->line = 0;
> #endif
> mutex->initialized = true;
> + record(lock, "Init state %d for %p", -1, mutex);
> }
>
> static inline void qemu_mutex_pre_lock(QemuMutex *mutex,
> const char *file, int line)
> {
> trace_qemu_mutex_lock(mutex, file, line);
> + record(lock, "Locking state %d for %p", 1, mutex);
> }
>
> static inline void qemu_mutex_post_lock(QemuMutex *mutex,
> @@ -39,6 +44,7 @@ static inline void qemu_mutex_post_lock(QemuMutex *mutex,
> mutex->line = line;
> #endif
> trace_qemu_mutex_locked(mutex, file, line);
> + record(lock, "Locked state %d for %p", 2, mutex);
> }
>
> static inline void qemu_mutex_pre_unlock(QemuMutex *mutex,
> @@ -49,6 +55,7 @@ static inline void qemu_mutex_pre_unlock(QemuMutex *mutex,
> mutex->line = 0;
> #endif
> trace_qemu_mutex_unlock(mutex, file, line);
> + record(lock, "Unkocked state %d for %p", 0, mutex);
> }
IMHO the whole point of having the pluggable trace backend impls, is
precisely that we don't have to add multiple different calls in the
code. A single trace_qemu_mutex_unlock() is supposed to work with
any backend.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- [PATCH v2 0/3] trace: Add a trace backend for the recorder library, Christophe de Dinechin, 2020/06/26
- [PATCH v2 1/3] Makefile: Compute libraries for libqemuutil.a and libvhost-user.a, Christophe de Dinechin, 2020/06/26
- [PATCH v2 2/3] trace: Add support for recorder back-end, Christophe de Dinechin, 2020/06/26
- [PATCH v2 3/3] trace: Example of "centralized" recorder tracing, Christophe de Dinechin, 2020/06/26
- Re: [PATCH v2 0/3] trace: Add a trace backend for the recorder library, no-reply, 2020/06/26
- Re: [PATCH v2 0/3] trace: Add a trace backend for the recorder library, Stefan Hajnoczi, 2020/06/30