From c2e0d600ed76f6767d59715d93cf862808552ea2 Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Sun, 10 Nov 2013 23:21:15 +0100 Subject: analyze: plot the time spent setting up security modules --- src/analyze/analyze.c | 17 +++++++++++++++++ src/core/dbus-manager.c | 8 ++++++++ src/core/main.c | 6 ++++++ src/core/manager.h | 2 ++ 4 files changed, 33 insertions(+) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index b80b91c5b7..eb85276b40 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -83,6 +83,8 @@ struct boot_times { usec_t initrd_time; usec_t userspace_time; usec_t finish_time; + usec_t security_start_time; + usec_t security_finish_time; usec_t generators_start_time; usec_t generators_finish_time; usec_t unitsload_start_time; @@ -321,6 +323,16 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) { "org.freedesktop.systemd1.Manager", "FinishTimestampMonotonic", ×.finish_time) < 0 || + bus_get_uint64_property(bus, + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "SecurityStartTimestampMonotonic", + ×.security_start_time) < 0 || + bus_get_uint64_property(bus, + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "SecurityFinishTimestampMonotonic", + ×.security_finish_time) < 0 || bus_get_uint64_property(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", @@ -523,6 +535,7 @@ static int analyze_plot(sd_bus *bus) { " rect.firmware { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.loader { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" " rect.userspace { fill: rgb(150,150,150); fill-opacity: 0.7; }\n" + " rect.security { fill: rgb(144,238,144); fill-opacity: 0.7; }\n" " rect.generators { fill: rgb(102,204,255); fill-opacity: 0.7; }\n" " rect.unitsload { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n" " rect.box { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n" @@ -566,6 +579,7 @@ static int analyze_plot(sd_bus *bus) { y++; } svg_bar("active", boot->userspace_time, boot->finish_time, y); + svg_bar("security", boot->security_start_time, boot->security_finish_time, y); svg_bar("generators", boot->generators_start_time, boot->generators_finish_time, y); svg_bar("unitsload", boot->unitsload_start_time, boot->unitsload_finish_time, y); svg_text(true, boot->userspace_time, y, "systemd"); @@ -603,6 +617,9 @@ static int analyze_plot(sd_bus *bus) { svg_bar("deactivating", 0, 300000, y); svg_text(true, 400000, y, "Deactivating"); y++; + svg_bar("security", 0, 300000, y); + svg_text(true, 400000, y, "Setting up security module"); + y++; svg_bar("generators", 0, 300000, y); svg_text(true, 400000, y, "Generators"); y++; diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index b47fc85101..747bcfcb91 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -271,6 +271,10 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -583,6 +587,10 @@ static const BusProperty bus_manager_properties[] = { { "UserspaceTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, userspace_timestamp.monotonic) }, { "FinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.realtime) }, { "FinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.monotonic) }, + { "SecurityStartTimestamp", bus_property_append_uint64, "t", offsetof(Manager, security_start_timestamp.realtime) }, + { "SecurityStartTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, security_start_timestamp.monotonic) }, + { "SecurityFinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, security_finish_timestamp.realtime) }, + { "SecurityFinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, security_finish_timestamp.monotonic) }, { "GeneratorsStartTimestamp", bus_property_append_uint64, "t", offsetof(Manager, generators_start_timestamp.realtime) }, { "GeneratorsStartTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, generators_start_timestamp.monotonic) }, { "GeneratorsFinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, generators_finish_timestamp.realtime) }, diff --git a/src/core/main.c b/src/core/main.c index ede1a121c6..c89c12343e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1201,6 +1201,8 @@ int main(int argc, char *argv[]) { dual_timestamp initrd_timestamp = { 0ULL, 0ULL }; dual_timestamp userspace_timestamp = { 0ULL, 0ULL }; dual_timestamp kernel_timestamp = { 0ULL, 0ULL }; + dual_timestamp security_start_timestamp = { 0ULL, 0ULL }; + dual_timestamp security_finish_timestamp = { 0ULL, 0ULL }; static char systemd[] = "systemd"; bool skip_setup = false; int j; @@ -1265,12 +1267,14 @@ int main(int argc, char *argv[]) { if (!skip_setup) { mount_setup_early(); + dual_timestamp_get(&security_start_timestamp); if (selinux_setup(&loaded_policy) < 0) goto finish; if (ima_setup() < 0) goto finish; if (smack_setup() < 0) goto finish; + dual_timestamp_get(&security_finish_timestamp); } if (label_init(NULL) < 0) @@ -1541,6 +1545,8 @@ int main(int argc, char *argv[]) { m->userspace_timestamp = userspace_timestamp; m->kernel_timestamp = kernel_timestamp; m->initrd_timestamp = initrd_timestamp; + m->security_start_timestamp = security_start_timestamp; + m->security_finish_timestamp = security_finish_timestamp; manager_set_default_rlimits(m, arg_default_rlimit); diff --git a/src/core/manager.h b/src/core/manager.h index 150525ee13..b043970340 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -153,6 +153,8 @@ struct Manager { dual_timestamp initrd_timestamp; dual_timestamp userspace_timestamp; dual_timestamp finish_timestamp; + dual_timestamp security_start_timestamp; + dual_timestamp security_finish_timestamp; dual_timestamp generators_start_timestamp; dual_timestamp generators_finish_timestamp; dual_timestamp unitsload_start_timestamp; -- cgit v1.2.3-54-g00ecf