Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] fsplough: Implement runtime awareness
@ 2025-02-11 12:23 Martin Doucha
  2025-02-11 12:23 ` [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command Martin Doucha
  2025-02-11 21:04 ` [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Petr Vorel
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Doucha @ 2025-02-11 12:23 UTC (permalink / raw)
  To: ltp

Switch fsplough test to run for 30 seconds by default, with the option
to set a fixed number of loops on command line instead. The test will
always exit when runtime expires and a warning will be printed
if there were too few iterations due to expired runtime.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/fs/fsplough/fsplough.c | 39 ++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/fs/fsplough/fsplough.c b/testcases/kernel/fs/fsplough/fsplough.c
index 66aa37c47..6ce644a8d 100644
--- a/testcases/kernel/fs/fsplough/fsplough.c
+++ b/testcases/kernel/fs/fsplough/fsplough.c
@@ -25,12 +25,13 @@ static char *workdir_arg;
 static char *directwr_flag;
 static char *directrd_flag;
 static char *loop_arg;
-static int loop_count = 4096;
+static int loop_count;
 
 static int read_fd = -1, write_fd = -1;
 static char *writebuf, *filedata;
 static size_t blocksize, bufsize, filesize;
 
+static struct tst_test test;
 static void do_write(void *buf, size_t offset, size_t size);
 static void do_pwrite(void *buf, size_t offset, size_t size);
 static void do_writev(void *buf, size_t offset, size_t size);
@@ -163,6 +164,7 @@ static void setup(void)
 {
 	struct statvfs statbuf;
 	size_t pagesize;
+	int runtime;
 
 	srand(time(0));
 	pagesize = SAFE_SYSCONF(_SC_PAGESIZE);
@@ -190,7 +192,17 @@ static void setup(void)
 		MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 	filedata = SAFE_MALLOC(filesize);
 
-	tst_set_timeout(bufsize * loop_count / (8 * 1024 * 1024));
+	if (loop_arg) {
+		/*
+		 * Executing fixed number of loops. Use calculated runtime
+		 * as timeout and apply the timeout multiplier.
+		 */
+		runtime = bufsize * loop_count / (8 * 1024 * 1024);
+		runtime = tst_multiply_timeout(runtime);
+
+		if (runtime > test.runtime)
+			tst_set_runtime(runtime);
+	}
 }
 
 static void run(void)
@@ -199,7 +211,10 @@ static void run(void)
 	int i, f, fails = 0;
 
 	/* Test data consistency between random writes */
-	for (i = 0; i < loop_count; i++) {
+	for (i = 0; !loop_arg || i < loop_count; i++) {
+		if (!tst_remaining_runtime())
+			break;
+
 		length = fill_buffer(writebuf, bufsize);
 		start = rand() % (filesize + 1 - length);
 
@@ -222,6 +237,20 @@ static void run(void)
 		}
 	}
 
+	if (i < loop_count / 2) {
+		tst_res(TWARN, "Runtime expired, exiting early after %d loops",
+			i);
+		tst_res(TINFO, "If you are running on slow machine, "
+			"try exporting LTP_TIMEOUT_MUL > 1");
+	} else if (i < loop_count) {
+		tst_res(TINFO, "Runtime expired, exiting early after %d loops",
+			i);
+	} else if (!loop_arg && i < 10) {
+		tst_res(TWARN, "Slow sytem: test performed only %d loops!", i);
+	} else {
+		tst_res(TPASS, "Exiting after %d loops", i);
+	}
+
 	if (!fails)
 		tst_res(TPASS, "Partial data are consistent");
 
@@ -269,8 +298,10 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_tmpdir = 1,
+	.runtime = 30,
 	.options = (struct tst_option[]) {
-		{"c:", &loop_arg, "Number of write loops (default: 4096)"},
+		{"c:", &loop_arg,
+			"Number of write loops (default: loop for 30 seconds)"},
 		{"d:", &workdir_arg, "Path to working directory"},
 		{"W", &directwr_flag, "Use direct I/O for writing"},
 		{"R", &directrd_flag, "Use direct I/O for reading"},
-- 
2.47.0


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command
  2025-02-11 12:23 [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Martin Doucha
@ 2025-02-11 12:23 ` Martin Doucha
  2025-02-11 21:06   ` Petr Vorel
  2025-02-11 21:44   ` Petr Vorel
  2025-02-11 21:04 ` [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Petr Vorel
  1 sibling, 2 replies; 6+ messages in thread
From: Martin Doucha @ 2025-02-11 12:23 UTC (permalink / raw)
  To: ltp

The fsplough test now runs for 30 seconds by default. Remove the fixed
number of loops from the NFS variant and use the safer default behavior.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/network/nfs/nfs_stress/nfs10.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs10.sh b/testcases/network/nfs/nfs_stress/nfs10.sh
index 17fb4e866..e52db8e29 100755
--- a/testcases/network/nfs/nfs_stress/nfs10.sh
+++ b/testcases/network/nfs/nfs_stress/nfs10.sh
@@ -25,25 +25,25 @@ nfs10_setup()
 do_test1()
 {
 	tst_res TINFO "Testing buffered write, buffered read"
-	EXPECT_PASS fsplough -c 512 -d "$PWD"
+	EXPECT_PASS fsplough -d "$PWD"
 }
 
 do_test2()
 {
 	tst_res TINFO "Testing buffered write, direct read"
-	EXPECT_PASS fsplough -c 512 -R -d "$PWD"
+	EXPECT_PASS fsplough -R -d "$PWD"
 }
 
 do_test3()
 {
 	tst_res TINFO "Testing direct write, buffered read"
-	EXPECT_PASS fsplough -c 512 -W -d "$PWD"
+	EXPECT_PASS fsplough -W -d "$PWD"
 }
 
 do_test4()
 {
 	tst_res TINFO "Testing direct write, direct read"
-	EXPECT_PASS fsplough -c 512 -RW -d "$PWD"
+	EXPECT_PASS fsplough -RW -d "$PWD"
 }
 
 . nfs_lib.sh
-- 
2.47.0


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/2] fsplough: Implement runtime awareness
  2025-02-11 12:23 [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Martin Doucha
  2025-02-11 12:23 ` [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command Martin Doucha
@ 2025-02-11 21:04 ` Petr Vorel
  2025-02-12  9:41   ` Martin Doucha
  1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2025-02-11 21:04 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

> Switch fsplough test to run for 30 seconds by default, with the option
> to set a fixed number of loops on command line instead. The test will
> always exit when runtime expires and a warning will be printed
> if there were too few iterations due to expired runtime.

+1
Reviewed-by: Petr Vorel <pvorel@suse.cz>

> +	if (i < loop_count / 2) {
> +		tst_res(TWARN, "Runtime expired, exiting early after %d loops",
> +			i);
> +		tst_res(TINFO, "If you are running on slow machine, "
> +			"try exporting LTP_TIMEOUT_MUL > 1");
> +	} else if (i < loop_count) {
> +		tst_res(TINFO, "Runtime expired, exiting early after %d loops",
> +			i);
> +	} else if (!loop_arg && i < 10) {
> +		tst_res(TWARN, "Slow sytem: test performed only %d loops!", i);
s/sytem/system/

I'll fix this before merge.

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command
  2025-02-11 12:23 ` [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command Martin Doucha
@ 2025-02-11 21:06   ` Petr Vorel
  2025-02-11 21:44   ` Petr Vorel
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2025-02-11 21:06 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

> The fsplough test now runs for 30 seconds by default. Remove the fixed
> number of loops from the NFS variant and use the safer default behavior.

Obviously correct, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command
  2025-02-11 12:23 ` [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command Martin Doucha
  2025-02-11 21:06   ` Petr Vorel
@ 2025-02-11 21:44   ` Petr Vorel
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2025-02-11 21:44 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

Thanks, patchset merged.

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] [PATCH 1/2] fsplough: Implement runtime awareness
  2025-02-11 21:04 ` [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Petr Vorel
@ 2025-02-12  9:41   ` Martin Doucha
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Doucha @ 2025-02-12  9:41 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!

On 11. 02. 25 22:04, Petr Vorel wrote:
> Hi Martin,
> 
>> Switch fsplough test to run for 30 seconds by default, with the option
>> to set a fixed number of loops on command line instead. The test will
>> always exit when runtime expires and a warning will be printed
>> if there were too few iterations due to expired runtime.
> 
> +1
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
>> +	if (i < loop_count / 2) {
>> +		tst_res(TWARN, "Runtime expired, exiting early after %d loops",
>> +			i);
>> +		tst_res(TINFO, "If you are running on slow machine, "
>> +			"try exporting LTP_TIMEOUT_MUL > 1");
>> +	} else if (i < loop_count) {
>> +		tst_res(TINFO, "Runtime expired, exiting early after %d loops",
>> +			i);
>> +	} else if (!loop_arg && i < 10) {
>> +		tst_res(TWARN, "Slow sytem: test performed only %d loops!", i);
> s/sytem/system/
> 
> I'll fix this before merge.

Thanks!

-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-12  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 12:23 [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Martin Doucha
2025-02-11 12:23 ` [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command Martin Doucha
2025-02-11 21:06   ` Petr Vorel
2025-02-11 21:44   ` Petr Vorel
2025-02-11 21:04 ` [LTP] [PATCH 1/2] fsplough: Implement runtime awareness Petr Vorel
2025-02-12  9:41   ` Martin Doucha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox