Skip to contentSkip to conversation

Rewrite msgstress testing suite

PATCH Superseded Andrea Cervesato 4 participants 5 messages Feb 16, 2024 – Mar 8, 2024

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Rewrite msgstress testing suite

From: Andrea Cervesato <[email protected]>

msgstress testing suite has been rewritten, taking in consideration that old code was not working most of the times. The new algorithm simply generates new SysV IPC messages, spawning a sender and a receiver which will validate data.

With the new algorithm we also reduce the amount of children which we spawn, since we only have 2: sender and receiver. This permits to increase the number of messages to send and to do not be depedent from system overload.

---
 runtest/syscalls                              |   6 +-
 runtest/syscalls-ipc                          |   6 +-
 .../kernel/syscalls/ipc/msgstress/.gitignore  |   3 -
 .../kernel/syscalls/ipc/msgstress/Makefile    |   5 -
 .../syscalls/ipc/msgstress/msgstress01.c      | 414 +++++++---------
 .../syscalls/ipc/msgstress/msgstress02.c      | 408 ----------------
 .../syscalls/ipc/msgstress/msgstress03.c      | 299 ------------
 .../syscalls/ipc/msgstress/msgstress04.c      | 444 ------------------
 8 files changed, 171 insertions(+), 1414 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/ipc/msgstress/msgstress02.c
 delete mode 100644 testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
 delete mode 100644 testcases/kernel/syscalls/ipc/msgstress/msgstress04.c
runtest/syscalls +2 -4
index 7794f1465..ef4b2bcef 100644
@@ -866,12 +866,10 @@ msgctl03 msgctl03
 msgctl04 msgctl04
 msgctl05 msgctl05
 msgctl06 msgctl06
-msgstress01 msgstress01
-msgstress02 msgstress02
-msgstress03 msgstress03
-msgstress04 msgstress04
 msgctl12 msgctl12
 
+msgstress01 msgstress01
+
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
runtest/syscalls-ipc +2 -4
index df41140a7..cd41e61c1 100644
@@ -4,12 +4,10 @@ msgctl03 msgctl03
 msgctl04 msgctl04
 msgctl05 msgctl05
 msgctl06 msgctl06
-msgstress01 msgstress01
-msgstress02 msgstress02
-msgstress03 msgstress03
-msgstress04 msgstress04
 msgctl12 msgctl12
 
+msgstress01 msgstress01
+
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
testcases/kernel/syscalls/ipc/msgstress/.gitignore +0 -3
index a8f675399..fe9780693 100644
@@ -1,4 +1 @@
 /msgstress01
-/msgstress02
-/msgstress03
-/msgstress04
testcases/kernel/syscalls/ipc/msgstress/Makefile +0 -5
index b821bda01..442eb87d5 100644
@@ -3,10 +3,5 @@
 
 top_srcdir              ?= ../../../../..
 
-LTPLIBS = ltpipc
-
 include $(top_srcdir)/include/mk/testcases.mk
-
-LTPLDLIBS  += -lltpipc
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +167 -247

468 lines not on this page · raw message

testcases/kernel/syscalls/ipc/msgstress/msgstress02.c deleted +0 -408

408 lines not on this page · raw message

testcases/kernel/syscalls/ipc/msgstress/msgstress03.c deleted +0 -299

299 lines not on this page · raw message

testcases/kernel/syscalls/ipc/msgstress/msgstress04.c deleted +0 -444

444 lines not on this page · raw message

Signature · 5 lines
2.35.3


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

Hi!
First of all this patch removes all users of the libltpipc library but keeps the library orphaned in libs/ leaving a dead code.

Secondly if you look at the libmsgctl.c you can actually see that the reader and writer pair sends messages in a loop. This is imporatant because without that the test can be hardly called a stress test. The point is to start as much processes as possible that keep sending messages around so that eventually we saturate the system. The new test just sends a single message, which means that the children finish too quickly and we never run more than a single digit of read/write pairs. Given that we now have a runtime support in the test library we should change this so that the reader/write paris continue to send messages around until we are out of runtime. And the runtime should be at least a minute.

Quoted 67 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +21 -40
+static void reader(const int id)
+{
+	int size;
+	struct sysv_msg msg_recv;
+	struct sysv_data *buff = NULL;
 
-	/* Fork a number of processes, each of which will
-	 * create a message queue with one reader/writer
-	 * pair which will read and write a number (iterations)
-	 * of random length messages with specific values.
-	 */
+	memset(&msg_recv, 0, sizeof(struct sysv_msg));
 
-	for (i = 0; i < nprocs; i++) {
-		fflush(stdout);
-		if ((pid = FORK_OR_VFORK()) < 0) {
-			tst_brkm(TFAIL,
-				 NULL,
-				 "\tFork failed (may be OK if under stress)");
-		}
-		/* Child does this */
-		if (pid == 0) {
-			procstat = 1;
-			exit(dotest(keyarray[i], i));
+	size = SAFE_MSGRCV(id, &msg_recv, 100, MSGTYPE, 0);
+
+	for (int i = 0; i < ipc_data_len; i++) {
+		if (ipc_data[i].id == id) {
+			buff = ipc_data + i;
+			break;
 		}
-		pidarray[i] = pid;
 	}
 
-	count = 0;
-	while (1) {
-		if ((wait(&status)) > 0) {
-			if (status >> 8 != 0) {
-				tst_brkm(TFAIL, NULL,
-					 "Child exit status = %d",
-					 status >> 8);
-			}
-			count++;
-		} else {
-			if (errno != EINTR) {
-				break;
-			}
-#ifdef DEBUG
-			tst_resm(TINFO, "Signal detected during wait");
-#endif
-		}
+	if (!buff) {
+		tst_brk(TBROK, "Can't find original message. This is a test issue!");
+		return;
 	}
-	/* Make sure proper number of children exited */
-	if (count != nprocs) {
-		tst_brkm(TFAIL,
-			 NULL,
-			 "Wrong number of children exited, Saw %d, Expected %d",
-			 count, nprocs);
+
+	TST_EXP_EQ_LI(msg_recv.type, buff->msg.type);
+	TST_EXP_EQ_LI(msg_recv.data.len, buff->msg.data.len);
+
+	for (int i = 0; i < size; i++) {
+		if (msg_recv.data.pbytes[i] != buff->msg.data.pbytes[i]) {

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c line 130

Quoted 10 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +7 -1
+			tst_res(TFAIL, "Received wrong data at index %d: %x != %x", i,
+				msg_recv.data.pbytes[i],
+				buff->msg.data.pbytes[i]);
+
+			goto exit;
+		}
 	}
 
-	tst_resm(TPASS, "Test ran successfully!");
+	tst_res(TPASS, "Received correct data");

This spams the test output with a few hundreds of lines of output, which is known to choke test runners. For this case we should probably output one single TPASS at the end of the test.

Also this seems to be a common pattern, so we may as well add a function into the test library that would produce TPASS unless we have seen a FAIL/BROK/WARN. Or maybe just a function that would return sum of the result counters so that we can do:

	if (tst_get_res(TFAIL|TBROK|TWARN))
		tst_res(TPASS, "All data were received correctly");
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Hi!

Quoted 3 lines · Cyril Hrubis

Hi!
First of all this patch removes all users of the libltpipc library but keeps the library orphaned in libs/ leaving a dead code.

This was done by purpose. I have track of dependences inside LTP and the idea is to remove it on a second moment. But I can send a following patch removing it already.

Quoted 11 lines

Secondly if you look at the libmsgctl.c you can actually see that the reader and writer pair sends messages in a loop. This is imporatant because without that the test can be hardly called a stress test. The point is to start as much processes as possible that keep sending messages around so that eventually we saturate the system. The new test just sends a single message, which means that the children finish too quickly and we never run more than a single digit of read/write pairs. Given that we now have a runtime support in the test library we should change this so that the reader/write paris continue to send messages around until we are out of runtime. And the runtime should be at least a minute.

Actually this is a good idea, but test might send not enough messages if system is not responsive. I would keep the loop like we do now in this case, so we ensure a certain amount of stress, no matter the runtime.

Quoted 82 lines
Quoted 68 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +21 -40
+static void reader(const int id)
+{
+	int size;
+	struct sysv_msg msg_recv;
+	struct sysv_data *buff = NULL;
 
-	/* Fork a number of processes, each of which will
-	 * create a message queue with one reader/writer
-	 * pair which will read and write a number (iterations)
-	 * of random length messages with specific values.
-	 */
+	memset(&msg_recv, 0, sizeof(struct sysv_msg));
 
-	for (i = 0; i < nprocs; i++) {
-		fflush(stdout);
-		if ((pid = FORK_OR_VFORK()) < 0) {
-			tst_brkm(TFAIL,
-				 NULL,
-				 "\tFork failed (may be OK if under stress)");
-		}
-		/* Child does this */
-		if (pid == 0) {
-			procstat = 1;
-			exit(dotest(keyarray[i], i));
+	size = SAFE_MSGRCV(id, &msg_recv, 100, MSGTYPE, 0);
+
+	for (int i = 0; i < ipc_data_len; i++) {
+		if (ipc_data[i].id == id) {
+			buff = ipc_data + i;
+			break;
  		}
-		pidarray[i] = pid;
  	}
 
-	count = 0;
-	while (1) {
-		if ((wait(&status)) > 0) {
-			if (status >> 8 != 0) {
-				tst_brkm(TFAIL, NULL,
-					 "Child exit status = %d",
-					 status >> 8);
-			}
-			count++;
-		} else {
-			if (errno != EINTR) {
-				break;
-			}
-#ifdef DEBUG
-			tst_resm(TINFO, "Signal detected during wait");
-#endif
-		}
+	if (!buff) {
+		tst_brk(TBROK, "Can't find original message. This is a test issue!");
+		return;
  	}
-	/* Make sure proper number of children exited */
-	if (count != nprocs) {
-		tst_brkm(TFAIL,
-			 NULL,
-			 "Wrong number of children exited, Saw %d, Expected %d",
-			 count, nprocs);
+
+	TST_EXP_EQ_LI(msg_recv.type, buff->msg.type);
+	TST_EXP_EQ_LI(msg_recv.data.len, buff->msg.data.len);
+
+	for (int i = 0; i < size; i++) {
+		if (msg_recv.data.pbytes[i] != buff->msg.data.pbytes[i]) {

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c line 130

Quoted 10 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +7 -1
+			tst_res(TFAIL, "Received wrong data at index %d: %x != %x", i,
+				msg_recv.data.pbytes[i],
+				buff->msg.data.pbytes[i]);
+
+			goto exit;
+		}
  	}
 
-	tst_resm(TPASS, "Test ran successfully!");
+	tst_res(TPASS, "Received correct data");

This spams the test output with a few hundreds of lines of output, which is known to choke test runners. For this case we should probably output one single TPASS at the end of the test.

Quoted 9 lines

Also this seems to be a common pattern, so we may as well add a function into the test library that would produce TPASS unless we have seen a FAIL/BROK/WARN. Or maybe just a function that would return sum of the result counters so that we can do:

	if (tst_get_res(TFAIL|TBROK|TWARN))
		tst_res(TPASS, "All data were received correctly");

Isn't it like this already?

Regards,
Andrea

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

Hi!

Quoted 3 lines · Cyril Hrubis

Hi!
First of all this patch removes all users of the libltpipc library but keeps the library orphaned in libs/ leaving a dead code.

This was done by purpose. I have track of dependences inside LTP and the idea is to remove it on a second moment. But I can send a following patch removing it already.

Actually, if it was done on purpose it is a bad approach. Splitting a cleanup from a rewrite is asking to leave a dead code.

Quoted 12 lines
Quoted 11 lines

Secondly if you look at the libmsgctl.c you can actually see that the reader and writer pair sends messages in a loop. This is imporatant because without that the test can be hardly called a stress test. The point is to start as much processes as possible that keep sending messages around so that eventually we saturate the system. The new test just sends a single message, which means that the children finish too quickly and we never run more than a single digit of read/write pairs. Given that we now have a runtime support in the test library we should change this so that the reader/write paris continue to send messages around until we are out of runtime. And the runtime should be at least a minute.

Quoted 4 lines

Actually this is a good idea, but test might send not enough messages if system is not responsive.
I would keep the loop like we do now in this case, so we ensure a certain amount of stress, no matter the runtime.

I would agree with Cyril this is not much stressing (rewrite should not drop the main purpose of the test).

...

Quoted 5 lines
Quoted 5 lines

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c line 130

Quoted 2 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +1 -1
-	tst_resm(TPASS, "Test ran successfully!");
+	tst_res(TPASS, "Received correct data");

This spams the test output with a few hundreds of lines of output, which is known to choke test runners. For this case we should probably output one single TPASS at the end of the test.

Can't we exit child non-zero on failure, store that via WIFEXITED() and print TPASS only when none of the child runs failed?

Quoted 7 lines
Quoted 7 lines

Also this seems to be a common pattern, so we may as well add a function into the test library that would produce TPASS unless we have seen a FAIL/BROK/WARN. Or maybe just a function that would return sum of the result counters so that we can do:

	if (tst_get_res(TFAIL|TBROK|TWARN))
		tst_res(TPASS, "All data were received correctly");

This looks to me better approach than expect that the default is to TPASS.

Quoted 1 line

Isn't it like this already?

No, it TBROK if you don't produce any of TPASS/TFAIL/TBROK/TCONF (TBROK can be only in tst_brk()):

tst_test.c:1472: TBROK: Test 0 haven't reported results!

Kind regards,
Petr

Quoted 2 lines

Regards,
Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
In reply to Andrea Cervesato via ltp

Hi!

Quoted 5 lines
Quoted 2 lines

First of all this patch removes all users of the libltpipc library but keeps the library orphaned in libs/ leaving a dead code.

This was done by purpose. I have track of dependences inside LTP and the idea is to remove it on a second moment. But I can send a following patch removing it already.

Just add a patch that removes it as a second patch after the test conversion.

Quoted 12 lines
Quoted 11 lines

Secondly if you look at the libmsgctl.c you can actually see that the reader and writer pair sends messages in a loop. This is imporatant because without that the test can be hardly called a stress test. The point is to start as much processes as possible that keep sending messages around so that eventually we saturate the system. The new test just sends a single message, which means that the children finish too quickly and we never run more than a single digit of read/write pairs. Given that we now have a runtime support in the test library we should change this so that the reader/write paris continue to send messages around until we are out of runtime. And the runtime should be at least a minute.

Quoted 4 lines

Actually this is a good idea, but test might send not enough messages if system is not responsive.
I would keep the loop like we do now in this case, so we ensure a certain amount of stress, no matter the runtime.

As long as the test runs for long enough the pairs should send more or less equal amount of messages, the scheduller should choose the processes so that they do equal amount of work on average.

So I wouldn't be concerned with a minimal amount of loops for a given pair, unless we want to make this into a scheduller test.

Quoted 86 lines
Quoted 86 lines
Quoted 67 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +21 -40
+static void reader(const int id)
+{
+	int size;
+	struct sysv_msg msg_recv;
+	struct sysv_data *buff = NULL;
 
-	/* Fork a number of processes, each of which will
-	 * create a message queue with one reader/writer
-	 * pair which will read and write a number (iterations)
-	 * of random length messages with specific values.
-	 */
+	memset(&msg_recv, 0, sizeof(struct sysv_msg));
 
-	for (i = 0; i < nprocs; i++) {
-		fflush(stdout);
-		if ((pid = FORK_OR_VFORK()) < 0) {
-			tst_brkm(TFAIL,
-				 NULL,
-				 "\tFork failed (may be OK if under stress)");
-		}
-		/* Child does this */
-		if (pid == 0) {
-			procstat = 1;
-			exit(dotest(keyarray[i], i));
+	size = SAFE_MSGRCV(id, &msg_recv, 100, MSGTYPE, 0);
+
+	for (int i = 0; i < ipc_data_len; i++) {
+		if (ipc_data[i].id == id) {
+			buff = ipc_data + i;
+			break;
  		}
-		pidarray[i] = pid;
  	}
 
-	count = 0;
-	while (1) {
-		if ((wait(&status)) > 0) {
-			if (status >> 8 != 0) {
-				tst_brkm(TFAIL, NULL,
-					 "Child exit status = %d",
-					 status >> 8);
-			}
-			count++;
-		} else {
-			if (errno != EINTR) {
-				break;
-			}
-#ifdef DEBUG
-			tst_resm(TINFO, "Signal detected during wait");
-#endif
-		}
+	if (!buff) {
+		tst_brk(TBROK, "Can't find original message. This is a test issue!");
+		return;
  	}
-	/* Make sure proper number of children exited */
-	if (count != nprocs) {
-		tst_brkm(TFAIL,
-			 NULL,
-			 "Wrong number of children exited, Saw %d, Expected %d",
-			 count, nprocs);
+
+	TST_EXP_EQ_LI(msg_recv.type, buff->msg.type);
+	TST_EXP_EQ_LI(msg_recv.data.len, buff->msg.data.len);
+
+	for (int i = 0; i < size; i++) {
+		if (msg_recv.data.pbytes[i] != buff->msg.data.pbytes[i]) {

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c line 130

Quoted 10 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +7 -1
+			tst_res(TFAIL, "Received wrong data at index %d: %x != %x", i,
+				msg_recv.data.pbytes[i],
+				buff->msg.data.pbytes[i]);
+
+			goto exit;
+		}
  	}
 
-	tst_resm(TPASS, "Test ran successfully!");
+	tst_res(TPASS, "Received correct data");

This spams the test output with a few hundreds of lines of output, which is known to choke test runners. For this case we should probably output one single TPASS at the end of the test.

Also this seems to be a common pattern, so we may as well add a function into the test library that would produce TPASS unless we have seen a FAIL/BROK/WARN. Or maybe just a function that would return sum of the result counters so that we can do:

Quoted 5 lines
Quoted 4 lines
	if (tst_get_res(TFAIL|TBROK|TWARN))
		tst_res(TPASS, "All data were received correctly");

Isn't it like this already?

Not at all, test that does not report any results is supposed to be broken and reports TBROK. The reasoning is that test results have to be reported explicitly.

And currently we do not have any API that would allow the test to get the value of the result reporting counters, so testcases that want to report PASS/FAIL at the end of the test have to keep the track themselves, usually by having a page of shared memory with a coutner. So perhaps it would make sense to add a function that would return the value of the result counters so that we can use them to report TPASS if no errors were found during the test iteration.

Signature · 5 lines
Cyril Hrubis
[email protected]

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