* [PATCH v0 0/3] lockperf: a few small improvments @ 2016-06-02 9:16 Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Daniel Wagner @ 2016-06-02 9:16 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, Dave Chinner, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> Hi Jeff, I had a bunch of small patches in my tree, which I forgot to send. So here they are... cheers, daniel Daniel Wagner (3): Synchronize all clients on start up posix03, posix04: Use '-l' instead of '-i' as option argument name posix03: Do not kill everything in the process group flock01.c | 24 ++++++++++++++++++++++-- flock02.c | 24 ++++++++++++++++++++++-- posix01.c | 24 ++++++++++++++++++++++-- posix02.c | 24 ++++++++++++++++++++++-- posix03.c | 23 ++++++++++++++++++----- posix04.c | 6 +++--- 6 files changed, 109 insertions(+), 16 deletions(-) -- 2.5.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v0 1/3] Synchronize all clients on start up 2016-06-02 9:16 [PATCH v0 0/3] lockperf: a few small improvments Daniel Wagner @ 2016-06-02 9:16 ` Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 2/3] posix03, posix04: Use '-l' instead of '-i' as option argument name Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 3/3] posix03: Do not kill everything in the process group Daniel Wagner 2 siblings, 0 replies; 5+ messages in thread From: Daniel Wagner @ 2016-06-02 9:16 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, Dave Chinner, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> The child process start working as soon as they are forked. Sometimes that leads to a workload pattern that no contention happens at all even with a high number of processes. Since the main motivation of this this is to benchmark the contention overhead let the clients wait till all client processes are created. Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> --- flock01.c | 24 ++++++++++++++++++++++-- flock02.c | 24 ++++++++++++++++++++++-- posix01.c | 24 ++++++++++++++++++++++-- posix02.c | 24 ++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/flock01.c b/flock01.c index f5416f6..5335cd2 100644 --- a/flock01.c +++ b/flock01.c @@ -29,6 +29,8 @@ #define NRPROC (128) #define NRLOCK (10240) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -84,7 +86,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -123,11 +126,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(argv[optind], nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/flock02.c b/flock02.c index 81c770a..7c1a470 100644 --- a/flock02.c +++ b/flock02.c @@ -30,6 +30,8 @@ #define NRPROC (128) #define NRLOCK (20480) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -91,7 +93,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -142,11 +145,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/posix01.c b/posix01.c index 09f1de6..432a667 100644 --- a/posix01.c +++ b/posix01.c @@ -30,6 +30,8 @@ #define NRPROC (128) #define NRLOCK (10240) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -97,7 +99,8 @@ int main(int argc, char **argv) { bool verbose = false, yield = false; - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -142,12 +145,29 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(argv[optind], nlock, &diff[i], verbose, yield); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/posix02.c b/posix02.c index 9a35c99..5fb2a4d 100644 --- a/posix02.c +++ b/posix02.c @@ -29,6 +29,8 @@ #define NRPROC (128) #define NRLOCK (20480) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -93,7 +95,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -144,11 +147,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; -- 2.5.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v0 2/3] posix03, posix04: Use '-l' instead of '-i' as option argument name 2016-06-02 9:16 [PATCH v0 0/3] lockperf: a few small improvments Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner @ 2016-06-02 9:16 ` Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 3/3] posix03: Do not kill everything in the process group Daniel Wagner 2 siblings, 0 replies; 5+ messages in thread From: Daniel Wagner @ 2016-06-02 9:16 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, Dave Chinner, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> All other test use '=l' instead of '-i' to as option name for defining how many loops should be executed. Let's streamline posix03 and posix04. Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> --- posix03.c | 6 +++--- posix04.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/posix03.c b/posix03.c index 864f0f0..a36caa5 100644 --- a/posix03.c +++ b/posix03.c @@ -109,7 +109,7 @@ static int do_child(int lockfd, int i, int to_lockers, int from_lockers) static int usage(char *argv0) { - errx(1, "Usage: %s [-i iterations] [-n nr_children] <filename>", argv0); + errx(1, "Usage: %s [-n nr_procs] [-l nr_loops] <filename>", argv0); } int main(int argc, char *argv[]) @@ -126,9 +126,9 @@ int main(int argc, char *argv[]) total.tv_sec = 0; total.tv_nsec = 0; - while ((opt = getopt(argc, argv, "i:n:")) != -1) { + while ((opt = getopt(argc, argv, "l:n:")) != -1) { switch (opt) { - case 'i': + case 'l': iter = atoi(optarg); break; case 'n': diff --git a/posix04.c b/posix04.c index ed862f2..67eb4af 100644 --- a/posix04.c +++ b/posix04.c @@ -158,7 +158,7 @@ static int do_child(int fd, int id, int nproc, int to_lockers, int from_lockers) static int usage(char *argv0) { - errx(1, "Usage: %s [-i iterations] [-n nr_children] [-s] <filename>", argv0); + errx(1, "Usage: %s [-n nr_procs] [-l nr_loops] [-s] <filename>", argv0); } int main(int argc, char *argv[]) @@ -175,9 +175,9 @@ int main(int argc, char *argv[]) total.tv_sec = 0; total.tv_nsec = 0; - while ((opt = getopt(argc, argv, "i:n:s")) != -1) { + while ((opt = getopt(argc, argv, "l:n:s")) != -1) { switch (opt) { - case 'i': + case 'l': iter = atoi(optarg); break; case 'n': -- 2.5.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v0 3/3] posix03: Do not kill everything in the process group 2016-06-02 9:16 [PATCH v0 0/3] lockperf: a few small improvments Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 2/3] posix03, posix04: Use '-l' instead of '-i' as option argument name Daniel Wagner @ 2016-06-02 9:16 ` Daniel Wagner 2 siblings, 0 replies; 5+ messages in thread From: Daniel Wagner @ 2016-06-02 9:16 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, Dave Chinner, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> kill(0, SIGINT) sends to all in the process group the signal including the parent shell. Instead remember the PIDs of all children and just send the signal to these processes. Reported-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> --- posix03.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/posix03.c b/posix03.c index a36caa5..4ee130b 100644 --- a/posix03.c +++ b/posix03.c @@ -71,13 +71,18 @@ static int fcntl_unlock(int fd, off_t off, off_t len) return fcntl(fd, F_SETLKW, &fl); } +/* The PIDs of all children */ +static pid_t *cpids; + static void kill_children() { siginfo_t infop; + int i; signal(SIGINT, SIG_IGN); - kill(0, SIGINT); + for (i = 0; cpids[i]; i++) + kill(cpids[i], SIGINT); while (waitid(P_ALL, 0, &infop, WEXITED) != -1); } @@ -161,14 +166,21 @@ int main(int argc, char *argv[]) signal(SIGINT, sighandler); + cpids = malloc((num + 1) * sizeof(pid_t)); + if (!cpids) + err(1, "malloc"); + cpids[num] = 0; + for (i = 0; i < num; i++) { - switch (fork()) { + pid_t pid = fork(); + switch (pid) { case 0: signal(SIGINT, SIG_DFL); return do_child(lockfd, i, to_lockers[0], from_lockers[1]); case -1: err(1, "fork failed"); } + cpids[i] = pid; } close(to_lockers[0]); @@ -208,5 +220,6 @@ int main(int argc, char *argv[]) printf("%ld.%09ld\n", total.tv_sec, total.tv_nsec); kill_children(); + free(cpids); return 0; } -- 2.5.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v0 0/3] [RESEND] lockperf: a few small improvments @ 2016-09-22 8:46 Daniel Wagner 2016-09-22 8:46 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner 0 siblings, 1 reply; 5+ messages in thread From: Daniel Wagner @ 2016-09-22 8:46 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, linux-kernel, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> Hi Jeff, I had a bunch of small patches in my tree, which I forgot to send. So here they are... cheers, daniel Daniel Wagner (3): Synchronize all clients on start up posix03, posix04: Use '-l' instead of '-i' as option argument name posix03: Do not kill everything in the process group flock01.c | 24 ++++++++++++++++++++++-- flock02.c | 24 ++++++++++++++++++++++-- posix01.c | 24 ++++++++++++++++++++++-- posix02.c | 24 ++++++++++++++++++++++-- posix03.c | 23 ++++++++++++++++++----- posix04.c | 6 +++--- 6 files changed, 109 insertions(+), 16 deletions(-) -- 2.5.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v0 1/3] Synchronize all clients on start up 2016-09-22 8:46 [PATCH v0 0/3] [RESEND] lockperf: a few small improvments Daniel Wagner @ 2016-09-22 8:46 ` Daniel Wagner 0 siblings, 0 replies; 5+ messages in thread From: Daniel Wagner @ 2016-09-22 8:46 UTC (permalink / raw) To: Jeff Layton; +Cc: linux-fsdevel, linux-kernel, Daniel Wagner From: Daniel Wagner <daniel.wagner@bmw-carit.de> The child process start working as soon as they are forked. Sometimes that leads to a workload pattern that no contention happens at all even with a high number of processes. Since the main motivation of this this is to benchmark the contention overhead let the clients wait till all client processes are created. Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> --- flock01.c | 24 ++++++++++++++++++++++-- flock02.c | 24 ++++++++++++++++++++++-- posix01.c | 24 ++++++++++++++++++++++-- posix02.c | 24 ++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/flock01.c b/flock01.c index f5416f6..5335cd2 100644 --- a/flock01.c +++ b/flock01.c @@ -29,6 +29,8 @@ #define NRPROC (128) #define NRLOCK (10240) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -84,7 +86,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -123,11 +126,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(argv[optind], nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/flock02.c b/flock02.c index 81c770a..7c1a470 100644 --- a/flock02.c +++ b/flock02.c @@ -30,6 +30,8 @@ #define NRPROC (128) #define NRLOCK (20480) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -91,7 +93,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -142,11 +145,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/posix01.c b/posix01.c index 09f1de6..432a667 100644 --- a/posix01.c +++ b/posix01.c @@ -30,6 +30,8 @@ #define NRPROC (128) #define NRLOCK (10240) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -97,7 +99,8 @@ int main(int argc, char **argv) { bool verbose = false, yield = false; - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -142,12 +145,29 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(argv[optind], nlock, &diff[i], verbose, yield); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; diff --git a/posix02.c b/posix02.c index 9a35c99..5fb2a4d 100644 --- a/posix02.c +++ b/posix02.c @@ -29,6 +29,8 @@ #define NRPROC (128) #define NRLOCK (20480) +#define TFR TEMP_FAILURE_RETRY + static struct timespec *diff; static int @@ -93,7 +95,8 @@ usage(char *prog) int main(int argc, char **argv) { - int i, opt, valid = 0; + int i, c, opt, valid = 0; + int to_lockers[2]; int nproc = NRPROC; int nlock = NRLOCK; pid_t *pids; @@ -144,11 +147,28 @@ main(int argc, char **argv) return 1; } + if (pipe(to_lockers)) { + fprintf(stderr, "pipe (to_lockers)"); + return 1; + } + for (i = 0; i < nproc; ++i) { pids[i] = fork(); - if (!pids[i]) + if (!pids[i]) { + while (TFR(read(to_lockers[0], &c, 1)) != 1) + ; return lockunlock(nlock, &diff[i]); + } + } + + close(to_lockers[0]); + for (i = 0; i < nproc; ++i) { + if (TFR(write(to_lockers[1], &c, 1)) != 1) { + perror("write child"); + return 1; + } } + close(to_lockers[1]); for (i = 0; i < nproc; ++i) { int status; -- 2.5.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-22 8:46 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-06-02 9:16 [PATCH v0 0/3] lockperf: a few small improvments Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 2/3] posix03, posix04: Use '-l' instead of '-i' as option argument name Daniel Wagner 2016-06-02 9:16 ` [PATCH v0 3/3] posix03: Do not kill everything in the process group Daniel Wagner -- strict thread matches above, loose matches on Subject: below -- 2016-09-22 8:46 [PATCH v0 0/3] [RESEND] lockperf: a few small improvments Daniel Wagner 2016-09-22 8:46 ` [PATCH v0 1/3] Synchronize all clients on start up Daniel Wagner
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).