Skip to content

Commit 451c231

Browse files
committed
Log the frame buffer array only as reader since each frame buffer is unique for each vcpu.
1 parent 185c5bc commit 451c231

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/plugins/bap-tracing/tracing.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ static void add_new_insn_frame(VCPU *vcpu, unsigned int vcpu_index,
5353

5454
static void log_insn_reg_access(unsigned int vcpu_index, void *udata) {
5555
g_rw_lock_reader_lock(&state.vcpus_array_lock);
56-
g_rw_lock_writer_lock(&state.frame_buffer_lock);
57-
g_rw_lock_writer_lock(&state.file_lock);
56+
g_rw_lock_reader_lock(&state.frame_buffer_lock);
5857

5958
FrameBuffer *fbuf = g_ptr_array_index(state.frame_buffer, vcpu_index);
6059
VCPU *vcpu = &g_array_index(state.vcpus, VCPU, vcpu_index);
@@ -64,16 +63,17 @@ static void log_insn_reg_access(unsigned int vcpu_index, void *udata) {
6463
add_post_reg_state(vcpu, vcpu_index, current_regs, fbuf);
6564

6665
if (frame_buffer_is_full(fbuf)) {
66+
g_rw_lock_writer_lock(&state.file_lock);
6767
frame_buffer_flush_to_file(fbuf, state.file);
68+
g_rw_lock_writer_unlock(&state.file_lock);
6869
}
6970

7071
// Open new one.
7172
Instruction *insn = udata;
7273
add_new_insn_frame(vcpu, vcpu_index, fbuf, insn);
7374
add_pre_reg_state(vcpu, vcpu_index, current_regs, fbuf);
7475

75-
g_rw_lock_writer_unlock(&state.file_lock);
76-
g_rw_lock_writer_unlock(&state.frame_buffer_lock);
76+
g_rw_lock_reader_unlock(&state.frame_buffer_lock);
7777
g_rw_lock_reader_unlock(&state.vcpus_array_lock);
7878

7979
return;

0 commit comments

Comments
 (0)