From b96bf5c9691850722922346fc12e52def944f6f5 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 15 Aug 2023 14:41:23 -0700 Subject: [PATCH] libsysprof: increase priority of mapped ring buffer source We want to reduce the chances we've lost anything in these, which is pretty important for memory tracing. --- src/libsysprof/mapped-ring-buffer-source-private.h | 3 ++- src/libsysprof/mapped-ring-buffer-source.c | 8 +++++--- src/libsysprof/sysprof-controlfd-instrument.c | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libsysprof/mapped-ring-buffer-source-private.h b/src/libsysprof/mapped-ring-buffer-source-private.h index 1867e6ff..81c6fcaa 100644 --- a/src/libsysprof/mapped-ring-buffer-source-private.h +++ b/src/libsysprof/mapped-ring-buffer-source-private.h @@ -33,7 +33,8 @@ guint mapped_ring_buffer_create_source (MappedRingBuffer *self, MappedRingBufferCallback callback, gpointer user_data); G_GNUC_INTERNAL -guint mapped_ring_buffer_create_source_full (MappedRingBuffer *self, +guint mapped_ring_buffer_create_source_full (int priority, + MappedRingBuffer *self, MappedRingBufferCallback callback, gpointer user_data, GDestroyNotify destroy); diff --git a/src/libsysprof/mapped-ring-buffer-source.c b/src/libsysprof/mapped-ring-buffer-source.c index a0a939e7..bf40fc0d 100644 --- a/src/libsysprof/mapped-ring-buffer-source.c +++ b/src/libsysprof/mapped-ring-buffer-source.c @@ -89,7 +89,8 @@ static GSourceFuncs mapped_ring_source_funcs = { }; guint -mapped_ring_buffer_create_source_full (MappedRingBuffer *self, +mapped_ring_buffer_create_source_full (int priority, + MappedRingBuffer *self, MappedRingBufferCallback source_func, gpointer user_data, GDestroyNotify destroy) @@ -103,7 +104,8 @@ mapped_ring_buffer_create_source_full (MappedRingBuffer *self, source = (MappedRingSource *)g_source_new (&mapped_ring_source_funcs, sizeof (MappedRingSource)); source->buffer = mapped_ring_buffer_ref (self); g_source_set_callback ((GSource *)source, (GSourceFunc)source_func, user_data, destroy); - g_source_set_name ((GSource *)source, "MappedRingSource"); + g_source_set_static_name ((GSource *)source, "MappedRingSource"); + g_source_set_priority ((GSource *)source, priority); ret = g_source_attach ((GSource *)source, g_main_context_default ()); g_source_unref ((GSource *)source); @@ -115,5 +117,5 @@ mapped_ring_buffer_create_source (MappedRingBuffer *self, MappedRingBufferCallback source_func, gpointer user_data) { - return mapped_ring_buffer_create_source_full (self, source_func, user_data, NULL); + return mapped_ring_buffer_create_source_full (G_PRIORITY_DEFAULT, self, source_func, user_data, NULL); } diff --git a/src/libsysprof/sysprof-controlfd-instrument.c b/src/libsysprof/sysprof-controlfd-instrument.c index 6ee569cc..8860b444 100644 --- a/src/libsysprof/sysprof-controlfd-instrument.c +++ b/src/libsysprof/sysprof-controlfd-instrument.c @@ -241,7 +241,8 @@ sysprof_controlfd_instrument_record_fiber (gpointer user_data) ring_data = g_new0 (RingData, 1); ring_data->writer = sysprof_capture_writer_ref (temp_writer); ring_data->source_ids = g_array_ref (state->source_ids); - ring_data->id = mapped_ring_buffer_create_source_full (ring_buffer, + ring_data->id = mapped_ring_buffer_create_source_full (G_PRIORITY_HIGH, + ring_buffer, sysprof_controlfd_instrument_frame_cb, ring_data, (GDestroyNotify)ring_data_free);