From: Daniel Wagner <wagi@monom.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Daniel Wagner <daniel.wagner@bmw-carit.de>
Subject: [PATCH v0 1/3] Synchronize all clients on start up
Date: Thu, 22 Sep 2016 10:46:05 +0200 [thread overview]
Message-ID: <1474533967-4404-2-git-send-email-wagi@monom.org> (raw)
In-Reply-To: <1474533967-4404-1-git-send-email-wagi@monom.org>
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
next prev parent reply other threads:[~2016-09-22 8:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 8:46 [PATCH v0 0/3] [RESEND] lockperf: a few small improvments Daniel Wagner
2016-09-22 8:46 ` Daniel Wagner [this message]
2016-09-22 8:46 ` [PATCH v0 2/3] posix03, posix04: Use '-l' instead of '-i' as option argument name Daniel Wagner
2016-09-22 8:46 ` [PATCH v0 3/3] posix03: Do not kill everything in the process group Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474533967-4404-2-git-send-email-wagi@monom.org \
--to=wagi@monom.org \
--cc=daniel.wagner@bmw-carit.de \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®