Skip to contentSkip to conversation

fsplough: Implement runtime awareness

PATCH In review Martin Doucha 2 participants 6 messages Feb 11, 2025 – Feb 12, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fsplough: Implement runtime awareness

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.

---
 testcases/kernel/fs/fsplough/fsplough.c | 39 ++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 4 deletions(-)
testcases/kernel/fs/fsplough/fsplough.c +35 -4
index 66aa37c47..6ce644a8d 100644
@@ -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"},
Signature · 5 lines
2.47.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 2/2 nfs10.sh: Remove fixed loop count from fsplough command

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.

---
 testcases/network/nfs/nfs_stress/nfs10.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/network/nfs/nfs_stress/nfs10.sh +4 -4
index 17fb4e866..e52db8e29 100755
@@ -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
Signature · 5 lines
2.47.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/2
#2 lore raw

Re: [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command

Hi Martin,

Quoted 2 lines

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!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] [PATCH 2/2] nfs10.sh: Remove fixed loop count from fsplough command

In reply to Martin Doucha

Hi Martin,

Thanks, patchset merged.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/2
#4 lore raw
In reply to Martin Doucha

Hi Martin,

Quoted 4 lines

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

testcases/kernel/fs/fsplough/fsplough.c static void run(void) · line 249

Quoted 10 lines
testcases/kernel/fs/fsplough/fsplough.c +10 -0
+	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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Hi!

Quoted 22 lines · Petr Vorel

Hi Martin,

Quoted 4 lines

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

testcases/kernel/fs/fsplough/fsplough.c static void run(void) · line 249

Quoted 10 lines
testcases/kernel/fs/fsplough/fsplough.c +10 -0
+	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/

Quoted 1 line

I'll fix this before merge.

Thanks!

Signature · 10 lines
Martin Doucha   [email protected]
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