2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-05-22 16:02:21 +02:00
|
|
|
/***
|
|
|
|
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 "sd-bus.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
|
2015-10-27 03:01:06 +01:00
|
|
|
#include "alloc-util.h"
|
2013-05-22 16:02:21 +02:00
|
|
|
#include "bus-internal.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "bus-kernel.h"
|
2015-08-27 16:32:22 +02:00
|
|
|
#include "bus-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "def.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "fd-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "time-util.h"
|
|
|
|
#include "util.h"
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2014-09-29 15:44:44 +02:00
|
|
|
#define MAX_SIZE (2*1024*1024)
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-06-04 12:00:50 +02:00
|
|
|
static usec_t arg_loop_usec = 100 * USEC_PER_MSEC;
|
2013-06-03 12:44:44 +02:00
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
typedef enum Type {
|
|
|
|
TYPE_LEGACY,
|
|
|
|
TYPE_DIRECT,
|
|
|
|
} Type;
|
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
static void server(sd_bus *b, size_t *result) {
|
2013-05-22 16:02:21 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
for (;;) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
2013-05-22 16:02:21 +02:00
|
|
|
|
|
|
|
r = sd_bus_process(b, &m);
|
|
|
|
assert_se(r >= 0);
|
|
|
|
|
|
|
|
if (r == 0)
|
2014-07-29 12:23:31 +02:00
|
|
|
assert_se(sd_bus_wait(b, USEC_INFINITY) >= 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
if (!m)
|
|
|
|
continue;
|
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
if (sd_bus_message_is_method_call(m, "benchmark.server", "Ping"))
|
2013-11-21 01:51:16 +01:00
|
|
|
assert_se(sd_bus_reply_method_return(m, NULL) >= 0);
|
2013-05-29 09:59:10 +02:00
|
|
|
else if (sd_bus_message_is_method_call(m, "benchmark.server", "Work")) {
|
|
|
|
const void *p;
|
|
|
|
size_t sz;
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
/* Make sure the mmap is mapped */
|
|
|
|
assert_se(sd_bus_message_read_array(m, 'y', &p, &sz) > 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2015-02-24 14:01:36 +01:00
|
|
|
r = sd_bus_reply_method_return(m, NULL);
|
|
|
|
assert_se(r >= 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
} else if (sd_bus_message_is_method_call(m, "benchmark.server", "Exit")) {
|
2013-05-29 09:59:10 +02:00
|
|
|
uint64_t res;
|
|
|
|
assert_se(sd_bus_message_read(m, "t", &res) > 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
*result = res;
|
2013-05-22 16:02:21 +02:00
|
|
|
return;
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
} else if (!sd_bus_message_is_signal(m, NULL, NULL))
|
2013-05-22 16:02:21 +02:00
|
|
|
assert_not_reached("Unknown method");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:01:36 +01:00
|
|
|
static void transaction(sd_bus *b, size_t sz, const char *server_name) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
|
2013-05-29 09:59:10 +02:00
|
|
|
uint8_t *p;
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2015-02-24 14:01:36 +01:00
|
|
|
assert_se(sd_bus_message_new_method_call(b, &m, server_name, "/", "benchmark.server", "Work") >= 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
assert_se(sd_bus_message_append_array_space(m, 'y', sz, (void**) &p) >= 0);
|
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
memset(p, 0x80, sz);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-11-11 18:55:34 +01:00
|
|
|
assert_se(sd_bus_call(b, m, 0, NULL, &reply) >= 0);
|
2013-05-29 09:59:10 +02:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:01:36 +01:00
|
|
|
static void client_bisect(const char *address, const char *server_name) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *x = NULL;
|
2013-05-29 09:59:10 +02:00
|
|
|
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);
|
|
|
|
|
2015-02-24 14:01:36 +01:00
|
|
|
r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
|
|
|
|
assert_se(r >= 0);
|
2013-05-29 09:59:10 +02:00
|
|
|
|
|
|
|
lsize = 1;
|
|
|
|
rsize = MAX_SIZE;
|
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
printf("SIZE\tCOPY\tMEMFD\n");
|
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
for (;;) {
|
2013-06-03 12:44:44 +02:00
|
|
|
usec_t t;
|
|
|
|
unsigned n_copying, n_memfd;
|
2013-05-29 09:59:10 +02:00
|
|
|
|
|
|
|
csize = (lsize + rsize) / 2;
|
|
|
|
|
|
|
|
if (csize <= lsize)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (csize <= 0)
|
|
|
|
break;
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-06-05 10:26:00 +02:00
|
|
|
printf("%zu\t", csize);
|
2013-06-04 20:55:00 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
b->use_memfd = 0;
|
2013-06-03 12:44:44 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
t = now(CLOCK_MONOTONIC);
|
2013-06-03 12:44:44 +02:00
|
|
|
for (n_copying = 0;; n_copying++) {
|
2015-02-24 14:01:36 +01:00
|
|
|
transaction(b, csize, server_name);
|
2013-06-03 12:44:44 +02:00
|
|
|
if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
|
|
|
|
break;
|
|
|
|
}
|
2013-06-04 20:55:00 +02:00
|
|
|
printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
|
2013-06-03 12:44:44 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
b->use_memfd = -1;
|
2013-06-03 12:44:44 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
t = now(CLOCK_MONOTONIC);
|
2013-06-03 12:44:44 +02:00
|
|
|
for (n_memfd = 0;; n_memfd++) {
|
2015-02-24 14:01:36 +01:00
|
|
|
transaction(b, csize, server_name);
|
2013-06-03 12:44:44 +02:00
|
|
|
if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
|
|
|
|
break;
|
|
|
|
}
|
2013-06-05 12:24:17 +02:00
|
|
|
printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
|
2013-06-03 12:44:44 +02:00
|
|
|
|
|
|
|
if (n_copying == n_memfd)
|
2013-05-29 09:59:10 +02:00
|
|
|
break;
|
|
|
|
|
2013-06-03 12:44:44 +02:00
|
|
|
if (n_copying > n_memfd)
|
2013-05-29 09:59:10 +02:00
|
|
|
lsize = csize;
|
|
|
|
else
|
|
|
|
rsize = csize;
|
2013-05-22 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
b->use_memfd = 1;
|
2015-02-24 14:01:36 +01:00
|
|
|
assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
|
2013-06-04 20:55:00 +02:00
|
|
|
assert_se(sd_bus_message_append(x, "t", csize) >= 0);
|
|
|
|
assert_se(sd_bus_send(b, x, NULL) >= 0);
|
|
|
|
|
|
|
|
sd_bus_unref(b);
|
|
|
|
}
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
static void client_chart(Type type, const char *address, const char *server_name, int fd) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *x = NULL;
|
2013-06-04 20:55:00 +02:00
|
|
|
size_t csize;
|
|
|
|
sd_bus *b;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = sd_bus_new(&b);
|
|
|
|
assert_se(r >= 0);
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
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);
|
|
|
|
}
|
2013-06-04 20:55:00 +02:00
|
|
|
|
|
|
|
r = sd_bus_start(b);
|
|
|
|
assert_se(r >= 0);
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
r = sd_bus_call_method(b, server_name, "/", "benchmark.server", "Ping", NULL, NULL, NULL);
|
|
|
|
assert_se(r >= 0);
|
2013-06-04 20:55:00 +02:00
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
switch (type) {
|
|
|
|
case TYPE_LEGACY:
|
|
|
|
printf("SIZE\tLEGACY\n");
|
|
|
|
break;
|
|
|
|
case TYPE_DIRECT:
|
|
|
|
printf("SIZE\tDIRECT\n");
|
|
|
|
break;
|
|
|
|
}
|
2013-06-04 20:55:00 +02:00
|
|
|
|
2013-06-05 10:26:00 +02:00
|
|
|
for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
|
2013-06-04 20:55:00 +02:00
|
|
|
usec_t t;
|
2017-07-23 17:45:57 +02:00
|
|
|
unsigned n_memfd;
|
2013-06-04 20:55:00 +02:00
|
|
|
|
2013-06-05 10:26:00 +02:00
|
|
|
printf("%zu\t", csize);
|
2013-06-04 20:55:00 +02:00
|
|
|
|
|
|
|
t = now(CLOCK_MONOTONIC);
|
|
|
|
for (n_memfd = 0;; n_memfd++) {
|
2015-02-24 14:01:36 +01:00
|
|
|
transaction(b, csize, server_name);
|
2013-06-04 20:55:00 +02:00
|
|
|
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;
|
2015-02-24 14:01:36 +01:00
|
|
|
assert_se(sd_bus_message_new_method_call(b, &x, server_name, "/", "benchmark.server", "Exit") >= 0);
|
2013-05-29 09:59:10 +02:00
|
|
|
assert_se(sd_bus_message_append(x, "t", csize) >= 0);
|
|
|
|
assert_se(sd_bus_send(b, x, NULL) >= 0);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
sd_bus_unref(b);
|
2013-05-22 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
int main(int argc, char *argv[]) {
|
2013-06-04 20:55:00 +02:00
|
|
|
enum {
|
|
|
|
MODE_BISECT,
|
|
|
|
MODE_CHART,
|
|
|
|
} mode = MODE_BISECT;
|
2017-07-23 17:45:57 +02:00
|
|
|
Type type = TYPE_LEGACY;
|
2015-04-28 21:39:13 +02:00
|
|
|
int i, pair[2] = { -1, -1 };
|
2017-11-01 22:32:22 +01:00
|
|
|
_cleanup_free_ char *address = NULL, *server_name = NULL;
|
2013-05-29 09:59:10 +02:00
|
|
|
_cleanup_close_ int bus_ref = -1;
|
2015-02-24 14:01:36 +01:00
|
|
|
const char *unique;
|
2013-05-29 09:59:10 +02:00
|
|
|
cpu_set_t cpuset;
|
|
|
|
size_t result;
|
2013-05-22 16:02:21 +02:00
|
|
|
sd_bus *b;
|
|
|
|
pid_t pid;
|
2013-05-29 09:59:10 +02:00
|
|
|
int r;
|
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (streq(argv[i], "chart")) {
|
|
|
|
mode = MODE_CHART;
|
|
|
|
continue;
|
2015-04-28 21:39:13 +02:00
|
|
|
} else if (streq(argv[i], "legacy")) {
|
|
|
|
type = TYPE_LEGACY;
|
|
|
|
continue;
|
|
|
|
} else if (streq(argv[i], "direct")) {
|
|
|
|
type = TYPE_DIRECT;
|
|
|
|
continue;
|
2013-06-04 20:55:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_se(parse_sec(argv[i], &arg_loop_usec) >= 0);
|
|
|
|
}
|
2013-06-03 12:44:44 +02:00
|
|
|
|
|
|
|
assert_se(arg_loop_usec > 0);
|
|
|
|
|
2017-07-23 17:45:57 +02:00
|
|
|
if (type == TYPE_LEGACY) {
|
2015-04-28 21:39:13 +02:00
|
|
|
const char *e;
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
e = secure_getenv("DBUS_SESSION_BUS_ADDRESS");
|
|
|
|
assert_se(e);
|
|
|
|
|
|
|
|
address = strdup(e);
|
|
|
|
assert_se(address);
|
|
|
|
}
|
2013-05-22 16:02:21 +02:00
|
|
|
|
|
|
|
r = sd_bus_new(&b);
|
|
|
|
assert_se(r >= 0);
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
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);
|
|
|
|
}
|
2013-05-22 16:02:21 +02:00
|
|
|
|
|
|
|
r = sd_bus_start(b);
|
|
|
|
assert_se(r >= 0);
|
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
if (type != TYPE_DIRECT) {
|
|
|
|
r = sd_bus_get_unique_name(b, &unique);
|
|
|
|
assert_se(r >= 0);
|
2015-02-24 14:01:36 +01:00
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
server_name = strdup(unique);
|
|
|
|
assert_se(server_name);
|
|
|
|
}
|
2015-02-24 14:01:36 +01:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
sync();
|
|
|
|
setpriority(PRIO_PROCESS, 0, -19);
|
|
|
|
|
2013-05-22 16:02:21 +02:00
|
|
|
pid = fork();
|
|
|
|
assert_se(pid >= 0);
|
|
|
|
|
|
|
|
if (pid == 0) {
|
2013-05-29 09:59:10 +02:00
|
|
|
CPU_ZERO(&cpuset);
|
|
|
|
CPU_SET(0, &cpuset);
|
|
|
|
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
|
|
|
|
2014-03-18 19:22:43 +01:00
|
|
|
safe_close(bus_ref);
|
2013-05-22 16:02:21 +02:00
|
|
|
sd_bus_unref(b);
|
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
switch (mode) {
|
|
|
|
case MODE_BISECT:
|
2015-02-24 14:01:36 +01:00
|
|
|
client_bisect(address, server_name);
|
2013-06-04 20:55:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MODE_CHART:
|
2015-04-28 21:39:13 +02:00
|
|
|
client_chart(type, address, server_name, pair[1]);
|
2013-06-04 20:55:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-12-22 13:24:40 +01:00
|
|
|
_exit(EXIT_SUCCESS);
|
2013-05-22 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
CPU_ZERO(&cpuset);
|
|
|
|
CPU_SET(1, &cpuset);
|
|
|
|
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
server(b, &result);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-06-04 20:55:00 +02:00
|
|
|
if (mode == MODE_BISECT)
|
|
|
|
printf("Copying/memfd are equally fast at %zu bytes\n", result);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2013-05-29 09:59:10 +02:00
|
|
|
assert_se(waitpid(pid, NULL, 0) == pid);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
2015-04-28 21:39:13 +02:00
|
|
|
safe_close(pair[1]);
|
2013-05-29 09:59:10 +02:00
|
|
|
sd_bus_unref(b);
|
2013-05-22 16:02:21 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|