mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
governor: disable paranoid setting in governor source
This could be it's own source, but it's nice to have it in one place with our performance tooling.
This commit is contained in:
@ -29,6 +29,7 @@ struct _SysprofGovernorSource
|
||||
{
|
||||
GObject parent_instance;
|
||||
gchar *old_governor;
|
||||
int old_paranoid;
|
||||
guint disable_governor : 1;
|
||||
};
|
||||
|
||||
@ -108,7 +109,7 @@ sysprof_governor_source_class_init (SysprofGovernorSourceClass *klass)
|
||||
"Disable Governor",
|
||||
TRUE,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
@ -176,6 +177,28 @@ sysprof_governor_source_deserialize (SysprofSource *source,
|
||||
g_key_file_get_boolean (keyfile, group, "disable-governor", NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
disable_paranoid_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofHelpers *helpers = (SysprofHelpers *)object;
|
||||
g_autoptr(SysprofGovernorSource) self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
int old_paranoid;
|
||||
|
||||
g_assert (SYSPROF_IS_HELPERS (helpers));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
g_assert (SYSPROF_IS_GOVERNOR_SOURCE (self));
|
||||
|
||||
if (!sysprof_helpers_set_paranoid_finish (helpers, result, &old_paranoid, &error))
|
||||
g_warning ("Failed to change perf_event_paranoid: %s", error->message);
|
||||
else
|
||||
self->old_paranoid = old_paranoid;
|
||||
|
||||
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
disable_governor_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@ -195,7 +218,33 @@ disable_governor_cb (GObject *object,
|
||||
else
|
||||
self->old_governor = g_steal_pointer (&old_governor);
|
||||
|
||||
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
|
||||
/* Now tweak paranoid setting */
|
||||
sysprof_helpers_set_paranoid_async (helpers,
|
||||
-1,
|
||||
NULL,
|
||||
disable_paranoid_cb,
|
||||
g_steal_pointer (&self));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
enable_paranoid_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofHelpers *helpers = (SysprofHelpers *)object;
|
||||
g_autoptr(SysprofGovernorSource) self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
int old_governor;
|
||||
|
||||
g_assert (SYSPROF_IS_HELPERS (helpers));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
g_assert (SYSPROF_IS_GOVERNOR_SOURCE (self));
|
||||
|
||||
if (!sysprof_helpers_set_paranoid_finish (helpers, result, &old_governor, &error))
|
||||
g_warning ("Failed to change event_perf_paranoid: %s", error->message);
|
||||
|
||||
sysprof_source_emit_finished (SYSPROF_SOURCE (self));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -207,6 +256,7 @@ enable_governor_cb (GObject *object,
|
||||
g_autoptr(SysprofGovernorSource) self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autofree gchar *old_governor = NULL;
|
||||
int previous;
|
||||
|
||||
g_assert (SYSPROF_IS_HELPERS (helpers));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
@ -217,7 +267,13 @@ enable_governor_cb (GObject *object,
|
||||
|
||||
g_clear_pointer (&self->old_governor, g_free);
|
||||
|
||||
sysprof_source_emit_finished (SYSPROF_SOURCE (self));
|
||||
/* Restore paranoid setting */
|
||||
previous = self->old_paranoid;
|
||||
sysprof_helpers_set_paranoid_async (helpers,
|
||||
previous,
|
||||
NULL,
|
||||
enable_paranoid_cb,
|
||||
g_steal_pointer (&self));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user