[systemd-commits] 4 commits - .gitignore Makefile.am src/core src/libsystemd src/libudev

Tom Gundersen tomegun at kemper.freedesktop.org
Wed Apr 29 08:16:09 PDT 2015


 .gitignore                                        |    2 
 Makefile.am                                       |    8 
 src/core/automount.c                              |   13 
 src/core/busname.c                                |    9 
 src/core/dbus.c                                   |    2 
 src/core/device.c                                 |    2 
 src/core/job.c                                    |    4 
 src/core/manager.c                                |   14 
 src/core/mount.c                                  |   12 
 src/core/path.c                                   |    2 
 src/core/scope.c                                  |    8 
 src/core/service.c                                |   12 
 src/core/socket.c                                 |    9 
 src/core/swap.c                                   |   10 
 src/core/timer.c                                  |    4 
 src/libsystemd/sd-bus/test-bus-benchmark.c        |  371 ++++++++++++++++++++++
 src/libsystemd/sd-bus/test-bus-kernel-benchmark.c |  308 ------------------
 src/libudev/libudev-monitor.c                     |    2 
 18 files changed, 470 insertions(+), 322 deletions(-)

New commits:
commit a9beb123d19304fa6999f63d755a2bda585c1f5b
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Apr 29 17:08:18 2015 +0200

    test: rename test-bus-kernel-benchmark to test-bus-benchmark
    
    This can now benchmark more than just kdbus.

diff --git a/.gitignore b/.gitignore
index 0376e00..f550950 100644
--- a/.gitignore
+++ b/.gitignore
@@ -144,6 +144,7 @@
 /test-barrier
 /test-boot-timestamp
 /test-btrfs
+/test-bus-benchmark
 /test-bus-chat
 /test-bus-cleanup
 /test-bus-creds
@@ -151,7 +152,6 @@
 /test-bus-gvariant
 /test-bus-introspect
 /test-bus-kernel
-/test-bus-kernel-benchmark
 /test-bus-kernel-bloom
 /test-bus-marshal
 /test-bus-match
diff --git a/Makefile.am b/Makefile.am
index 29ffcbb..164bdfb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3120,13 +3120,13 @@ lib_LTLIBRARIES += \
 tests += \
 	test-bus-marshal \
 	test-bus-signature \
+	test-bus-benchmark \
 	test-bus-chat \
 	test-bus-cleanup \
 	test-bus-server \
 	test-bus-match \
 	test-bus-kernel \
 	test-bus-kernel-bloom \
-	test-bus-kernel-benchmark \
 	test-bus-zero-copy \
 	test-bus-introspect \
 	test-bus-objects \
@@ -3258,10 +3258,10 @@ test_bus_kernel_bloom_LDADD = \
 	libsystemd-internal.la \
 	libsystemd-shared.la
 
-test_bus_kernel_benchmark_SOURCES = \
-	src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
+test_bus_benchmark_SOURCES = \
+	src/libsystemd/sd-bus/test-bus-benchmark.c
 
-test_bus_kernel_benchmark_LDADD = \
+test_bus_benchmark_LDADD = \
 	libsystemd-internal.la \
 	libsystemd-shared.la
 
diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c
new file mode 100644
index 0000000..d14110a
--- /dev/null
+++ b/src/libsystemd/sd-bus/test-bus-benchmark.c
@@ -0,0 +1,371 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <sys/wait.h>
+
+#include "def.h"
+#include "util.h"
+#include "time-util.h"
+
+#include "sd-bus.h"
+#include "bus-kernel.h"
+#include "bus-internal.h"
+#include "bus-util.h"
+
+#define MAX_SIZE (2*1024*1024)
+
+static usec_t arg_loop_usec = 100 * USEC_PER_MSEC;
+
+typedef enum Type {
+        TYPE_KDBUS,
+        TYPE_LEGACY,
+        TYPE_DIRECT,
+} Type;
+
+static void server(sd_bus *b, size_t *result) {
+        int r;
+
+        for (;;) {
+                _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+
+                r = sd_bus_process(b, &m);
+                assert_se(r >= 0);
+
+                if (r == 0)
+                        assert_se(sd_bus_wait(b, USEC_INFINITY) >= 0);
+                if (!m)
+                        continue;
+
+                if (sd_bus_message_is_method_call(m, "benchmark.server", "Ping"))
+                        assert_se(sd_bus_reply_method_return(m, NULL) >= 0);
+                else if (sd_bus_message_is_method_call(m, "benchmark.server", "Work")) {
+                        const void *p;
+                        size_t sz;
+
+                        /* Make sure the mmap is mapped */
+                        assert_se(sd_bus_message_read_array(m, 'y', &p, &sz) > 0);
+
+                        r = sd_bus_reply_method_return(m, NULL);
+                        assert_se(r >= 0);
+                } else if (sd_bus_message_is_method_call(m, "benchmark.server", "Exit")) {
+                        uint64_t res;
+                        assert_se(sd_bus_message_read(m, "t", &res) > 0);
+
+                        *result = res;
+                        return;
+
+                } else if (!sd_bus_message_is_signal(m, NULL, NULL))
+                        assert_not_reached("Unknown method");
+        }
+}
+
+static void transaction(sd_bus *b, size_t sz, const char *server_name) {
+        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
+        uint8_t *p;
+
+        assert_se(sd_bus_message_new_method_call(b, &m, server_name, "/", "benchmark.server", "Work") >= 0);
+        assert_se(sd_bus_message_append_array_space(m, 'y', sz, (void**) &p) >= 0);
+
+        memset(p, 0x80, sz);
+
+        assert_se(sd_bus_call(b, m, 0, NULL, &reply) >= 0);
+}
+
+static void client_bisect(const char *address, const char *server_name) {
+        _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
+        size_t lsize, rsize, csize;
+        sd_bus *b;
+        int r;
+
+        r = sd_bus_new(&b);
+        assert_se(r >= 0);
+
+        r = sd_bus_set_address(b, address);
+        assert_se(r >= 0);
+
+        r = sd_bus_start(b);
+        assert_se(r >= 0);
+
+        r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
+        assert_se(r >= 0);
+
+        lsize = 1;
+        rsize = MAX_SIZE;
+
+        printf("SIZE\tCOPY\tMEMFD\n");
+
+        for (;;) {
+                usec_t t;
+                unsigned n_copying, n_memfd;
+
+                csize = (lsize + rsize) / 2;
+
+                if (csize <= lsize)
+                        break;
+
+                if (csize <= 0)
+                        break;
+
+                printf("%zu\t", csize);
+
+                b->use_memfd = 0;
+
+                t = now(CLOCK_MONOTONIC);
+                for (n_copying = 0;; n_copying++) {
+                        transaction(b, csize, server_name);
+                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
+                                break;
+                }
+                printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
+
+                b->use_memfd = -1;
+
+                t = now(CLOCK_MONOTONIC);
+                for (n_memfd = 0;; n_memfd++) {
+                        transaction(b, csize, server_name);
+                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
+                                break;
+                }
+                printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
+
+                if (n_copying == n_memfd)
+                        break;
+
+                if (n_copying > n_memfd)
+                        lsize = csize;
+                else
+                        rsize = csize;
+        }
+
+        b->use_memfd = 1;
+        assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
+        assert_se(sd_bus_message_append(x, "t", csize) >= 0);
+        assert_se(sd_bus_send(b, x, NULL) >= 0);
+
+        sd_bus_unref(b);
+}
+
+static void client_chart(Type type, const char *address, const char *server_name, int fd) {
+        _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
+        size_t csize;
+        sd_bus *b;
+        int r;
+
+        r = sd_bus_new(&b);
+        assert_se(r >= 0);
+
+        if (type == TYPE_DIRECT) {
+                r = sd_bus_set_fd(b, fd, fd);
+                assert_se(r >= 0);
+        } else {
+                r = sd_bus_set_address(b, address);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_bus_client(b, true);
+                assert_se(r >= 0);
+        }
+
+        r = sd_bus_start(b);
+        assert_se(r >= 0);
+
+        r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
+        assert_se(r >= 0);
+
+        switch (type) {
+        case TYPE_KDBUS:
+                printf("SIZE\tCOPY\tMEMFD\n");
+                break;
+        case TYPE_LEGACY:
+                printf("SIZE\tLEGACY\n");
+                break;
+        case TYPE_DIRECT:
+                printf("SIZE\tDIRECT\n");
+                break;
+        }
+
+        for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
+                usec_t t;
+                unsigned n_copying, n_memfd;
+
+                printf("%zu\t", csize);
+
+                if (type == TYPE_KDBUS) {
+                        b->use_memfd = 0;
+
+                        t = now(CLOCK_MONOTONIC);
+                        for (n_copying = 0;; n_copying++) {
+                                transaction(b, csize, server_name);
+                                if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
+                                        break;
+                        }
+
+                        printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
+
+                        b->use_memfd = -1;
+                }
+
+                t = now(CLOCK_MONOTONIC);
+                for (n_memfd = 0;; n_memfd++) {
+                        transaction(b, csize, server_name);
+                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
+                                break;
+                }
+
+                printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
+        }
+
+        b->use_memfd = 1;
+        assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
+        assert_se(sd_bus_message_append(x, "t", csize) >= 0);
+        assert_se(sd_bus_send(b, x, NULL) >= 0);
+
+        sd_bus_unref(b);
+}
+
+int main(int argc, char *argv[]) {
+        enum {
+                MODE_BISECT,
+                MODE_CHART,
+        } mode = MODE_BISECT;
+        Type type = TYPE_KDBUS;
+        int i, pair[2] = { -1, -1 };
+        _cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL, *server_name = NULL;
+        _cleanup_close_ int bus_ref = -1;
+        const char *unique;
+        cpu_set_t cpuset;
+        size_t result;
+        sd_bus *b;
+        pid_t pid;
+        int r;
+
+        for (i = 1; i < argc; i++) {
+                if (streq(argv[i], "chart")) {
+                        mode = MODE_CHART;
+                        continue;
+                } else if (streq(argv[i], "legacy")) {
+                        type = TYPE_LEGACY;
+                        continue;
+                } else if (streq(argv[i], "direct")) {
+                        type = TYPE_DIRECT;
+                        continue;
+                }
+
+                assert_se(parse_sec(argv[i], &arg_loop_usec) >= 0);
+        }
+
+        assert_se(!MODE_BISECT || TYPE_KDBUS);
+
+        assert_se(arg_loop_usec > 0);
+
+        if (type == TYPE_KDBUS) {
+                assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
+
+                bus_ref = bus_kernel_create_bus(name, false, &bus_name);
+                if (bus_ref == -ENOENT)
+                        exit(EXIT_TEST_SKIP);
+
+                assert_se(bus_ref >= 0);
+
+                address = strappend("kernel:path=", bus_name);
+                assert_se(address);
+        } else if (type == TYPE_LEGACY) {
+                const char *e;
+
+                e = secure_getenv("DBUS_SESSION_BUS_ADDRESS");
+                assert_se(e);
+
+                address = strdup(e);
+                assert_se(address);
+        }
+
+        r = sd_bus_new(&b);
+        assert_se(r >= 0);
+
+        if (type == TYPE_DIRECT) {
+                assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) >= 0);
+
+                r = sd_bus_set_fd(b, pair[0], pair[0]);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_server(b, true, SD_ID128_NULL);
+                assert_se(r >= 0);
+        } else {
+                r = sd_bus_set_address(b, address);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_bus_client(b, true);
+                assert_se(r >= 0);
+        }
+
+        r = sd_bus_start(b);
+        assert_se(r >= 0);
+
+        if (type != TYPE_DIRECT) {
+                r = sd_bus_get_unique_name(b, &unique);
+                assert_se(r >= 0);
+
+                server_name = strdup(unique);
+                assert_se(server_name);
+        }
+
+        sync();
+        setpriority(PRIO_PROCESS, 0, -19);
+
+        pid = fork();
+        assert_se(pid >= 0);
+
+        if (pid == 0) {
+                CPU_ZERO(&cpuset);
+                CPU_SET(0, &cpuset);
+                pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+
+                safe_close(bus_ref);
+                sd_bus_unref(b);
+
+                switch (mode) {
+                case MODE_BISECT:
+                        client_bisect(address, server_name);
+                        break;
+
+                case MODE_CHART:
+                        client_chart(type, address, server_name, pair[1]);
+                        break;
+                }
+
+                _exit(0);
+        }
+
+        CPU_ZERO(&cpuset);
+        CPU_SET(1, &cpuset);
+        pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+
+        server(b, &result);
+
+        if (mode == MODE_BISECT)
+                printf("Copying/memfd are equally fast at %zu bytes\n", result);
+
+        assert_se(waitpid(pid, NULL, 0) == pid);
+
+        safe_close(pair[1]);
+        sd_bus_unref(b);
+
+        return 0;
+}
diff --git a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
deleted file mode 100644
index d14110a..0000000
--- a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <sys/wait.h>
-
-#include "def.h"
-#include "util.h"
-#include "time-util.h"
-
-#include "sd-bus.h"
-#include "bus-kernel.h"
-#include "bus-internal.h"
-#include "bus-util.h"
-
-#define MAX_SIZE (2*1024*1024)
-
-static usec_t arg_loop_usec = 100 * USEC_PER_MSEC;
-
-typedef enum Type {
-        TYPE_KDBUS,
-        TYPE_LEGACY,
-        TYPE_DIRECT,
-} Type;
-
-static void server(sd_bus *b, size_t *result) {
-        int r;
-
-        for (;;) {
-                _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
-
-                r = sd_bus_process(b, &m);
-                assert_se(r >= 0);
-
-                if (r == 0)
-                        assert_se(sd_bus_wait(b, USEC_INFINITY) >= 0);
-                if (!m)
-                        continue;
-
-                if (sd_bus_message_is_method_call(m, "benchmark.server", "Ping"))
-                        assert_se(sd_bus_reply_method_return(m, NULL) >= 0);
-                else if (sd_bus_message_is_method_call(m, "benchmark.server", "Work")) {
-                        const void *p;
-                        size_t sz;
-
-                        /* Make sure the mmap is mapped */
-                        assert_se(sd_bus_message_read_array(m, 'y', &p, &sz) > 0);
-
-                        r = sd_bus_reply_method_return(m, NULL);
-                        assert_se(r >= 0);
-                } else if (sd_bus_message_is_method_call(m, "benchmark.server", "Exit")) {
-                        uint64_t res;
-                        assert_se(sd_bus_message_read(m, "t", &res) > 0);
-
-                        *result = res;
-                        return;
-
-                } else if (!sd_bus_message_is_signal(m, NULL, NULL))
-                        assert_not_reached("Unknown method");
-        }
-}
-
-static void transaction(sd_bus *b, size_t sz, const char *server_name) {
-        _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
-        uint8_t *p;
-
-        assert_se(sd_bus_message_new_method_call(b, &m, server_name, "/", "benchmark.server", "Work") >= 0);
-        assert_se(sd_bus_message_append_array_space(m, 'y', sz, (void**) &p) >= 0);
-
-        memset(p, 0x80, sz);
-
-        assert_se(sd_bus_call(b, m, 0, NULL, &reply) >= 0);
-}
-
-static void client_bisect(const char *address, const char *server_name) {
-        _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
-        size_t lsize, rsize, csize;
-        sd_bus *b;
-        int r;
-
-        r = sd_bus_new(&b);
-        assert_se(r >= 0);
-
-        r = sd_bus_set_address(b, address);
-        assert_se(r >= 0);
-
-        r = sd_bus_start(b);
-        assert_se(r >= 0);
-
-        r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
-        assert_se(r >= 0);
-
-        lsize = 1;
-        rsize = MAX_SIZE;
-
-        printf("SIZE\tCOPY\tMEMFD\n");
-
-        for (;;) {
-                usec_t t;
-                unsigned n_copying, n_memfd;
-
-                csize = (lsize + rsize) / 2;
-
-                if (csize <= lsize)
-                        break;
-
-                if (csize <= 0)
-                        break;
-
-                printf("%zu\t", csize);
-
-                b->use_memfd = 0;
-
-                t = now(CLOCK_MONOTONIC);
-                for (n_copying = 0;; n_copying++) {
-                        transaction(b, csize, server_name);
-                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
-                                break;
-                }
-                printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
-
-                b->use_memfd = -1;
-
-                t = now(CLOCK_MONOTONIC);
-                for (n_memfd = 0;; n_memfd++) {
-                        transaction(b, csize, server_name);
-                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
-                                break;
-                }
-                printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
-
-                if (n_copying == n_memfd)
-                        break;
-
-                if (n_copying > n_memfd)
-                        lsize = csize;
-                else
-                        rsize = csize;
-        }
-
-        b->use_memfd = 1;
-        assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
-        assert_se(sd_bus_message_append(x, "t", csize) >= 0);
-        assert_se(sd_bus_send(b, x, NULL) >= 0);
-
-        sd_bus_unref(b);
-}
-
-static void client_chart(Type type, const char *address, const char *server_name, int fd) {
-        _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
-        size_t csize;
-        sd_bus *b;
-        int r;
-
-        r = sd_bus_new(&b);
-        assert_se(r >= 0);
-
-        if (type == TYPE_DIRECT) {
-                r = sd_bus_set_fd(b, fd, fd);
-                assert_se(r >= 0);
-        } else {
-                r = sd_bus_set_address(b, address);
-                assert_se(r >= 0);
-
-                r = sd_bus_set_bus_client(b, true);
-                assert_se(r >= 0);
-        }
-
-        r = sd_bus_start(b);
-        assert_se(r >= 0);
-
-        r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
-        assert_se(r >= 0);
-
-        switch (type) {
-        case TYPE_KDBUS:
-                printf("SIZE\tCOPY\tMEMFD\n");
-                break;
-        case TYPE_LEGACY:
-                printf("SIZE\tLEGACY\n");
-                break;
-        case TYPE_DIRECT:
-                printf("SIZE\tDIRECT\n");
-                break;
-        }
-
-        for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
-                usec_t t;
-                unsigned n_copying, n_memfd;
-
-                printf("%zu\t", csize);
-
-                if (type == TYPE_KDBUS) {
-                        b->use_memfd = 0;
-
-                        t = now(CLOCK_MONOTONIC);
-                        for (n_copying = 0;; n_copying++) {
-                                transaction(b, csize, server_name);
-                                if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
-                                        break;
-                        }
-
-                        printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
-
-                        b->use_memfd = -1;
-                }
-
-                t = now(CLOCK_MONOTONIC);
-                for (n_memfd = 0;; n_memfd++) {
-                        transaction(b, csize, server_name);
-                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
-                                break;
-                }
-
-                printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
-        }
-
-        b->use_memfd = 1;
-        assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
-        assert_se(sd_bus_message_append(x, "t", csize) >= 0);
-        assert_se(sd_bus_send(b, x, NULL) >= 0);
-
-        sd_bus_unref(b);
-}
-
-int main(int argc, char *argv[]) {
-        enum {
-                MODE_BISECT,
-                MODE_CHART,
-        } mode = MODE_BISECT;
-        Type type = TYPE_KDBUS;
-        int i, pair[2] = { -1, -1 };
-        _cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL, *server_name = NULL;
-        _cleanup_close_ int bus_ref = -1;
-        const char *unique;
-        cpu_set_t cpuset;
-        size_t result;
-        sd_bus *b;
-        pid_t pid;
-        int r;
-
-        for (i = 1; i < argc; i++) {
-                if (streq(argv[i], "chart")) {
-                        mode = MODE_CHART;
-                        continue;
-                } else if (streq(argv[i], "legacy")) {
-                        type = TYPE_LEGACY;
-                        continue;
-                } else if (streq(argv[i], "direct")) {
-                        type = TYPE_DIRECT;
-                        continue;
-                }
-
-                assert_se(parse_sec(argv[i], &arg_loop_usec) >= 0);
-        }
-
-        assert_se(!MODE_BISECT || TYPE_KDBUS);
-
-        assert_se(arg_loop_usec > 0);
-
-        if (type == TYPE_KDBUS) {
-                assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
-
-                bus_ref = bus_kernel_create_bus(name, false, &bus_name);
-                if (bus_ref == -ENOENT)
-                        exit(EXIT_TEST_SKIP);
-
-                assert_se(bus_ref >= 0);
-
-                address = strappend("kernel:path=", bus_name);
-                assert_se(address);
-        } else if (type == TYPE_LEGACY) {
-                const char *e;
-
-                e = secure_getenv("DBUS_SESSION_BUS_ADDRESS");
-                assert_se(e);
-
-                address = strdup(e);
-                assert_se(address);
-        }
-
-        r = sd_bus_new(&b);
-        assert_se(r >= 0);
-
-        if (type == TYPE_DIRECT) {
-                assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) >= 0);
-
-                r = sd_bus_set_fd(b, pair[0], pair[0]);
-                assert_se(r >= 0);
-
-                r = sd_bus_set_server(b, true, SD_ID128_NULL);
-                assert_se(r >= 0);
-        } else {
-                r = sd_bus_set_address(b, address);
-                assert_se(r >= 0);
-
-                r = sd_bus_set_bus_client(b, true);
-                assert_se(r >= 0);
-        }
-
-        r = sd_bus_start(b);
-        assert_se(r >= 0);
-
-        if (type != TYPE_DIRECT) {
-                r = sd_bus_get_unique_name(b, &unique);
-                assert_se(r >= 0);
-
-                server_name = strdup(unique);
-                assert_se(server_name);
-        }
-
-        sync();
-        setpriority(PRIO_PROCESS, 0, -19);
-
-        pid = fork();
-        assert_se(pid >= 0);
-
-        if (pid == 0) {
-                CPU_ZERO(&cpuset);
-                CPU_SET(0, &cpuset);
-                pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
-
-                safe_close(bus_ref);
-                sd_bus_unref(b);
-
-                switch (mode) {
-                case MODE_BISECT:
-                        client_bisect(address, server_name);
-                        break;
-
-                case MODE_CHART:
-                        client_chart(type, address, server_name, pair[1]);
-                        break;
-                }
-
-                _exit(0);
-        }
-
-        CPU_ZERO(&cpuset);
-        CPU_SET(1, &cpuset);
-        pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
-
-        server(b, &result);
-
-        if (mode == MODE_BISECT)
-                printf("Copying/memfd are equally fast at %zu bytes\n", result);
-
-        assert_se(waitpid(pid, NULL, 0) == pid);
-
-        safe_close(pair[1]);
-        sd_bus_unref(b);
-
-        return 0;
-}

commit 7dfbe2e3fc0215b49d8202a32beb6b1aae08c4e4
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Apr 29 16:05:32 2015 +0200

    core: annotate event sources

diff --git a/src/core/automount.c b/src/core/automount.c
index 6fc214b..b1109bd 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -274,12 +274,13 @@ static int automount_coldplug(Unit *u) {
 
                 if (a->deserialized_state == AUTOMOUNT_WAITING ||
                     a->deserialized_state == AUTOMOUNT_RUNNING) {
-
                         assert(a->pipe_fd >= 0);
 
                         r = sd_event_add_io(u->manager->event, &a->pipe_event_source, a->pipe_fd, EPOLLIN, automount_dispatch_io, u);
                         if (r < 0)
                                 return r;
+
+                        (void) sd_event_source_set_description(a->pipe_event_source, "automount-io");
                 }
 
                 automount_set_state(a, a->deserialized_state);
@@ -595,6 +596,8 @@ static void automount_enter_waiting(Automount *a) {
         if (r < 0)
                 goto fail;
 
+        (void) sd_event_source_set_description(a->pipe_event_source, "automount-io");
+
         a->pipe_fd = p[0];
         a->dev_id = st.st_dev;
 
@@ -683,11 +686,17 @@ static int automount_start_expire(Automount *a) {
                 return sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r = sd_event_add_time(
                         UNIT(a)->manager->event,
                         &a->expire_event_source,
                         CLOCK_MONOTONIC, timeout, 0,
                         automount_dispatch_expire, a);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(a->expire_event_source, "automount-expire");
+
+        return 0;
 }
 
 static void automount_enter_runnning(Automount *a) {
diff --git a/src/core/busname.c b/src/core/busname.c
index aba2a96..48cc045 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -124,12 +124,18 @@ static int busname_arm_timer(BusName *n) {
                 return sd_event_source_set_enabled(n->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r =  sd_event_add_time(
                         UNIT(n)->manager->event,
                         &n->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + n->timeout_usec, 0,
                         busname_dispatch_timer, n);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(n->timer_event_source, "busname-timer");
+
+        return 0;
 }
 
 static int busname_add_default_default_dependencies(BusName *n) {
@@ -285,6 +291,7 @@ static int busname_watch_fd(BusName *n) {
                 r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_ON);
         else
                 r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
+                (void) sd_event_source_set_description(n->starter_event_source, "busname-starter");
         if (r < 0) {
                 log_unit_warning_errno(UNIT(n)->id, r, "Failed to watch starter fd: %m");
                 busname_unwatch_fd(n);
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 02b998c..43b2ccd 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -982,6 +982,8 @@ static int bus_init_private(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate event source: %m");
 
+        (void) sd_event_source_set_description(s, "bus-connection");
+
         m->private_listen_fd = fd;
         m->private_listen_event_source = s;
         fd = -1;
diff --git a/src/core/device.c b/src/core/device.c
index 19b688d..5656c96 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -627,6 +627,8 @@ static int device_enumerate(Manager *m) {
                 r = sd_event_add_io(m->event, &m->udev_event_source, udev_monitor_get_fd(m->udev_monitor), EPOLLIN, device_dispatch_io, m);
                 if (r < 0)
                         goto fail;
+
+                (void) sd_event_source_set_description(m->udev_event_source, "device");
         }
 
         e = udev_enumerate_new(m->udev);
diff --git a/src/core/job.c b/src/core/job.c
index e92e24e..a26f7de 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -934,6 +934,8 @@ int job_start_timer(Job *j) {
         if (r < 0)
                 return r;
 
+        (void) sd_event_source_set_description(j->timer_event_source, "job-start");
+
         return 0;
 }
 
@@ -1130,6 +1132,8 @@ int job_coldplug(Job *j) {
         if (r < 0)
                 log_debug_errno(r, "Failed to restart timeout for job: %m");
 
+        (void) sd_event_source_set_description(j->timer_event_source, "job-timeout");
+
         return r;
 }
 
diff --git a/src/core/manager.c b/src/core/manager.c
index f13dad5..0c94e9e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -103,6 +103,8 @@ static void manager_watch_jobs_in_progress(Manager *m) {
                         CLOCK_MONOTONIC,
                         next, 0,
                         manager_dispatch_jobs_in_progress, m);
+
+        (void) sd_event_source_set_description(m->jobs_in_progress_event_source, "manager-jobs-in-progress");
 }
 
 #define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
@@ -278,6 +280,8 @@ static int manager_check_ask_password(Manager *m) {
                         return -errno;
                 }
 
+                (void) sd_event_source_set_description(m->ask_password_event_source, "manager-ask-password");
+
                 /* Queries might have been added meanwhile... */
                 manager_dispatch_ask_password_fd(m->ask_password_event_source,
                                                  m->ask_password_inotify_fd, EPOLLIN, m);
@@ -301,6 +305,8 @@ static int manager_watch_idle_pipe(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to watch idle pipe: %m");
 
+        (void) sd_event_source_set_description(m->idle_pipe_event_source, "manager-idle-pipe");
+
         return 0;
 }
 
@@ -343,6 +349,8 @@ static int manager_setup_time_change(Manager *m) {
         if (r < 0)
                 return log_error_errno(r, "Failed to create time change event source: %m");
 
+        (void) sd_event_source_set_description(m->time_change_event_source, "manager-time-change");
+
         log_debug("Set up TFD_TIMER_CANCEL_ON_SET timerfd.");
 
         return 0;
@@ -453,6 +461,8 @@ static int manager_setup_signals(Manager *m) {
         if (r < 0)
                 return r;
 
+        (void) sd_event_source_set_description(m->signal_event_source, "manager-signal");
+
         /* Process signals a bit earlier than the rest of things, but
          * later than notify_fd processing, so that the notify
          * processing can still figure out to which process/service a
@@ -593,6 +603,8 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
         if (r < 0)
                 goto fail;
 
+        (void) sd_event_source_set_description(m->run_queue_event_source, "manager-run-queue");
+
         r = manager_setup_signals(m);
         if (r < 0)
                 goto fail;
@@ -691,6 +703,8 @@ static int manager_setup_notify(Manager *m) {
                 r = sd_event_source_set_priority(m->notify_event_source, -7);
                 if (r < 0)
                         return log_error_errno(r, "Failed to set priority of notify event source: %m");
+
+                (void) sd_event_source_set_description(m->notify_event_source, "manager-notify");
         }
 
         return 0;
diff --git a/src/core/mount.c b/src/core/mount.c
index eb25bcb..d0c41a7 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -164,12 +164,18 @@ static int mount_arm_timer(Mount *m) {
                 return sd_event_source_set_enabled(m->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r = sd_event_add_time(
                         UNIT(m)->manager->event,
                         &m->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + m->timeout_usec, 0,
                         mount_dispatch_timer, m);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(m->timer_event_source, "mount-timer");
+
+        return 0;
 }
 
 static void mount_unwatch_control_pid(Mount *m) {
@@ -1645,6 +1651,8 @@ static int mount_enumerate(Manager *m) {
                 r = sd_event_source_set_priority(m->mount_event_source, -10);
                 if (r < 0)
                         goto fail;
+
+                (void) sd_event_source_set_description(m->mount_event_source, "mount-mountinfo-dispatch");
         }
 
         if (m->utab_inotify_fd < 0) {
@@ -1669,6 +1677,8 @@ static int mount_enumerate(Manager *m) {
                 r = sd_event_source_set_priority(m->mount_utab_event_source, -10);
                 if (r < 0)
                         goto fail;
+
+                (void) sd_event_source_set_description(m->mount_utab_event_source, "mount-utab-dispatch");
         }
 
         r = mount_load_proc_self_mountinfo(m, false);
diff --git a/src/core/path.c b/src/core/path.c
index fbb695d..b6322bd 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -73,6 +73,8 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
         if (r < 0)
                 goto fail;
 
+        (void) sd_event_source_set_description(s->event_source, "path");
+
         /* This assumes the path was passed through path_kill_slashes()! */
 
         for (slash = strchr(s->path, '/'); ; slash = strchr(slash+1, '/')) {
diff --git a/src/core/scope.c b/src/core/scope.c
index cbfa336..b99eca9 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -81,12 +81,18 @@ static int scope_arm_timer(Scope *s) {
                 return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r =  sd_event_add_time(
                         UNIT(s)->manager->event,
                         &s->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + s->timeout_stop_usec, 0,
                         scope_dispatch_timer, s);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(s->timer_event_source, "scope-timer");
+
+        return 0;
 }
 
 static void scope_set_state(Scope *s, ScopeState state) {
diff --git a/src/core/service.c b/src/core/service.c
index 3a614b1..d52ba73 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -227,6 +227,8 @@ static void service_start_watchdog(Service *s) {
                         return;
                 }
 
+                (void) sd_event_source_set_description(s->watchdog_event_source, "service-watchdog");
+
                 /* Let's process everything else which might be a sign
                  * of living before we consider a service died. */
                 r = sd_event_source_set_priority(s->watchdog_event_source, SD_EVENT_PRIORITY_IDLE);
@@ -372,6 +374,8 @@ static int service_add_fd_store(Service *s, int fd) {
                 return r;
         }
 
+        (void) sd_event_source_set_description(fs->event_source, "service-fd-store");
+
         LIST_PREPEND(fd_store, s->fd_store, fs);
         s->n_fd_store++;
 
@@ -422,12 +426,18 @@ static int service_arm_timer(Service *s, usec_t usec) {
                 return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r = sd_event_add_time(
                         UNIT(s)->manager->event,
                         &s->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + usec, 0,
                         service_dispatch_timer, s);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(s->timer_event_source, "service-timer");
+
+        return 0;
 }
 
 static int service_verify(Service *s) {
diff --git a/src/core/socket.c b/src/core/socket.c
index 1f931eb..702742f 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -170,12 +170,18 @@ static int socket_arm_timer(Socket *s) {
                 return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r = sd_event_add_time(
                         UNIT(s)->manager->event,
                         &s->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + s->timeout_usec, 0,
                         socket_dispatch_timer, s);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(s->timer_event_source, "socket-timer");
+
+        return 0;
 }
 
 int socket_instantiate_service(Socket *s) {
@@ -1266,6 +1272,7 @@ static int socket_watch_fds(Socket *s) {
                 else
                         r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p);
 
+                        (void) sd_event_source_set_description(p->event_source, "socket-port-io");
                 if (r < 0) {
                         log_unit_warning_errno(UNIT(s)->id, r, "Failed to watch listening fds: %m");
                         goto fail;
diff --git a/src/core/swap.c b/src/core/swap.c
index 74f26b7..ae45b80 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -177,12 +177,18 @@ static int swap_arm_timer(Swap *s) {
                 return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
         }
 
-        return sd_event_add_time(
+        r = sd_event_add_time(
                         UNIT(s)->manager->event,
                         &s->timer_event_source,
                         CLOCK_MONOTONIC,
                         now(CLOCK_MONOTONIC) + s->timeout_usec, 0,
                         swap_dispatch_timer, s);
+        if (r < 0)
+                return r;
+
+        (void) sd_event_source_set_description(s->timer_event_source, "swap-timer");
+
+        return 0;
 }
 
 static int swap_add_device_links(Swap *s) {
@@ -1294,6 +1300,8 @@ static int swap_enumerate(Manager *m) {
                 r = sd_event_source_set_priority(m->swap_event_source, -10);
                 if (r < 0)
                         goto fail;
+
+                (void) sd_event_source_set_description(m->swap_event_source, "swap-proc");
         }
 
         r = swap_load_proc_swaps(m, false);
diff --git a/src/core/timer.c b/src/core/timer.c
index 9405501..d6905bb 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -444,6 +444,8 @@ static void timer_enter_waiting(Timer *t, bool initial) {
                 if (r < 0)
                         goto fail;
 
+                (void) sd_event_source_set_description(t->monotonic_event_source, "timer-monotonic");
+
         } else if (t->monotonic_event_source) {
 
                 r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_OFF);
@@ -471,6 +473,8 @@ static void timer_enter_waiting(Timer *t, bool initial) {
                 if (r < 0)
                         goto fail;
 
+                (void) sd_event_source_set_description(t->realtime_event_source, "timer-realtime");
+
         } else if (t->realtime_event_source) {
 
                 r = sd_event_source_set_enabled(t->realtime_event_source, SD_EVENT_OFF);

commit 77cfd1139cd116e9761aacfaf8c3cde71fc5d058
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Apr 28 21:39:13 2015 +0200

    sd-bus: benchmark - also support testing non-kdbus transports
    
    We introduce two news types of benchmarks in chart-mode:
     - 'legacy' connects using the session bus
     - 'direct' connects using a peer-to-peer socket
    
    We should probably also introduce a mode for testing the dbus1-kdbus proxy.

diff --git a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
index f480b65..d14110a 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
@@ -21,6 +21,7 @@
 
 #include <sys/wait.h>
 
+#include "def.h"
 #include "util.h"
 #include "time-util.h"
 
@@ -33,6 +34,12 @@
 
 static usec_t arg_loop_usec = 100 * USEC_PER_MSEC;
 
+typedef enum Type {
+        TYPE_KDBUS,
+        TYPE_LEGACY,
+        TYPE_DIRECT,
+} Type;
+
 static void server(sd_bus *b, size_t *result) {
         int r;
 
@@ -65,7 +72,7 @@ static void server(sd_bus *b, size_t *result) {
                         *result = res;
                         return;
 
-                } else
+                } else if (!sd_bus_message_is_signal(m, NULL, NULL))
                         assert_not_reached("Unknown method");
         }
 }
@@ -156,7 +163,7 @@ static void client_bisect(const char *address, const char *server_name) {
         sd_bus_unref(b);
 }
 
-static void client_chart(const char *address, const char *server_name) {
+static void client_chart(Type type, const char *address, const char *server_name, int fd) {
         _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
         size_t csize;
         sd_bus *b;
@@ -165,15 +172,34 @@ static void client_chart(const char *address, const char *server_name) {
         r = sd_bus_new(&b);
         assert_se(r >= 0);
 
-        r = sd_bus_set_address(b, address);
-        assert_se(r >= 0);
+        if (type == TYPE_DIRECT) {
+                r = sd_bus_set_fd(b, fd, fd);
+                assert_se(r >= 0);
+        } else {
+                r = sd_bus_set_address(b, address);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_bus_client(b, true);
+                assert_se(r >= 0);
+        }
 
         r = sd_bus_start(b);
         assert_se(r >= 0);
 
-        assert_se(sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL) >= 0);
+        r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
+        assert_se(r >= 0);
 
-        printf("SIZE\tCOPY\tMEMFD\n");
+        switch (type) {
+        case TYPE_KDBUS:
+                printf("SIZE\tCOPY\tMEMFD\n");
+                break;
+        case TYPE_LEGACY:
+                printf("SIZE\tLEGACY\n");
+                break;
+        case TYPE_DIRECT:
+                printf("SIZE\tDIRECT\n");
+                break;
+        }
 
         for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
                 usec_t t;
@@ -181,18 +207,20 @@ static void client_chart(const char *address, const char *server_name) {
 
                 printf("%zu\t", csize);
 
-                b->use_memfd = 0;
+                if (type == TYPE_KDBUS) {
+                        b->use_memfd = 0;
 
-                t = now(CLOCK_MONOTONIC);
-                for (n_copying = 0;; n_copying++) {
-                        transaction(b, csize, server_name);
-                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
-                                break;
-                }
+                        t = now(CLOCK_MONOTONIC);
+                        for (n_copying = 0;; n_copying++) {
+                                transaction(b, csize, server_name);
+                                if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
+                                        break;
+                        }
 
-                printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
+                        printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
 
-                b->use_memfd = -1;
+                        b->use_memfd = -1;
+                }
 
                 t = now(CLOCK_MONOTONIC);
                 for (n_memfd = 0;; n_memfd++) {
@@ -217,7 +245,8 @@ int main(int argc, char *argv[]) {
                 MODE_BISECT,
                 MODE_CHART,
         } mode = MODE_BISECT;
-        int i;
+        Type type = TYPE_KDBUS;
+        int i, pair[2] = { -1, -1 };
         _cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL, *server_name = NULL;
         _cleanup_close_ int bus_ref = -1;
         const char *unique;
@@ -231,38 +260,71 @@ int main(int argc, char *argv[]) {
                 if (streq(argv[i], "chart")) {
                         mode = MODE_CHART;
                         continue;
+                } else if (streq(argv[i], "legacy")) {
+                        type = TYPE_LEGACY;
+                        continue;
+                } else if (streq(argv[i], "direct")) {
+                        type = TYPE_DIRECT;
+                        continue;
                 }
 
                 assert_se(parse_sec(argv[i], &arg_loop_usec) >= 0);
         }
 
+        assert_se(!MODE_BISECT || TYPE_KDBUS);
+
         assert_se(arg_loop_usec > 0);
 
-        assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
+        if (type == TYPE_KDBUS) {
+                assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
+
+                bus_ref = bus_kernel_create_bus(name, false, &bus_name);
+                if (bus_ref == -ENOENT)
+                        exit(EXIT_TEST_SKIP);
 
-        bus_ref = bus_kernel_create_bus(name, false, &bus_name);
-        if (bus_ref == -ENOENT)
-                exit(EXIT_TEST_SKIP);
+                assert_se(bus_ref >= 0);
 
-        assert_se(bus_ref >= 0);
+                address = strappend("kernel:path=", bus_name);
+                assert_se(address);
+        } else if (type == TYPE_LEGACY) {
+                const char *e;
 
-        address = strappend("kernel:path=", bus_name);
-        assert_se(address);
+                e = secure_getenv("DBUS_SESSION_BUS_ADDRESS");
+                assert_se(e);
+
+                address = strdup(e);
+                assert_se(address);
+        }
 
         r = sd_bus_new(&b);
         assert_se(r >= 0);
 
-        r = sd_bus_set_address(b, address);
-        assert_se(r >= 0);
+        if (type == TYPE_DIRECT) {
+                assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) >= 0);
+
+                r = sd_bus_set_fd(b, pair[0], pair[0]);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_server(b, true, SD_ID128_NULL);
+                assert_se(r >= 0);
+        } else {
+                r = sd_bus_set_address(b, address);
+                assert_se(r >= 0);
+
+                r = sd_bus_set_bus_client(b, true);
+                assert_se(r >= 0);
+        }
 
         r = sd_bus_start(b);
         assert_se(r >= 0);
 
-        r = sd_bus_get_unique_name(b, &unique);
-        assert_se(r >= 0);
+        if (type != TYPE_DIRECT) {
+                r = sd_bus_get_unique_name(b, &unique);
+                assert_se(r >= 0);
 
-        server_name = strdup(unique);
-        assert_se(server_name);
+                server_name = strdup(unique);
+                assert_se(server_name);
+        }
 
         sync();
         setpriority(PRIO_PROCESS, 0, -19);
@@ -284,7 +346,7 @@ int main(int argc, char *argv[]) {
                         break;
 
                 case MODE_CHART:
-                        client_chart(address, server_name);
+                        client_chart(type, address, server_name, pair[1]);
                         break;
                 }
 
@@ -302,6 +364,7 @@ int main(int argc, char *argv[]) {
 
         assert_se(waitpid(pid, NULL, 0) == pid);
 
+        safe_close(pair[1]);
         sd_bus_unref(b);
 
         return 0;

commit 7800bf7169686d4473bb4dd7f9238d8dee1e597a
Author: Tom Gundersen <teg at jklm.no>
Date:   Mon Apr 27 15:01:06 2015 +0200

    libudev: monitor - fix typo in log message

diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 60f11c1..b13c579 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -759,7 +759,7 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
         count = sendmsg(udev_monitor->sock, &smsg, 0);
         if (count < 0) {
                 if (!destination && errno == ECONNREFUSED) {
-                        log_debug("passed device to to netlink monitor %p", udev_monitor);
+                        log_debug("passed device to netlink monitor %p", udev_monitor);
                         return 0;
                 } else
                         return -errno;



More information about the systemd-commits mailing list