Skip to contentSkip to conversation

read_all: retry to queue work for any worker

PATCH New Jan Stancek 3 participants 14 messages Oct 9, 2019 – Oct 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 read_all: retry to queue work for any worker

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null count=1 bs=1024
  1+0 records in
  1+0 records out
  1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept the work and keep trying until we succeed or hit test timeout.

---
 testcases/kernel/fs/read_all/read_all.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
testcases/kernel/fs/read_all/read_all.c +29 -2
index 3dac20e02638..4bce4521ace7 100644
@@ -282,6 +282,33 @@ static void spawn_workers(void)
 	}
 }
 
+static void work_push_retry(int worker, const char *buf)
+{
+	int i, ret, worker_min, worker_max;
+
+	if (worker < 0) {
+		/* pick any, try -worker first */
+		worker_min = worker * (-1);
+		worker_max = worker_count;
+	} else {
+		/* keep trying worker */
+		worker_min = worker;
+		worker_max = worker + 1;
+	}
+	i = worker_min;
+
+	for (;;) {
+		ret = queue_push(workers[i].q, buf);
+		if (ret == 1)
+			break;
+
+		if (++i >= worker_max) {
+			i = worker_min;
+			usleep(100000);
+		}
+	}
+}
+
 static void stop_workers(void)
 {
 	const char stop_code[1] = { '\0' };
@@ -292,7 +319,7 @@ static void stop_workers(void)
 
 	for (i = 0; i < worker_count; i++) {
 		if (workers[i].q)
-			TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1);
+			work_push_retry(i, stop_code);
 	}
 
 	for (i = 0; i < worker_count; i++) {
@@ -310,7 +337,7 @@ static void rep_sched_work(const char *path, int rep)
 	for (i = j = 0; i < rep; i++, j++) {
 		if (j >= worker_count)
 			j = 0;
-		TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
+		work_push_retry(-j, path);
 	}
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 read_all: retry to queue work for any worker

Hi!

Quoted 13 lines
testcases/kernel/fs/read_all/read_all.c +13 -0
+static void work_push_retry(int worker, const char *buf)
+{
+	int i, ret, worker_min, worker_max;
+
+	if (worker < 0) {
+		/* pick any, try -worker first */
+		worker_min = worker * (-1);
+		worker_max = worker_count;
+	} else {
+		/* keep trying worker */
+		worker_min = worker;
+		worker_max = worker + 1;
+	}

testcases/kernel/fs/read_all/read_all.c static void spawn_workers(void) · line 307

Quoted 10 lines
testcases/kernel/fs/read_all/read_all.c +10 -0
+	i = worker_min;
+
+	for (;;) {
+		ret = queue_push(workers[i].q, buf);
+		if (ret == 1)
+			break;
+
+		if (++i >= worker_max) {
+			i = worker_min;
+			usleep(100000);

My only concern is that we sleep for too long here. Maybe we should start with smaller sleep here and increase it after a while.

Or have you checked that the tests runs as fast as if we had smaller sleep here?

Quoted 31 lines
testcases/kernel/fs/read_all/read_all.c +6 -2
+		}
+	}
+}
+
 static void stop_workers(void)
 {
 	const char stop_code[1] = { '\0' };
@@ -292,7 +319,7 @@ static void stop_workers(void)
 
 	for (i = 0; i < worker_count; i++) {
 		if (workers[i].q)
-			TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1);
+			work_push_retry(i, stop_code);
 	}
 
 	for (i = 0; i < worker_count; i++) {
@@ -310,7 +337,7 @@ static void rep_sched_work(const char *path, int rep)
 	for (i = j = 0; i < rep; i++, j++) {
 		if (j >= worker_count)
 			j = 0;
-		TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
+		work_push_retry(-j, path);
 	}
 }
 
Signature · 5 lines
1.8.3.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 read_all: retry to queue work for any worker

----- Original Message -----

Quoted 29 lines

Hi!

Quoted 13 lines
testcases/kernel/fs/read_all/read_all.c +13 -0
+static void work_push_retry(int worker, const char *buf)
+{
+	int i, ret, worker_min, worker_max;
+
+	if (worker < 0) {
+		/* pick any, try -worker first */
+		worker_min = worker * (-1);
+		worker_max = worker_count;
+	} else {
+		/* keep trying worker */
+		worker_min = worker;
+		worker_max = worker + 1;
+	}

testcases/kernel/fs/read_all/read_all.c static void spawn_workers(void) · line 307

Quoted 10 lines
testcases/kernel/fs/read_all/read_all.c +10 -0
+	i = worker_min;
+
+	for (;;) {
+		ret = queue_push(workers[i].q, buf);
+		if (ret == 1)
+			break;
+
+		if (++i >= worker_max) {
+			i = worker_min;
+			usleep(100000);

My only concern is that we sleep for too long here. Maybe we should start with smaller sleep here and increase it after a while.

Quoted 2 lines

Or have you checked that the tests runs as fast as if we had smaller sleep here?

Small benchmark shows that smaller sleep can complete faster. I'll send v2.

Quoted 37 lines
Quoted 30 lines
testcases/kernel/fs/read_all/read_all.c +6 -3
+		}
+	}
+}
+
 static void stop_workers(void)
 {
 	const char stop_code[1] = { '\0' };
@@ -292,7 +319,7 @@ static void stop_workers(void)
 
 	for (i = 0; i < worker_count; i++) {
 		if (workers[i].q)
-			TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1);
+			work_push_retry(i, stop_code);
 	}
 
 	for (i = 0; i < worker_count; i++) {
@@ -310,7 +337,7 @@ static void rep_sched_work(const char *path, int rep)
 	for (i = j = 0; i < rep; i++, j++) {
 		if (j >= worker_count)
 			j = 0;
-		TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
+		work_push_retry(-j, path);
 	}
 }
 
--

1.8.3.1

Quoted 2 lines

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Cyril Hrubis
[email protected]

#3 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

In reply to Jan Stancek

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null count=1 bs=1024
  1+0 records in
  1+0 records out
  1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept the work and keep trying until we succeed or hit test timeout.

---
 testcases/kernel/fs/read_all/read_all.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

v2: Increase sleep gradually.

testcases/kernel/fs/read_all/read_all.c +31 -2
index 3dac20e02638..7beb08ccf712 100644
@@ -282,6 +282,35 @@ static void spawn_workers(void)
 	}
 }
 
+static void work_push_retry(int worker, const char *buf)
+{
+	int i, ret, worker_min, worker_max, usleep_time = 100;
+
+	if (worker < 0) {
+		/* pick any, try -worker first */
+		worker_min = worker * (-1);
+		worker_max = worker_count;
+	} else {
+		/* keep trying worker */
+		worker_min = worker;
+		worker_max = worker + 1;
+	}
+	i = worker_min;
+
+	for (;;) {
+		ret = queue_push(workers[i].q, buf);
+		if (ret == 1)
+			break;
+
+		if (++i >= worker_max) {
+			i = worker_min;
+			if (usleep_time < 100000)
+				usleep_time *= 2;
+			usleep(usleep_time);
+		}
+	}
+}
+
 static void stop_workers(void)
 {
 	const char stop_code[1] = { '\0' };
@@ -292,7 +321,7 @@ static void stop_workers(void)
 
 	for (i = 0; i < worker_count; i++) {
 		if (workers[i].q)
-			TST_RETRY_FUNC(queue_push(workers[i].q, stop_code), 1);
+			work_push_retry(i, stop_code);
 	}
 
 	for (i = 0; i < worker_count; i++) {
@@ -310,7 +339,7 @@ static void rep_sched_work(const char *path, int rep)
 	for (i = j = 0; i < rep; i++, j++) {
 		if (j >= worker_count)
 			j = 0;
-		TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
+		work_push_retry(-j, path);
 	}
 }
 
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

In reply to Jan Stancek
Quoted 52 lines · Jan Stancek

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null count=1
bs=1024
  1+0 records in
  1+0 records out
  1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept the work and keep trying until we succeed or hit test timeout.

---
 testcases/kernel/fs/read_all/read_all.c | 33
+++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

v2: Increase sleep gradually.

testcases/kernel/fs/read_all/read_all.c +16 -0
index 3dac20e02638..7beb08ccf712 100644
@@ -282,6 +282,35 @@ static void spawn_workers(void)
        }
 }
 
+static void work_push_retry(int worker, const char *buf)
+{
+       int i, ret, worker_min, worker_max, usleep_time = 100;
+
+       if (worker < 0) {
+               /* pick any, try -worker first */
+               worker_min = worker * (-1);
+               worker_max = worker_count;
+       } else {
+               /* keep trying worker */
+               worker_min = worker;
+               worker_max = worker + 1;
+       }
+       i = worker_min;
+
+       for (;;) {

testcases/kernel/fs/read_all/read_all.c static void spawn_workers(void) · line 310

Quoted 10 lines
testcases/kernel/fs/read_all/read_all.c +9 -0
+               ret = queue_push(workers[i].q, buf);
+               if (ret == 1)
+                       break;
+
+               if (++i >= worker_max) {
+                       i = worker_min;
+                       if (usleep_time < 100000)
+                               usleep_time *= 2;
+                       usleep(usleep_time);
 

At first, I thought of TST_RETRY_FN_EXP_BACKOFF, but it seems not easy to find the proper value of MAX_DELAY, so you method looks more stable to read_all.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191011/aae2d179/attachment.htm>
#6 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

Hi Jan,

Quoted 16 lines · Li Wang
Quoted 12 lines · Jan Stancek

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null count=1
bs=1024
  1+0 records in
  1+0 records out
  1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s
Quoted 9 lines
Quoted 8 lines
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept
the work and keep trying until we succeed or hit test timeout.

RFC:

Base on your patch, I'm thinking to achieve a new macro TST_INFILOOP_FUNC which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?
+/**
+ * TST_INFILOOP_FUNC() - Infinitely retry a function with an increasing delay.
+ * @FUNC - The function which will be retried
+ * @ERET - The value returned from @FUNC on success
+ *
+ * This macro will call @FUNC in an infinite loop with a delay. If @FUNC
+ * returns @ERET then the loop exits. The delay between retries starts at one
+ * microsecond and is then doubled each iteration until it exceeds one second.
+ * When the delay exceeds one-second @FUNC keep repeat until get success or hit
+ * test timeout.
+ */
+#define TST_INFILOOP_FUNC(FUNC, ERET) \
+ TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, -1)
+
#define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY) \

-({     int tst_delay_ = 1;                                             \
+({     int tst_delay_ = 1, tst_max_delay_ = MAX_DELAY;                 \
+       if (MAX_DELAY < 0)                                              \
+                tst_max_delay_ *= MAX_DELAY;                           \
        for (;;) {                                                      \
                typeof(FUNC) tst_ret_ = FUNC;                           \
                if (tst_ret_ == ERET)                                   \
                        break;                                          \
-               if (tst_delay_ < MAX_DELAY * 1000000) {                 \
-                       usleep(tst_delay_);                             \
+               usleep(tst_delay_);                                     \
+               if (tst_delay_ < tst_max_delay_ * 1000000) {            \
                        tst_delay_ *= 2;                                \
                } else {                                                \
-                       tst_brk(TBROK, #FUNC" timed out");              \
+                        if (MAX_DELAY > 0)                             \
+                               tst_brk(TBROK, #FUNC" timed out");      \
                }                                                       \
        }                                                               \
        ERET;                                                           \

Add pastebin to better readable: http://pastebin.test.redhat.com/805437

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191012/782621dd/attachment-0001.htm>
#7 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

----- Original Message -----

Quoted 29 lines

Hi Jan,

Quoted 16 lines · Li Wang
Quoted 12 lines · Jan Stancek

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null count=1
bs=1024
  1+0 records in
  1+0 records out
  1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s
Quoted 9 lines
Quoted 8 lines
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept
the work and keep trying until we succeed or hit test timeout.

Quoted 5 lines

RFC:

Base on your patch, I'm thinking to achieve a new macro TST_INFILOOP_FUNC which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?

I'm OK with concept. I'd like more some variation of *RETRY* for name. Comments below.

Quoted 15 lines

+/**
+ * TST_INFILOOP_FUNC() - Infinitely retry a function with an increasing delay.
+ * @FUNC - The function which will be retried
+ * @ERET - The value returned from @FUNC on success
+ *
+ * This macro will call @FUNC in an infinite loop with a delay. If @FUNC
+ * returns @ERET then the loop exits. The delay between retries starts at one
+ * microsecond and is then doubled each iteration until it exceeds one second.
+ * When the delay exceeds one-second @FUNC keep repeat until get success or hit
+ * test timeout.
+ */

Review

Quoted 8 lines
(quoted diff) +6 -1
+#define TST_INFILOOP_FUNC(FUNC, ERET) \
+       TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, -1)
+
 #define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY)        \
-({     int tst_delay_ = 1;                                             \
+({     int tst_delay_ = 1, tst_max_delay_ = MAX_DELAY;                 \
+       if (MAX_DELAY < 0)                                              \
+                tst_max_delay_ *= MAX_DELAY;                           \

Shouldn't this be just times (-1). For -5 you get 25 as max sleep time.

Review

Quoted 12 lines
        for (;;) {                                                      \
                typeof(FUNC) tst_ret_ = FUNC;                           \
                if (tst_ret_ == ERET)                                   \
                        break;                                          \
(quoted diff) +3 -3
-               if (tst_delay_ < MAX_DELAY * 1000000) {                 \
-                       usleep(tst_delay_);                             \
+               usleep(tst_delay_);                                     \
+               if (tst_delay_ < tst_max_delay_ * 1000000) {            \
                        tst_delay_ *= 2;                                \
                } else {                                                \
-                       tst_brk(TBROK, #FUNC" timed out");              \
+                        if (MAX_DELAY > 0)                             \

pastebin has this condition backwards, but here it looks ok.

Quoted 11 lines
+                               tst_brk(TBROK, #FUNC" timed out");      \
                }                                                       \
        }                                                               \
        ERET;                                                           \

Add pastebin to better readable: http://pastebin.test.redhat.com/805437

--
Regards,
Li Wang

#8 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

Quoted 34 lines · Jan Stancek

----- Original Message -----

Quoted 7 lines

Hi Jan,

Quoted 3 lines · Li Wang

On Wed, Oct 9, 2019 at 10:43 PM Jan Stancek <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null

count=1

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

bs=1024
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s

  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept
the work and keep trying until we succeed or hit test timeout.

Quoted 9 lines
Quoted 5 lines

RFC:

Base on your patch, I'm thinking to achieve a new macro TST_INFILOOP_FUNC which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?

I'm OK with concept. I'd like more some variation of *RETRY* for name. Comments below.

Thanks, what about naming: TST_INFI_RETRY_FUNC?

And do you mind use it to replace your function work_push_retry()? I know it may be not smarter than work_push_retry() but it looks tiny for code.

Quoted 12 lines

...

Review

Quoted 8 lines
(quoted diff) +6 -1
+#define TST_INFILOOP_FUNC(FUNC, ERET) \
+       TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, -1)
+
 #define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY)        \
-({     int tst_delay_ = 1;                                             \
+({     int tst_delay_ = 1, tst_max_delay_ = MAX_DELAY;                 \
+       if (MAX_DELAY < 0)                                              \
+                tst_max_delay_ *= MAX_DELAY;                           \

Shouldn't this be just times (-1). For -5 you get 25 as max sleep time.

Agree.

Quoted 14 lines

Review

Quoted 13 lines
        for (;;) {                                                      \
                typeof(FUNC) tst_ret_ = FUNC;                           \
                if (tst_ret_ == ERET)                                   \
                        break;                                          \
(quoted diff) +3 -3
-               if (tst_delay_ < MAX_DELAY * 1000000) {                 \
-                       usleep(tst_delay_);                             \
+               usleep(tst_delay_);                                     \
+               if (tst_delay_ < tst_max_delay_ * 1000000) {            \
                        tst_delay_ *= 2;                                \
                } else {                                                \
-                       tst_brk(TBROK, #FUNC" timed out");              \
+                        if (MAX_DELAY > 0)                             \
Quoted 1 line

pastebin has this condition backwards, but here it looks ok

Sorry for the typo in pastebin.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191012/beccb1b9/attachment.htm>
#9 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

----- Original Message -----

Quoted 42 lines · Jan Stancek
Quoted 41 lines

----- Original Message -----

Quoted 7 lines

Hi Jan,

Quoted 3 lines · Li Wang

On Wed, Oct 9, 2019 at 10:43 PM Jan Stancek <[email protected]>

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines

read_all is currently retrying only for short time period and it's retrying to queue for same worker. If that worker is busy, it easily hits timeout.

For example 'kernel_page_tables' on aarch64 can take long time to open/read:

  # time dd if=/sys/kernel/debug/kernel_page_tables of=/dev/null

count=1

Quoted 19 lines
Quoted 5 lines
Quoted 5 lines

bs=1024
1+0 records in
1+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 13.0531 s, 0.1 kB/s

Quoted 9 lines
Quoted 8 lines
  real    0m13.066s
  user    0m0.000s
  sys     0m13.059s

Rather than retrying to queue for specific worker, pick any that can accept
the work and keep trying until we succeed or hit test timeout.

RFC:

Base on your patch, I'm thinking to achieve a new macro TST_INFILOOP_FUNC which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?

Quoted 5 lines
Quoted 3 lines

I'm OK with concept. I'd like more some variation of *RETRY* for name. Comments below.

Thanks, what about naming: TST_INFI_RETRY_FUNC?

Or just keep TST_RETRY_FUNC and add parameter to it?

Quoted 3 lines

And do you mind use it to replace your function work_push_retry()? I know it may be not smarter than work_push_retry() but it looks tiny for code.

It may need some wrapper, because work_push_retry() may be passing different argument to function on each retry, which was one of reasons for the patch.

Quoted 38 lines
Quoted 13 lines

...

Review

Quoted 8 lines
(quoted diff) +6 -1
+#define TST_INFILOOP_FUNC(FUNC, ERET) \
+       TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, -1)
+
 #define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY)        \
-({     int tst_delay_ = 1;                                             \
+({     int tst_delay_ = 1, tst_max_delay_ = MAX_DELAY;                 \
+       if (MAX_DELAY < 0)                                              \
+                tst_max_delay_ *= MAX_DELAY;                           \

Shouldn't this be just times (-1). For -5 you get 25 as max sleep time.

Agree.

Quoted 14 lines

Review

Quoted 13 lines
        for (;;) {                                                      \
                typeof(FUNC) tst_ret_ = FUNC;                           \
                if (tst_ret_ == ERET)                                   \
                        break;                                          \
(quoted diff) +3 -3
-               if (tst_delay_ < MAX_DELAY * 1000000) {                 \
-                       usleep(tst_delay_);                             \
+               usleep(tst_delay_);                                     \
+               if (tst_delay_ < tst_max_delay_ * 1000000) {            \
                        tst_delay_ *= 2;                                \
                } else {                                                \
-                       tst_brk(TBROK, #FUNC" timed out");              \
+                        if (MAX_DELAY > 0)                             \
Quoted 1 line

pastebin has this condition backwards, but here it looks ok

Sorry for the typo in pastebin.

--
Regards,
Li Wang

#10 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

Quoted 6 lines · Jan Stancek

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Base on your patch, I'm thinking to achieve a new macro

TST_INFILOOP_FUNC

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm OK with concept. I'd like more some variation of *RETRY* for name. Comments below.

Thanks, what about naming: TST_INFI_RETRY_FUNC?

Or just keep TST_RETRY_FUNC and add parameter to it?

Sounds better, we could add parameter @INFI to control the retry as a knob.

/* @INFI - 1: retry infinitely, 0: retry in limit times */

#define TST_RETRY_FUNC(FUNC, ERET, INFI) \
TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, 1, INFI)

Quoted 8 lines
Quoted 3 lines

And do you mind use it to replace your function work_push_retry()? I know it may be not smarter than work_push_retry() but it looks tiny for code.

It may need some wrapper, because work_push_retry() may be passing different
argument to function on each retry, which was one of reasons for the patch.

I was not meaning to hack the work_push_retry() function, I mean to change your patch as below after we improve the TST_RETRY_FUNC.

# git diff .
(quoted diff) +0 -0

b/testcases/kernel/fs/read_all/read_all.c
index 3dac20e..ccbc5eb 100644

testcases/kernel/fs/read_all/read_all.c +0 -1
@@ -292,7 +292,7 @@ static void stop_workers(void)
 
        for (i = 0; i < worker_count; i++) {
                if (workers[i].q)
-                       TST_RETRY_FUNC(queue_push(workers[i].q, stop_code),

1);
+ TST_RETRY_FUNC(queue_push(workers[i].q, stop_code),

1, 1);
        }

        for (i = 0; i < worker_count; i++) {
@@ -310,7 +310,7 @@ static void rep_sched_work(const char *path, int rep)
        for (i = j = 0; i < rep; i++, j++) {
                if (j >= worker_count)
                        j = 0;
-               TST_RETRY_FUNC(queue_push(workers[j].q, path), 1);
+               TST_RETRY_FUNC(queue_push(workers[j].q, path), 1, 1);
        }

}

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191012/10131c99/attachment-0001.htm>
#11 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

----- Original Message -----

Quoted 17 lines · Jan Stancek
Quoted 7 lines

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Base on your patch, I'm thinking to achieve a new macro

TST_INFILOOP_FUNC

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

which can repeat the @FUNC infinitely. Do you feel it satisfies your requirements to some degree or meaningful to LTP?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm OK with concept. I'd like more some variation of *RETRY* for name. Comments below.

Thanks, what about naming: TST_INFI_RETRY_FUNC?

Or just keep TST_RETRY_FUNC and add parameter to it?

Quoted 6 lines

Sounds better, we could add parameter @INFI to control the retry as a knob.

/* @INFI - 1: retry infinitely, 0: retry in limit times */

#define TST_RETRY_FUNC(FUNC, ERET, INFI) \
TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, 1, INFI)

Other option is we use directly TST_RETRY_FN_EXP_BACKOFF.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

And do you mind use it to replace your function work_push_retry()? I know it may be not smarter than work_push_retry() but it looks tiny for code.

Quoted 7 lines
Quoted 4 lines

It may need some wrapper, because work_push_retry() may be passing different
argument to function on each retry, which was one of reasons for the patch.

I was not meaning to hack the work_push_retry() function, I mean to change your patch as below after we improve the TST_RETRY_FUNC.

Why not? Wouldn't we get better performance if we don't wait on specific worker to complete?

#12 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

Quoted 23 lines · Jan Stancek

----- Original Message -----

Quoted 6 lines · Jan Stancek
Quoted 5 lines

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Base on your patch, I'm thinking to achieve a new macro

TST_INFILOOP_FUNC

Quoted 1 line
Quoted 1 line
Quoted 1 line

which can repeat the @FUNC infinitely. Do you feel it satisfies

your

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

requirements to some degree or meaningful to LTP?

I'm OK with concept. I'd like more some variation of *RETRY* for

name.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Comments below.

Thanks, what about naming: TST_INFI_RETRY_FUNC?

Or just keep TST_RETRY_FUNC and add parameter to it?

Sounds better, we could add parameter @INFI to control the retry as a

Quoted 9 lines

knob.

Quoted 5 lines

/* @INFI - 1: retry infinitely, 0: retry in limit times */

#define TST_RETRY_FUNC(FUNC, ERET, INFI) \
TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, 1, INFI)

Other option is we use directly TST_RETRY_FN_EXP_BACKOFF.

I'm ok for either. I will have a try when I get a chance since mkswap01.sh sometimes timed out in the one-second retrying.

Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

And do you mind use it to replace your function work_push_retry()? I

know

Quoted 1 line
Quoted 1 line
Quoted 1 line

it may be not smarter than work_push_retry() but it looks tiny for

code.

Quoted 4 lines
Quoted 4 lines

It may need some wrapper, because work_push_retry() may be passing different
argument to function on each retry, which was one of reasons for the

patch.

Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 1 line

I was not meaning to hack the work_push_retry() function, I mean to

change

Quoted 1 line

your patch as below after we improve the TST_RETRY_FUNC.

Why not? Wouldn't we get better performance if we don't wait on specific worker
to complete?

Well, right! You can merge this patch as it is.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191014/37921d27/attachment.htm>
#13 lore raw

PATCH v2 1/1 read_all: retry to queue work for any worker

----- Original Message -----

Quoted 1 line

Well, right! You can merge this patch as it is.

Pushed.