diff options
4 files changed, 402 insertions, 0 deletions
diff --git a/debian/patches/fixes0001-utils-settrans-implement-active-translator-stacking.patch b/debian/patches/fixes0001-utils-settrans-implement-active-translator-stacking.patch new file mode 100644 index 00000000..544ca932 --- /dev/null +++ b/debian/patches/fixes0001-utils-settrans-implement-active-translator-stacking.patch @@ -0,0 +1,88 @@ +From 1a6818d5ff3d897c2636c9585e1cb94db5d6368e Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Sat, 23 Apr 2016 17:39:47 +0200 +Subject: [PATCH hurd 1/3] utils/settrans: implement active translator stacking + +* utils/settrans.c (OPT_STACK): New macro. +(options): New option. +(main): Handle new option. +(open_node): Use different flags for the lookup of the underlying +node. +--- + utils/settrans.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/utils/settrans.c b/utils/settrans.c +index e01906b..ee7cba5 100644 +--- a/utils/settrans.c ++++ b/utils/settrans.c +@@ -47,6 +47,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION (settrans); + #define STRINGIFY(arg) _STRINGIFY (arg) + + #define OPT_CHROOT_CHDIR -1 ++#define OPT_STACK -2 + + static struct argp_option options[] = + { +@@ -66,6 +67,8 @@ static struct argp_option options[] = + "(do not ask it to go away)"}, + {"underlying", 'U', "NODE", 0, "Open NODE and hand it to the translator " + "as the underlying node"}, ++ {"stack", OPT_STACK, 0, 0, "Replace an existing translator, but keep it " ++ "running, and put the new one on top"}, + + {"chroot", 'C', 0, 0, + "Instead of setting the node's translator, take following arguments up to" +@@ -156,10 +159,12 @@ main(int argc, char *argv[]) + int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0, + orphan = 0; + int start = 0; ++ int stack = 0; + char *pid_file = NULL; + int excl = 0; + int timeout = DEFAULT_TIMEOUT * 1000; /* ms */ + char *underlying_node_name = NULL; ++ int underlying_lookup_flags; + char **chroot_command = 0; + char *chroot_chdir = "/"; + +@@ -193,6 +198,11 @@ main(int argc, char *argv[]) + start = 1; + active = 1; /* start implies active */ + break; ++ case OPT_STACK: ++ stack = 1; ++ active = 1; /* stack implies active */ ++ orphan = 1; /* stack implies orphan */ ++ break; + case 'p': passive = 1; break; + case 'k': keep_active = 1; break; + case 'g': kill_active = 1; break; +@@ -261,6 +271,14 @@ main(int argc, char *argv[]) + + argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, 0); + ++ if (stack) ++ { ++ underlying_node_name = node_name; ++ underlying_lookup_flags = lookup_flags && ~O_NOTRANS; ++ } ++ else ++ underlying_lookup_flags = lookup_flags; ++ + if (!active && !passive && !chroot_command) + passive = 1; /* By default, set the passive translator. */ + +@@ -341,7 +359,8 @@ main(int argc, char *argv[]) + if (underlying_node_name) + { + *underlying = file_name_lookup (underlying_node_name, +- flags | lookup_flags, 0666); ++ flags | underlying_lookup_flags, ++ 0666); + if (! MACH_PORT_VALID (*underlying)) + { + /* For the error message. */ +-- +2.1.4 + diff --git a/debian/patches/fixes0002-Avoid-superfluous-locking-of-node.patch b/debian/patches/fixes0002-Avoid-superfluous-locking-of-node.patch new file mode 100644 index 00000000..b1dbafaf --- /dev/null +++ b/debian/patches/fixes0002-Avoid-superfluous-locking-of-node.patch @@ -0,0 +1,60 @@ +From 614e8df719de7b7b03f9a15ee3049e3a29b06f87 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 25 Apr 2016 00:54:08 +0200 +Subject: [PATCH hurd 2/3] Avoid superfluous locking of node + +* libdiskfs/io-restrict-auth.c (diskfs_S_io_restrict_auth): Do not +lock the associated node. No operation here needs synchronization. +* libnetfs/io-restrict-auth.c (netfs_S_io_restrict_auth): Likewise. +--- + libdiskfs/io-restrict-auth.c | 2 -- + libnetfs/io-restrict-auth.c | 3 --- + 2 files changed, 5 deletions(-) + +diff --git a/libdiskfs/io-restrict-auth.c b/libdiskfs/io-restrict-auth.c +index 80c0b20..1c2c999 100644 +--- a/libdiskfs/io-restrict-auth.c ++++ b/libdiskfs/io-restrict-auth.c +@@ -40,7 +40,6 @@ diskfs_S_io_restrict_auth (struct protid *cred, + if (err) + return err; + +- pthread_mutex_lock (&cred->po->np->lock); + refcount_ref (&cred->po->refcnt); + err = diskfs_create_protid (cred->po, user, &newpi); + if (! err) +@@ -51,7 +50,6 @@ diskfs_S_io_restrict_auth (struct protid *cred, + } + else + refcount_deref (&cred->po->refcnt); +- pthread_mutex_unlock (&cred->po->np->lock); + + iohelp_free_iouser (user); + return err; +diff --git a/libnetfs/io-restrict-auth.c b/libnetfs/io-restrict-auth.c +index 79b7d09..89df671 100644 +--- a/libnetfs/io-restrict-auth.c ++++ b/libnetfs/io-restrict-auth.c +@@ -42,19 +42,16 @@ netfs_S_io_restrict_auth (struct protid *user, + if (err) + return err; + +- pthread_mutex_lock (&user->po->np->lock); + refcount_ref (&user->po->refcnt); + newpi = netfs_make_protid (user->po, new_user); + if (newpi) + { + *newport = ports_get_right (newpi); +- pthread_mutex_unlock (&user->po->np->lock); + *newporttype = MACH_MSG_TYPE_MAKE_SEND; + } + else + { + refcount_deref (&user->po->refcnt); +- pthread_mutex_unlock (&user->po->np->lock); + iohelp_free_iouser (new_user); + err = ENOMEM; + } +-- +2.1.4 + diff --git a/debian/patches/fixes0003-fstests-new-micro-benchmark.patch b/debian/patches/fixes0003-fstests-new-micro-benchmark.patch new file mode 100644 index 00000000..95dbcf01 --- /dev/null +++ b/debian/patches/fixes0003-fstests-new-micro-benchmark.patch @@ -0,0 +1,251 @@ +From 9b975c48726c0a9ac19c3c9b0e701970b3dab8ea Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 25 Apr 2016 00:59:01 +0200 +Subject: [PATCH hurd 3/3] fstests: new micro benchmark + +* fstests/Makefile: Build 'benchmark'. +* fstests/benchmark.c: New file. +--- + fstests/Makefile | 6 +- + fstests/benchmark.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 213 insertions(+), 1 deletion(-) + create mode 100644 fstests/benchmark.c + +diff --git a/fstests/Makefile b/fstests/Makefile +index 6374242..8058247 100644 +--- a/fstests/Makefile ++++ b/fstests/Makefile +@@ -19,7 +19,9 @@ dir := fstests + makemode := utilities + + SRCS = fstests.c fdtests.c timertest.c opendisk.c +-targets = timertest fstests # opendisk fdtests ++targets = timertest fstests benchmark # opendisk fdtests ++HURDLIBS = shouldbeinlibc ++benchmark-LDLIBS = -lpthread + + include ../Makeconf + +@@ -27,3 +29,5 @@ timertest: timertest.o + fstests: fstests.o + opendisk: opendisk.o + fdtests: fdtests.o ++benchmark: benchmark.o \ ++ ../libshouldbeinlibc/libshouldbeinlibc.a +diff --git a/fstests/benchmark.c b/fstests/benchmark.c +new file mode 100644 +index 0000000..a4c501e +--- /dev/null ++++ b/fstests/benchmark.c +@@ -0,0 +1,208 @@ ++/* Performance testing. ++ ++ Copyright (C) 2016 Free Software Foundation, Inc. ++ ++ This file is part of the GNU Hurd. ++ ++ The GNU Hurd is free software; you can redistribute it and/or ++ modify it under the terms of the GNU General Public License as ++ published by the Free Software Foundation; either version 2, or (at ++ your option) any later version. ++ ++ The GNU Hurd 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 ++ General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */ ++ ++#include <argp.h> ++#include <error.h> ++#include <fcntl.h> ++#include <hurd.h> ++#include <inttypes.h> ++#include <mach.h> ++#include <maptime.h> ++#include <pthread.h> ++#include <stdlib.h> ++#include <stdio.h> ++#include <string.h> ++#include <sys/mman.h> ++#include <sys/stat.h> ++#include <unistd.h> ++#include <version.h> ++ ++static char *target_path = NULL; ++ ++size_t iterations = 1l<<18; ++size_t threads = 2; ++ ++const char *argp_program_version = STANDARD_HURD_VERSION (benchmark); ++ ++static const struct argp_option options[] = ++{ ++ {"iterations", 'n', "N", 0, "Repeat tests N times"}, ++ {"threads", 't', "N", 0, "Run N threads"}, ++ {} ++}; ++ ++/* Parse a command line option. */ ++error_t parse_opt (int key, char *arg, struct argp_state *state) ++{ ++ char *arg_end; ++ unsigned long *ptr = NULL; ++ ++ switch (key) ++ { ++ case 't': ++ ptr = ptr ?: &threads; ++ case 'n': ++ ptr = ptr ?: &iterations; ++ ++ *ptr = strtoul (arg, &arg_end, 10); ++ if (*arg == '\0' || *arg_end != '\0') ++ argp_error (state, "invalid integer: %s", arg); ++ break; ++ ++ case ARGP_KEY_ARG: ++ target_path = strdup (arg); ++ if (! target_path) ++ argp_error (state, "Error while canonicalizing path"); ++ break; ++ ++ case ARGP_KEY_NO_ARGS: ++ argp_usage (state); ++ return EINVAL; ++ ++ default: ++ return ARGP_ERR_UNKNOWN; ++ } ++ return 0; ++} ++ ++static struct argp argp = ++ { ++ options, ++ parse_opt, ++ "TARGET\tFile name of a node with an active translator", ++ "A translator providing mtab compatible information about active " ++ "and passive translators below TARGET.", ++ }; ++ ++ ++ ++volatile struct mapped_time_value *mtime; ++ ++struct worker_cookie ++{ ++ pthread_t thread; ++ error_t (*dost) (void *); ++ error_t err; ++ size_t count; ++ struct timeval runtime; ++}; ++ ++void * ++worker_thread (void *cookie) ++{ ++ error_t err = 0; ++ struct worker_cookie *args = cookie; ++ struct timeval start_time; ++ struct timeval end_time; ++ size_t count; ++ ++ maptime_read (mtime, &start_time); ++ ++ for (count = args->count; count; count--) ++ { ++ err = args->dost (cookie); ++ if (err) ++ break; ++ } ++ ++ maptime_read (mtime, &end_time); ++ timersub (&end_time, &start_time, &args->runtime); ++ ++ args->count = count; ++ args->err = err; ++ return NULL; ++} ++ ++void ++print_stats (const char *id, size_t nt, size_t n, struct timeval *tv) ++{ ++ double duration = ++ (tv->tv_sec + (tv->tv_usec / 1000000.)) / (double) nt; ++ fprintf (stderr, ++ "% 10s: %.2fs\t%fns\t%9.3f (1/s)\n", ++ id, ++ duration, ++ 1000000000. * duration / n, ++ n / duration); ++} ++ ++ ++ ++static error_t ++do_dir_lookup (void *cookie) ++{ ++ file_t f; ++ f = file_name_lookup (target_path, 0, 0); ++ if (! MACH_PORT_VALID (f)) ++ return errno; ++ mach_port_deallocate (mach_task_self (), f); ++ return 0; ++} ++ ++ ++ ++int ++main (int argc, char *argv[]) ++{ ++ error_t err; ++ size_t i; ++ struct worker_cookie *cookies; ++ struct timeval accumulated_time = {0}; ++ ++ err = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, 0); ++ if (err) ++ error (1, err, "argument parsing"); ++ ++ fprintf (stderr, "N: %u (1<<%d)\n", ++ iterations, __builtin_ffs (iterations) - 1); ++ ++ err = maptime_map (0, NULL, &mtime); ++ if (err) ++ error (1, err, "maptime_map"); ++ ++ cookies = calloc (threads, sizeof *cookies); ++ if (cookies == NULL) ++ error (1, errno, "calloc"); ++ ++ for (i = 0; i < threads; i++) ++ { ++ cookies[i].count = iterations / threads; ++ cookies[i].dost = do_dir_lookup; ++ err = pthread_create (&cookies[i].thread, NULL, ++ &worker_thread, &cookies[i]); ++ if (err) ++ error (2, err, "pthread_create"); ++ } ++ ++ for (i = 0; i < threads; i++) ++ { ++ err = pthread_join (cookies[i].thread, NULL); ++ if (err) ++ error (3, err, "pthread_join"); ++ ++ if (cookies[i].err) ++ error (3, err, "thread %d", i); ++ ++ timeradd (&accumulated_time, &cookies[i].runtime, &accumulated_time); ++ } ++ ++ print_stats ("dir_lookup", threads, iterations, &accumulated_time); ++ ++ return 0; ++} +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 9215b81d..51f5d2f8 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -45,3 +45,6 @@ assert0001-libpager-add-missing-include.patch assert0002-libshouldbeinlibc-add-assert-3-variant-that-prints-b.patch assert0003-libshouldbeinlibc-use-the-new-assert-in-the-refcount.patch crash0001-xxx-crash-logging-works.patch +fixes0001-utils-settrans-implement-active-translator-stacking.patch +fixes0002-Avoid-superfluous-locking-of-node.patch +fixes0003-fstests-new-micro-benchmark.patch |