@@ -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);
}
#endif
This patch is a simple example showing how the recorder can be used to have one "topic" covering multiple entries. Here, the topic is "lock", the idea being to have the latest lock changes for instance in case of a crash or hang. Here are a few use cases: * Tracing lock updates: RECORDER_TRACES=lock qemu * Showing lock changes prior to a hang RECORDER_TRACES=lock qemu & # Wait until hang killall -USR2 qemu # This will trigger a dump * Graphic visualization of lock states: 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(+)