Add CPU usage measurement 39/233839/2
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 19 May 2020 10:31:35 +0000 (12:31 +0200)
committerMateusz Majewski <m.majewski2@samsung.com>
Wed, 20 May 2020 12:02:59 +0000 (14:02 +0200)
Change-Id: I123a926433fd456e1860dd6cc9572a3ffe0e2d0c

Makefile.am
configs/dlog-logger.conf.cpu [new file with mode: 0644]
configs/dlog-pipe.conf.cpu [new file with mode: 0644]
configure.ac
packaging/dlog.spec
tests/dlog_cpu.in [new file with mode: 0644]

index 7929dc1..95e7636 100644 (file)
@@ -539,7 +539,9 @@ pkgconfig_DATA = dlog.pc dlogutil.pc
 
 data_DATA = \
        configs/dlog-pipe.conf.test \
-       configs/dlog-logger.conf.test
+       configs/dlog-logger.conf.test \
+       configs/dlog-pipe.conf.cpu \
+       configs/dlog-logger.conf.cpu
 
 unitdir = $(prefix)/lib/systemd/system
 nodist_unit_DATA = configs/dlog_logger.service \
@@ -556,7 +558,7 @@ dlogconf_DATA = \
        configs/25-logger.conf \
        configs/99-dlog-logger.disable-platform-logging-for-testsuite.conf
 
-bin_SCRIPTS = dlog_test
+bin_SCRIPTS = dlog_test dlog_cpu
 
 docdir = $(datadir)/doc/dlog
 doc_DATA = \
diff --git a/configs/dlog-logger.conf.cpu b/configs/dlog-logger.conf.cpu
new file mode 100644 (file)
index 0000000..f264e55
--- /dev/null
@@ -0,0 +1,44 @@
+##### Settings used by the logging library
+backend=logger
+main=/dev/log_main
+apps=/dev/log_apps:/dev/log_events:
+system=/dev/log_system:
+radio=/dev/log_radio:
+
+main_size=1048576
+apps_size=1048576
+system_size=1048576
+radio_size=1048576
+
+plog=1
+debugmode=1
+limiter=1
+limiter|*|*=allow
+kmsg=:
+syslog=:
+
+kmsg_write_sock=/run/dlog/kmsg.wr
+syslog_write_sock=/run/dlog/syslog.wr
+
+kmsg_ctl_sock=/run/dlog/kmsg.ctl
+syslog_ctl_sock=/run/dlog/syslog.ctl
+
+kmsg_write_sock_rights=0222
+syslog_write_sock_rights=0222
+
+kmsg_ctl_sock_rights=0222
+syslog_ctl_sock_rights=0222
+
+kmsg_size=1048576
+syslog_size=1048576
+
+util_sorting_time_window=1000
+
+dlog_logger_conf_system=dlogutil -b system -r 2048 -n 1 -f /tmp/dlog-writers/system -v threadtime *:I
+dlog_logger_conf_main=dlogutil -b main -r 1024 -n 1 -f /tmp/dlog-writers/main -v threadtime *:W
+dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /tmp/dlog-writers/radio -v threadtime
+util_sorting_buffer_size=8192
+dynamic_config_path=/tmp/dlog-filters/
+
+handle_kmsg=0
+handle_syslog=0
diff --git a/configs/dlog-pipe.conf.cpu b/configs/dlog-pipe.conf.cpu
new file mode 100644 (file)
index 0000000..c8f48b3
--- /dev/null
@@ -0,0 +1,96 @@
+# Lines starting with # are comments and are ignored.
+# Empty lines are also ignored.
+# Every other line is a config value and has to be in key=value format
+
+backend=pipe
+
+##### Settings used by the logging library
+
+# Platform logging. Whether logging happens at all.
+plog=1
+
+# Debugmode - whether write platform debug log or not
+debugmode=1
+
+# Limiter - whether it's enabled and the rules (check the documentation for how to create rules).
+limiter=1
+limiter|*|*=allow
+
+##### Settings used by the logging daemon
+
+# Sockets that all programs connect to to receive a logging pipe.
+main_write_sock=/var/lib/dlog-tests/main.wr
+apps_write_sock=/var/lib/dlog-tests/apps.wr
+system_write_sock=/var/lib/dlog-tests/system.wr
+radio_write_sock=/var/lib/dlog-tests/radio.wr
+kmsg_write_sock=/var/lib/dlog-tests/kmsg.wr
+syslog_write_sock=/var/lib/dlog-tests/syslog.wr
+
+# Sockets that administrative programs connect to to manipulate the daemon.
+main_ctl_sock=/var/lib/dlog-tests/main.ctl
+apps_ctl_sock=/var/lib/dlog-tests/apps.ctl
+system_ctl_sock=/var/lib/dlog-tests/system.ctl
+radio_ctl_sock=/var/lib/dlog-tests/radio.ctl
+kmsg_ctl_sock=/var/lib/dlog-tests/kmsg.ctl
+syslog_ctl_sock=/var/lib/dlog-tests/syslog.ctl
+
+# Permissions for the relevant sockets.
+main_write_sock_rights=0222
+apps_write_sock_rights=0222
+system_write_sock_rights=0222
+radio_write_sock_rights=0222
+kmsg_write_sock_rights=0222
+syslog_write_sock_rights=0222
+
+main_ctl_sock_rights=0222
+apps_ctl_sock_rights=0222
+system_ctl_sock_rights=0222
+radio_ctl_sock_rights=0222
+kmsg_ctl_sock_rights=0222
+syslog_ctl_sock_rights=0222
+
+main_write_sock_owner=log
+apps_write_sock_owner=log
+system_write_sock_owner=log
+radio_write_sock_owner=log
+kmsg_write_sock_owner=log
+syslog_write_sock_owner=log
+
+main_ctl_sock_owner=log
+apps_ctl_sock_owner=log
+system_ctl_sock_owner=log
+radio_ctl_sock_owner=log
+kmsg_ctl_sock_owner=log
+syslog_ctl_sock_owner=log
+
+main_write_sock_group=log
+apps_write_sock_group=log
+system_write_sock_group=log
+radio_write_sock_group=log
+kmsg_write_sock_group=log
+syslog_write_sock_group=log
+
+main_ctl_sock_group=log
+apps_ctl_sock_group=log
+system_ctl_sock_group=log
+radio_ctl_sock_group=log
+kmsg_ctl_sock_group=log
+syslog_ctl_sock_group=log
+
+main_size=1048576
+apps_size=1048576
+system_size=1048576
+radio_size=1048576
+kmsg_size=1048576
+syslog_size=1048576
+
+util_sorting_time_window=5000
+util_sorting_buffer_size=32000
+
+dynamic_config_path=/tmp/dlog-filters/
+dlog_logger_conf_system=dlogutil -b system -r 2048 -n 1 -f /tmp/dlog-writers/system -v threadtime *:I
+dlog_logger_conf_main=dlogutil -b main -r 1024 -n 1 -f /tmp/dlog-writers/main -v threadtime *:W
+dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /tmp/dlog-writers/radio -v threadtime
+
+handle_kmsg=0
+handle_syslog=0
index fdfff75..3a61cc9 100644 (file)
@@ -90,6 +90,7 @@ AC_SUBST([datadir])
 AC_SUBST([libexecdir])
 AC_CONFIG_FILES([Makefile dlog.pc dlogutil.pc]
                 [dlog_test:tests/dlog_test.in]
+                [dlog_cpu:tests/dlog_cpu.in]
                 [README.testsuite:tests/README.testsuite.in]
                 [configs/dlog_logger.service]
                 [configs/dlog_cleanup.service])
index efa57b7..810f928 100644 (file)
@@ -303,6 +303,7 @@ chsmack -e 'System' %{_libexecdir}/dlog-log-critical
 %manifest dlog.manifest
 %license LICENSE.APACHE2.0 LICENSE.MIT
 %{_bindir}/dlog_test
+%{_bindir}/dlog_cpu
 /usr/share/doc/dlog/README.testsuite
 %{_libexecdir}/libdlog/perf_libdlog
 %{_libexecdir}/libdlog/test_libdlog
@@ -310,6 +311,8 @@ chsmack -e 'System' %{_libexecdir}/dlog-log-critical
 %{_libexecdir}/libdlog/test_filters
 %{_datadir}/dlog-pipe.conf.test
 %{_datadir}/dlog-logger.conf.test
+%{_datadir}/dlog-pipe.conf.cpu
+%{_datadir}/dlog-logger.conf.cpu
 %{_sysconfdir}/dlog.conf.d/99-dlog-logger.disable-platform-logging-for-testsuite.conf
 %dir %attr(755,log,log) /var/lib/dlog-tests
 %dir %attr(755,log,log) /usr/share/dlog-filters.conf.test
diff --git a/tests/dlog_cpu.in b/tests/dlog_cpu.in
new file mode 100644 (file)
index 0000000..3c25e00
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# We don't do that here
+exec 2> /dev/null
+
+# Initialization inspired by dlog_test.in, TODO: unify somehow
+if [ $# -ne 1 ]; then
+       echo "usage: $0 pipe|logger"
+       exit 1
+fi
+
+if [ "$1" = "pipe" ]; then
+       type="pipe"
+elif [ "$1" = "logger" ]; then
+       type="logger"
+else
+       echo "usage: $0 pipe|logger"
+       exit 1
+fi
+
+NEEDS_TO_QUIT=0
+capsh --print | grep Current | grep cap_syslog > /dev/null || { echo "*** ERROR: cap_syslog missing"; NEEDS_TO_QUIT=1; }
+mount | grep ' / ' | grep rw > /dev/null || { echo "*** ERROR: root not mounted read-write"; NEEDS_TO_QUIT=1; }
+[ $NEEDS_TO_QUIT -eq 0 ] || exit 1
+
+export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.cpu"
+PATH=$PATH:@libexecdir@/libdlog/
+
+RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
+mkdir -p "$RUNTIME_FILTERS_DIR"
+
+WRITER_DIR="/tmp/dlog-writers/"
+mkdir -p "$WRITER_DIR"
+
+dlog_logger &
+LOGGER=$!
+sleep 1
+(while :; do dlogsend -c 1000 -b main -t DLOG_CPU_TEST1 hi; sleep 0.1; done) &
+TEST=$!
+sleep 10
+ps --no-headers --quick-pid $LOGGER --format %cpu
+kill $TEST
+wait $TEST
+kill $LOGGER
+wait $LOGGER
+
+rm -rf "$DLOG_CONFIG_DIR"