[sysprof] governor: always disable paranoid status
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] governor: always disable paranoid status
- Date: Wed, 24 Feb 2021 22:01:13 +0000 (UTC)
commit 86fb061899c4bb85313927f4d717c8b2ede4252c
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 24 12:19:36 2021 -0800
governor: always disable paranoid status
This allows us to always attempt to disable the perf_event_paranoid
setting to -1 while we profile.
src/libsysprof/sysprof-governor-source.c | 102 +++++++++++++++----------------
1 file changed, 49 insertions(+), 53 deletions(-)
---
diff --git a/src/libsysprof/sysprof-governor-source.c b/src/libsysprof/sysprof-governor-source.c
index 794d1bf..7c2f67a 100644
--- a/src/libsysprof/sysprof-governor-source.c
+++ b/src/libsysprof/sysprof-governor-source.c
@@ -117,6 +117,7 @@ static void
sysprof_governor_source_init (SysprofGovernorSource *self)
{
self->disable_governor = FALSE;
+ self->old_paranoid = 2;
}
SysprofSource *
@@ -178,73 +179,69 @@ sysprof_governor_source_deserialize (SysprofSource *source,
}
static void
-disable_paranoid_cb (GObject *object,
+disable_governor_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_autofree gchar *old_governor = NULL;
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);
+ if (!sysprof_helpers_set_governor_finish (helpers, result, &old_governor, &error))
+ g_warning ("Failed to change governor: %s", error->message);
else
- self->old_paranoid = old_paranoid;
+ self->old_governor = g_steal_pointer (&old_governor);
sysprof_source_emit_ready (SYSPROF_SOURCE (self));
}
static void
-disable_governor_cb (GObject *object,
+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;
- g_autofree gchar *old_governor = 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_governor_finish (helpers, result, &old_governor, &error))
- g_warning ("Failed to change governor: %s", error->message);
+ 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_governor = g_steal_pointer (&old_governor);
+ self->old_paranoid = old_paranoid;
- /* Now tweak paranoid setting */
- sysprof_helpers_set_paranoid_async (helpers,
- -1,
- NULL,
- disable_paranoid_cb,
- g_steal_pointer (&self));
+ if (!self->disable_governor)
+ sysprof_source_emit_ready (SYSPROF_SOURCE (self));
+ else
+ sysprof_helpers_set_governor_async (helpers,
+ "performance",
+ NULL,
+ disable_governor_cb,
+ g_steal_pointer (&self));
}
-
static void
-enable_paranoid_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
+sysprof_governor_source_prepare (SysprofSource *source)
{
- SysprofHelpers *helpers = (SysprofHelpers *)object;
- g_autoptr(SysprofGovernorSource) self = user_data;
- g_autoptr(GError) error = NULL;
- int old_governor;
+ SysprofGovernorSource *self = (SysprofGovernorSource *)source;
+ SysprofHelpers *helpers = sysprof_helpers_get_default ();
- 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));
+ sysprof_helpers_set_paranoid_async (helpers,
+ -1,
+ NULL,
+ disable_paranoid_cb,
+ g_object_ref (self));
}
static void
@@ -256,7 +253,6 @@ 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));
@@ -267,31 +263,34 @@ enable_governor_cb (GObject *object,
g_clear_pointer (&self->old_governor, g_free);
- /* Restore paranoid setting */
- previous = self->old_paranoid;
- sysprof_helpers_set_paranoid_async (helpers,
- previous,
- NULL,
- enable_paranoid_cb,
- g_steal_pointer (&self));
+ sysprof_source_emit_finished (SYSPROF_SOURCE (self));
}
static void
-sysprof_governor_source_prepare (SysprofSource *source)
+enable_paranoid_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- SysprofGovernorSource *self = (SysprofGovernorSource *)source;
- SysprofHelpers *helpers = sysprof_helpers_get_default ();
+ 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);
+
if (!self->disable_governor)
- sysprof_source_emit_ready (source);
+ sysprof_source_emit_finished (SYSPROF_SOURCE (self));
else
sysprof_helpers_set_governor_async (helpers,
- "performance",
+ self->old_governor,
NULL,
- disable_governor_cb,
- g_object_ref (self));
+ enable_governor_cb,
+ g_steal_pointer (&self));
}
static void
@@ -302,14 +301,11 @@ sysprof_governor_source_stop (SysprofSource *source)
g_assert (SYSPROF_IS_GOVERNOR_SOURCE (self));
- if (self->old_governor == NULL)
- sysprof_source_emit_finished (source);
- else
- sysprof_helpers_set_governor_async (helpers,
- self->old_governor,
- NULL,
- enable_governor_cb,
- g_object_ref (self));
+ sysprof_helpers_set_paranoid_async (helpers,
+ self->old_paranoid,
+ NULL,
+ enable_paranoid_cb,
+ g_object_ref (self));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]