Skip to contentSkip to conversation

Add test case to cover the setting resource limit64 for process

PATCH Superseded chunfuwen 6 participants 22 messages Feb 18, 2025 – Feb 28, 2025

lore
Share & tools
lore

chunfuwen

author
#0 lore raw

PATCH 1/1 Add test case to cover the setting resource limit64 for process

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +129 -0
new file mode 100644
index 000000000..031d58c64
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+/*
+ * Description:
+ * Set CPU time limit64 for a process and check its behavior
+ * after reaching CPU time limit64.
+ * 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
+ * 2) Process got SIGKILL after reaching hard limit of CPU time limit64.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/mman.h>
+#include <inttypes.h>
+
+#include "tst_test.h"
+
+#include "lapi/syscalls.h"
+#include "lapi/abisize.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+	uint64_t rlim_cur;
+	uint64_t rlim_max;
+};
+#endif
+
+static int *end;
+
+static void sighandler(int sig)
+{
+	*end = sig;
+}
+
+static void setup(void)
+{
+	SAFE_SIGNAL(SIGXCPU, sighandler);
+
+	end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
+			MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+}
+
+static void cleanup(void)
+{
+	if (end)
+		SAFE_MUNMAP(end, sizeof(int));
+}
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+    return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+static void verify_setrlimit64(void)
+{
+	int status;
+	pid_t pid;
+	struct rlimit64 rlim;
+	rlim.rlim_cur = 1;
+	rlim.rlim_max = 2;
+
+	*end = 0;
+
+	pid = SAFE_FORK();
+	if (!pid) {
+		TEST(setrlimit_u64(RLIMIT_CPU, &rlim));
+		if (TST_RET == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"setrlimit_u64(RLIMIT_CPU) failed");
+			exit(1);
+		}
+
+		alarm(20);
+
+		while (1);
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+
+	if (WIFEXITED(status) && WEXITSTATUS(status) == 1)
+		return;
+
+	if (WIFSIGNALED(status)) {
+		if (WTERMSIG(status) == SIGKILL && *end == SIGXCPU) {
+			tst_res(TPASS,
+				"Got SIGXCPU then SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGKILL && !*end) {
+			tst_res(TFAIL,
+				"Got only SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && *end == SIGXCPU) {
+			tst_res(TFAIL,
+				"Got only SIGXCPU after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && !*end) {
+			tst_res(TFAIL,
+				"Got no signal after reaching both limit");
+			return;
+		}
+	}
+
+	tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static struct tst_test test = {
+	.test_all = verify_setrlimit64,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+};
Signature · 5 lines
2.43.5


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

Hello,

A few comments in line.

Quoted 17 lines · chunfuwen

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 129 ++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +0 -0
new file mode 100644
index 000000000..031d58c64

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 3

Quoted 3 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +3 -0
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2017 Red Hat Inc. All Rights Reserved.

Is this an old source being sent upstream or can we bump this to 2025?

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 8

Quoted 5 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +5 -0
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+/*
+ * Description:

No need for this line.

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 13

Quoted 5 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +5 -0
+ * Set CPU time limit64 for a process and check its behavior
+ * after reaching CPU time limit64.
+ * 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
+ * 2) Process got SIGKILL after reaching hard limit of CPU time limit64.
+ *

Trailing line should be removed.

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +8 -0
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/resource.h>

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 31

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/mman.h>
+#include <inttypes.h>
+
+#include "tst_test.h"
+
+#include "lapi/syscalls.h"
+#include "lapi/abisize.h"

I was able to build using:

#define _GNU_SOURCE
#include <sys/resource.h>

#include "tst_test.h"

#include "lapi/syscalls.h"

So, perhaps trim the includes down?

Quoted 22 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +22 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+	uint64_t rlim_cur;
+	uint64_t rlim_max;
+};
+#endif
+
+static int *end;
+
+static void sighandler(int sig)
+{
+	*end = sig;
+}
+
+static void setup(void)
+{
+	SAFE_SIGNAL(SIGXCPU, sighandler);
+
+	end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
+			MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+}

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 63

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+
+static void cleanup(void)
+{
+	if (end)
+		SAFE_MUNMAP(end, sizeof(int));
+}
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+    return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);

Please use tab instead of spaces.

Quoted 14 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +14 -0
+}
+
+static void verify_setrlimit64(void)
+{
+	int status;
+	pid_t pid;
+	struct rlimit64 rlim;
+	rlim.rlim_cur = 1;
+	rlim.rlim_max = 2;
+
+	*end = 0;
+
+	pid = SAFE_FORK();
+	if (!pid) {

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 87

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+		TEST(setrlimit_u64(RLIMIT_CPU, &rlim));
+		if (TST_RET == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"setrlimit_u64(RLIMIT_CPU) failed");
+			exit(1);
+		}
+
+		alarm(20);
+
+		while (1);

nit: Use the following to make checkpatch happy:

		while (1)
			;
Quoted 32 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +32 -0
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+
+	if (WIFEXITED(status) && WEXITSTATUS(status) == 1)
+		return;
+
+	if (WIFSIGNALED(status)) {
+		if (WTERMSIG(status) == SIGKILL && *end == SIGXCPU) {
+			tst_res(TPASS,
+				"Got SIGXCPU then SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGKILL && !*end) {
+			tst_res(TFAIL,
+				"Got only SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && *end == SIGXCPU) {
+			tst_res(TFAIL,
+				"Got only SIGXCPU after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && !*end) {
+			tst_res(TFAIL,
+				"Got no signal after reaching both limit");
+			return;
+		}
+	}

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 129

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+
+	tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static struct tst_test test = {
+	.test_all = verify_setrlimit64,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+};

With those fixed:

Thank you,
- Ricardo.

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

Hi!

The whole test is a duplication of the setrlimit06, so it's better to work on that one and to introduce the 64bits support using 64bit test variant.

A couple of comments about the implementation:

- we are already defining the "struct rlimit64" inside getrlimit03, so we need to create a new file lapi/resource.h where we move that struct, checking if HAVE_STRUCT_RLIMIT64 is not defined. I guess the same should be done for getrlimit_u64()/setrlimit_u64() syscalls definitions. Better to move them in there in case we will need it in the future . We can skip SAFE_* variants at the moment, since we are not using them around LTP test for now.

- in both setrlimit06 and setrlimit07 we should probably use tst_buffers for safety reasons when passing the pointer to the rlimit/rlimit64 struct we are gonna use

- it's worth to check if the other tests might introduce the same 64bit variants

FYI i noticed that setrlimit06 description can't be fetched in the metadata because it's not initialized with /*\ . It also needs to be changed into the RST format instead of asciidoc.

King regards,
Andrea Cervesato

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

Hello,
See inline comments.
Best Regards,
Chunfu Wen

Quoted 39 lines · Andrea Cervesato

Hi!

The whole test is a duplication of the setrlimit06, so it's better to work on that one and to introduce the 64bits support using 64bit test variant.
[chwen]Maybe it is a good idea to use separate setrlimit07.c file to support using 64bit testing, since it can bring into two benefits. 1)align with gettrlimit, it has separate file getrlimit03.c for 64bits, and it help easily extend more scernao cases for 64bits 2) Putting them in separate file is more convenient for users to select test case specfic 64bits testing once users need that.

A couple of comments about the implementation:

- we are already defining the "struct rlimit64" inside getrlimit03, so we need to create a new file lapi/resource.h where we move that struct, checking if HAVE_STRUCT_RLIMIT64 is not defined. I guess the same should be done for getrlimit_u64()/setrlimit_u64() syscalls definitions. Better to move them in there in case we will need it in the future . We can skip SAFE_* variants at the moment, since we are not using them around LTP test for now.

- in both setrlimit06 and setrlimit07 we should probably use tst_buffers for safety reasons when passing the pointer to the rlimit/rlimit64 struct we are gonna use

- it's worth to check if the other tests might introduce the same 64bit variants

FYI i noticed that setrlimit06 description can't be fetched in the metadata because it's not initialized with /*\ . It also needs to be changed into the RST format instead of asciidoc.

King regards,
Andrea Cervesato

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

Hi,

Quoted 9 lines · Chunfu Wen

Hello,
See inline comments.
Best Regards,
Chunfu Wen

On Tue, Feb 18, 2025 at 9:29 PM Andrea Cervesato <[email protected]> wrote:

Hi!

Quoted 11 lines

The whole test is a duplication of the setrlimit06, so it's better to work on that one and to introduce the 64bits support using 64bit test variant.
[chwen]Maybe it is a good idea to use separate setrlimit07.c file to support using 64bit testing, since it can bring into two benefits. 1)align with gettrlimit, it has separate
file getrlimit03.c for 64bits, and it help easily extend more scernao cases for 64bits 2) Putting them in separate file is more convenient for users to select test case specfic 64bits testing once users need that.

If the goal is to generate a 64bit binary so users can easily run it without variants, you don't need a new file but to edit the Makefile adding:

    include $(abs_srcdir)/../utils/newer_64.mk

    %_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64

In this way you will have a 64bit binary for each test in the folder. At that point, to switch between syscalls according to the 64bit architecture definition is easy and runtest file will need to be updated accordingly. If you take a look at the other test cases you will find many examples on this method.

Andrea

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

PATCH v2 1/1 Add test case to cover the setting resource limit64 for process

In reply to Andrea Cervesato via ltp

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v2:
- Romove test descriptions and trailing line as suggested by Ricardo B. Marlière
- Added 2025 copyright as suggested by Ricardo B. Marlière
- Trim down include files as suggested by Ricardo B. Marlière
- Create new lapi/resource.h residing struct rlimit64 as suggested by Andrea
- Move setrlimit_u64() syscalls definitions into lapi/resource.h as suggested by Andrea
- Skip SAFE_* variants as suggested by Andrea
- use tst_buffers when passing the pointeras suggested by Andrea
- Link to v1:https://lore.kernel.org/all/[email protected]/

---
 include/lapi/resource.h                       |  26 ++++
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 127 ++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 include/lapi/resource.h
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
include/lapi/resource.h new file +26 -0
new file mode 100644
index 000000000..3310bc934
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +127 -0

127 lines not on this page · raw message

Signature · 5 lines
2.43.5


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

Hi Chunfu Wen,

Besides Andrea's comments, there are other things to improve.

Quoted 29 lines

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v2:
- Romove test descriptions and trailing line as suggested by Ricardo B. Marlière
- Added 2025 copyright as suggested by Ricardo B. Marlière
- Trim down include files as suggested by Ricardo B. Marlière
- Create new lapi/resource.h residing struct rlimit64 as suggested by Andrea
- Move setrlimit_u64() syscalls definitions into lapi/resource.h as suggested by Andrea
- Skip SAFE_* variants as suggested by Andrea
- use tst_buffers when passing the pointeras suggested by Andrea
- Link to v1:https://lore.kernel.org/all/[email protected]/

---
 include/lapi/resource.h                       |  26 ++++
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 127 ++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 include/lapi/resource.h
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
include/lapi/resource.h new file +0 -0
new file mode 100644
index 000000000..3310bc934

include/lapi/resource.h line 9

Quoted 9 lines
include/lapi/resource.h new file +9 -0
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+

There should be at the top

#include "config.h"
otherwise #ifndef HAVE_STRUCT_RLIMIT64 is always false.

include/lapi/resource.h line 12

Quoted 3 lines
include/lapi/resource.h new file +3 -0
+#define _GNU_SOURCE
+
+#include "lapi/syscalls.h"

This should include some header, I guess:
#include <sys/resource.h>

because there is already a check.
AC_CHECK_TYPES([struct rlimit64],,,[
#define _LARGEFILE64_SOURCE
#include <sys/resource.h>
])

NOTE: we prefer to uses libc headers instead of kernel headers if possible (e.g. not using <linux/resource.h>) due libc and kernel headers conflicts.
https://sourceware.org/glibc/wiki/Synchronizing_Headers

include/lapi/resource.h line 23

Quoted 11 lines
include/lapi/resource.h new file +11 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);

I suppose using raw syscall is really needed, right?

C library/kernel ABI differences
Since glibc 2.13, the glibc getrlimit() and setrlimit() wrapper functions no longer invoke the corresponding system calls, but instead employ prlimit(), for the reasons described in BUGS.

The name of the glibc wrapper function is prlimit(); the underlying system call is prlimit64().

man getrlimit(2) says:
https://man7.org/linux/man-pages/man2/getrlimit.2.html

C library/kernel ABI differences
Since glibc 2.13, the glibc getrlimit() and setrlimit() wrapper functions no longer invoke the corresponding system calls, but instead employ prlimit(), for the reasons described in BUGS.

The name of the glibc wrapper function is prlimit(); the underlying system call is prlimit64().

...
Since glibc 2.13, glibc works around the limitations of the getrlimit() and setrlimit() system calls by implementing setrlimit() and getrlimit() as wrapper functions that call prlimit().

include/lapi/resource.h line 26

Quoted 3 lines
include/lapi/resource.h new file +3 -0
+}
+
+#endif /* LAPI_RESOURCE_H__ */

I would probably separate adding the header into it's own commit, but it's ok to have everything in a single commit.

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +2 -0
new file mode 100644
index 000000000..60a4580da
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 12

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+/*
+ * Set CPU time limit64 for a process and check its behavior
+ * after reaching CPU time limit64.
+ * 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
+ * 2) Process got SIGKILL after reaching hard limit of CPU time limit64.
+ */

Please use docs like this:

/*\
* Set CPU time limit64 for a process and check its behavior
* after reaching CPU time limit64.
*
* 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
* 2) Process got SIGKILL after reaching hard limit of CPU time limit64. */

/*\ is for docs to be parsed in metadata/ltp.json and included in
https://linux-test-project.readthedocs.io/en/latest/users/test_catalog.html

Extra space between list is needed to 1) and 2) be filtered as a list (not inline).

Ideally you build the docs yourself
https://linux-test-project.readthedocs.io/en/latest/developers/documentation.html#building-documentation

and check the output in: doc/html/users/test_catalog.html#setrlimit07

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 22

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+
+#define _GNU_SOURCE
+
+#include <sys/wait.h>
+
+#include "tst_test.h"
+
+#include "lapi/syscalls.h"
+
+#include "lapi/resource.h"

very nit: please remove blank lines between inludes

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 29

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+	uint64_t rlim_cur;
+	uint64_t rlim_max;
+};
+#endif

This is defined in lapi/resource.h which you include, no need to repeat it here.

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+
+static struct  rlimit64*rlim;
+
+static int *end;
+
+static void sighandler(int sig)

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 45

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+{
+	*end = sig;
+}
+
+static void setup(void)
+{
+	signal(SIGXCPU, sighandler);
+
+	end = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE,
+		   MAP_SHARED | MAP_ANONYMOUS, -1, 0);

Please use SAFE_MMAP(), otherwise there would have to be check:

if (end == MAP_FAILED)

	tst_brk(TBROK | TERRNO, "mmap failed on nfildes");

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 51

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+}
+
+static void cleanup(void)
+{
+	if (end)
+		munmap(end, sizeof(int));

We have SAFE_MUNMAP

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 57

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+}
+/*
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+	return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}*/

Hm, commented out code, please remove it.

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+
+static void verify_setrlimit64(void)
+{
+	int status;
+	pid_t pid;
+
+	rlim->rlim_cur = 1;

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 74

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+	rlim->rlim_max = 2;
+
+	*end = 0;
+
+	pid = fork();
+	if (!pid) {
+		TEST(setrlimit_u64(RLIMIT_CPU, rlim));
+		if (TST_RET == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"setrlimit_u64(RLIMIT_CPU) failed");

We have TST_EXP_PASS() in tst_test_macros.h, please use it (or other if this is not appropriate.

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 81

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+			exit(1);
 
+		}
+
+		alarm(20);
+
+		while (1)
+			;

Why this?

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 84

Quoted 3 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +3 -0
+	}
+
+	waitpid(pid, &status, 0);

Maybe SAFE_WAITPID() ?

Quoted 28 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +28 -0
+
+	if (WIFEXITED(status) && WEXITSTATUS(status) == 1)
+		return;
+
+	if (WIFSIGNALED(status)) {
+		if (WTERMSIG(status) == SIGKILL && *end == SIGXCPU) {
+			tst_res(TPASS,
+				"Got SIGXCPU then SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGKILL && !*end) {
+			tst_res(TFAIL,
+				"Got only SIGKILL after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && *end == SIGXCPU) {
+			tst_res(TFAIL,
+				"Got only SIGXCPU after reaching both limit");
+			return;
+		}
+
+		if (WTERMSIG(status) == SIGALRM && !*end) {
+			tst_res(TFAIL,
+				"Got no signal after reaching both limit");
+			return;
+		}

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 122

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+	}
+
+	tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static struct tst_test test = {
+	.test_all = verify_setrlimit64,
+        .bufs = (struct tst_buffers []) {
+                {&rlim, .size = sizeof(*rlim)},
+                {},

+1 for using guarded buffers.
Please fix the indent.

Last, but not least, code style:

$ make check-setrlimit07
CHECK testcases/kernel/syscalls/setrlimit/setrlimit07.c
setrlimit07.c:31: ERROR: "foo*bar" should be "foo *bar"
setrlimit07.c:54: WARNING: Block comments use * on subsequent lines
setrlimit07.c:57: WARNING: Block comments use a trailing */ on a separate line
setrlimit07.c:120: ERROR: code indent should use tabs where possible
setrlimit07.c:120: WARNING: please, no spaces at the start of a line
setrlimit07.c:121: ERROR: code indent should use tabs where possible
setrlimit07.c:121: WARNING: please, no spaces at the start of a line
setrlimit07.c:122: ERROR: code indent should use tabs where possible
setrlimit07.c:122: WARNING: please, no spaces at the start of a line

Kind regards,
Petr

Quoted 5 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +5 -0
+	},
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
Quoted 70 lines · Petr Vorel

Hi Chunfu Wen,

Besides Andrea's comments, there are other things to improve.

Quoted 1 line

The test ensures that the process gets the correct signals in the

correct order:

Quoted 7 lines

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v2:
- Romove test descriptions and trailing line as suggested by Ricardo B.

Marlière

Quoted 3 lines

- Added 2025 copyright as suggested by Ricardo B. Marlière
- Trim down include files as suggested by Ricardo B. Marlière
- Create new lapi/resource.h residing struct rlimit64 as suggested by

Andrea

Quoted 1 line

- Move setrlimit_u64() syscalls definitions into lapi/resource.h as

suggested by Andrea

Quoted 3 lines

- Skip SAFE_* variants as suggested by Andrea
- use tst_buffers when passing the pointeras suggested by Andrea
- Link to v1:

https://lore.kernel.org/all/[email protected]/

Quoted 13 lines
---
 include/lapi/resource.h                       |  26 ++++
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 127 ++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 include/lapi/resource.h
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
include/lapi/resource.h new file +0 -0
new file mode 100644
index 000000000..3310bc934

include/lapi/resource.h line 9

Quoted 9 lines
include/lapi/resource.h new file +9 -0
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+

There should be at the top

#include "config.h"
otherwise #ifndef HAVE_STRUCT_RLIMIT64 is always false.

include/lapi/resource.h line 12

Quoted 3 lines
include/lapi/resource.h new file +3 -0
+#define _GNU_SOURCE
+
+#include "lapi/syscalls.h"

This should include some header, I guess:
#include <sys/resource.h>

because there is already a check.
AC_CHECK_TYPES([struct rlimit64],,,[
#define _LARGEFILE64_SOURCE
#include <sys/resource.h>
])

NOTE: we prefer to uses libc headers instead of kernel headers if possible (e.g. not using <linux/resource.h>) due libc and kernel headers conflicts.
https://sourceware.org/glibc/wiki/Synchronizing_Headers

Quoted 13 lines

include/lapi/resource.h line 23

Quoted 11 lines
include/lapi/resource.h new file +11 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);

I suppose using raw syscall is really needed, right?

Yes, using the raw syscall for prlimit64 is necessary in this case.

From what I know, Chufu is working oin an environment where glibc's wrapper might interfere, using tst_syscall(__NR_prlimit64, ...) ensures that the raw syscall is executed without relying on glibc behavior.

@chuwen, this new case is quite similar to setrlimit06.c, maybe we can combine into one and use .test_variants to traverse all syscalls. e.g. syscalls/stime/stime_var.h.

Signature · 5 lines
Regards,
Li Wang

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

Hi Li, Chunfu Wen,
...

Quoted 10 lines
Quoted 4 lines

include/lapi/resource.h line 23

Quoted 3 lines
include/lapi/resource.h new file +3 -0
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);

I suppose using raw syscall is really needed, right?

Yes, using the raw syscall for prlimit64 is necessary in this case.

From what I know, Chufu is working oin an environment where glibc's wrapper might interfere, using tst_syscall(__NR_prlimit64, ...) ensures that the raw syscall is executed without relying on glibc behavior.

Li, thanks for info.

Quoted 3 lines

@chuwen, this new case is quite similar to setrlimit06.c, maybe we can combine into one and use .test_variants to traverse all syscalls. e.g. syscalls/stime/stime_var.h.

+1

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw
In reply to Petr Vorel

Hello Petr,

Thanks for reviewing.
See inline comments.

Chunfu Wen

Quoted 4 lines · Petr Vorel

Hi Chunfu Wen,

Besides Andrea's comments, there are other things to improve.

[chwen] merge all things into setrlimit06.c, and delete setrlimit07.c

Quoted 47 lines
Quoted 3 lines

The test ensures that the process gets the correct signals in the

correct order:

Quoted 7 lines

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v2:
- Romove test descriptions and trailing line as suggested by Ricardo B.

Marlière

Quoted 3 lines

- Added 2025 copyright as suggested by Ricardo B. Marlière
- Trim down include files as suggested by Ricardo B. Marlière
- Create new lapi/resource.h residing struct rlimit64 as suggested by

Andrea

Quoted 1 line

- Move setrlimit_u64() syscalls definitions into lapi/resource.h as

suggested by Andrea

Quoted 3 lines

- Skip SAFE_* variants as suggested by Andrea
- use tst_buffers when passing the pointeras suggested by Andrea
- Link to v1:

https://lore.kernel.org/all/[email protected]/

Quoted 13 lines
---
 include/lapi/resource.h                       |  26 ++++
 .../kernel/syscalls/setrlimit/setrlimit07.c   | 127 ++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 include/lapi/resource.h
 create mode 100644 testcases/kernel/syscalls/setrlimit/setrlimit07.c
include/lapi/resource.h new file +0 -0
new file mode 100644
index 000000000..3310bc934

include/lapi/resource.h line 9

Quoted 9 lines
include/lapi/resource.h new file +9 -0
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+

There should be at the top

Quoted 3 lines

#include "config.h"
otherwise #ifndef HAVE_STRUCT_RLIMIT64 is always false.

[chwen] Done.

Quoted 8 lines

include/lapi/resource.h line 12

Quoted 4 lines
include/lapi/resource.h new file +3 -0
+#define _GNU_SOURCE
+
+#include "lapi/syscalls.h"

This should include some header, I guess:
#include <sys/resource.h>

[chwen] added

Quoted 264 lines

because there is already a check.
AC_CHECK_TYPES([struct rlimit64],,,[
#define _LARGEFILE64_SOURCE
#include <sys/resource.h>
])

NOTE: we prefer to uses libc headers instead of kernel headers if possible (e.g. not using <linux/resource.h>) due libc and kernel headers conflicts.
https://sourceware.org/glibc/wiki/Synchronizing_Headers

include/lapi/resource.h line 23

Quoted 11 lines
include/lapi/resource.h new file +11 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);

I suppose using raw syscall is really needed, right?

C library/kernel ABI differences
Since glibc 2.13, the glibc getrlimit() and setrlimit() wrapper
functions no longer invoke the corresponding system calls, but instead employ prlimit(), for the reasons described in BUGS.

       The name of the glibc wrapper function is prlimit(); the underlying

system call is prlimit64().

man getrlimit(2) says:
https://man7.org/linux/man-pages/man2/getrlimit.2.html

C library/kernel ABI differences
Since glibc 2.13, the glibc getrlimit() and setrlimit() wrapper functions no longer invoke the corresponding system calls, but instead employ prlimit(), for the reasons described in BUGS.

The name of the glibc wrapper function is prlimit(); the underlying system call is prlimit64().

...
Since glibc 2.13, glibc works around the limitations of the getrlimit() and setrlimit() system calls by implementing setrlimit() and getrlimit() as wrapper functions that call prlimit().
[chwen] See Wang Li' replied email

include/lapi/resource.h line 26

Quoted 3 lines
include/lapi/resource.h new file +3 -0
+}
+
+#endif /* LAPI_RESOURCE_H__ */

I would probably separate adding the header into it's own commit, but it's ok to
have everything in a single commit.

Review

Quoted 1 line
(quoted diff) +0 -0

b/testcases/kernel/syscalls/setrlimit/setrlimit07.c

Quoted 7 lines

new file mode 100644
index 000000000..60a4580da

testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +2 -0
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 12

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+/*
+ * Set CPU time limit64 for a process and check its behavior
+ * after reaching CPU time limit64.
+ * 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
+ * 2) Process got SIGKILL after reaching hard limit of CPU time limit64.
+ */

Please use docs like this:

/*\
* Set CPU time limit64 for a process and check its behavior
* after reaching CPU time limit64.
*
* 1) Process got SIGXCPU after reaching soft limit of CPU time limit64.
* 2) Process got SIGKILL after reaching hard limit of CPU time limit64. */

/*\ is for docs to be parsed in metadata/ltp.json and included in
https://linux-test-project.readthedocs.io/en/latest/users/test_catalog.html

Extra space between list is needed to 1) and 2) be filtered as a list (not inline).

Ideally you build the docs yourself

https://linux-test-project.readthedocs.io/en/latest/developers/documentation.html#building-documentation

and check the output in: doc/html/users/test_catalog.html#setrlimit07 [chwen] this is not a issue since merging into setrlimit06

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 22

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+
+#define _GNU_SOURCE
+
+#include <sys/wait.h>
+
+#include "tst_test.h"
+
+#include "lapi/syscalls.h"
+
+#include "lapi/resource.h"

very nit: please remove blank lines between inludes [chwen] Done

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 29

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+     uint64_t rlim_cur;
+     uint64_t rlim_max;
+};
+#endif

This is defined in lapi/resource.h which you include, no need to repeat it here.
[chwen] Done

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+
+static struct  rlimit64*rlim;
+
+static int *end;
+
+static void sighandler(int sig)

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 45

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+{
+     *end = sig;
+}
+
+static void setup(void)
+{
+     signal(SIGXCPU, sighandler);
+
+     end = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE,
+                MAP_SHARED | MAP_ANONYMOUS, -1, 0);

Please use SAFE_MMAP(), otherwise there would have to be check:
[chwen] it is not a issue now since it is merged into setrlimit06.c if (end == MAP_FAILED)

        tst_brk(TBROK | TERRNO, "mmap failed on nfildes");

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 51

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+}
+
+static void cleanup(void)
+{
+     if (end)
+             munmap(end, sizeof(int));

We have SAFE_MUNMAP

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 57

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+}
+/*
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+     return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}*/

Hm, commented out code, please remove it.
[chwen] Done

Quoted 7 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+
+static void verify_setrlimit64(void)
+{
+     int status;
+     pid_t pid;
+
+     rlim->rlim_cur = 1;

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 74

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+     rlim->rlim_max = 2;
+
+     *end = 0;
+
+     pid = fork();
+     if (!pid) {
+             TEST(setrlimit_u64(RLIMIT_CPU, rlim));
+             if (TST_RET == -1) {
+                     tst_res(TFAIL | TTERRNO,
+                             "setrlimit_u64(RLIMIT_CPU) failed");

We have TST_EXP_PASS() in tst_test_macros.h, please use it (or other if this is
not appropriate.

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 81

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +7 -0
+                     exit(1);
 
+             }
+
+             alarm(20);
+
+             while (1)
+                     ;

Why this?
[chwen] aims to Suppress make check warnging

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 84

Quoted 3 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +3 -0
+     }
+
+     waitpid(pid, &status, 0);

Maybe SAFE_WAITPID() ?

testcases/kernel/syscalls/setrlimit/setrlimit07.c

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +8 -0
+
+     if (WIFEXITED(status) && WEXITSTATUS(status) == 1)
+             return;
+
+     if (WIFSIGNALED(status)) {
+             if (WTERMSIG(status) == SIGKILL && *end == SIGXCPU) {
+                     tst_res(TPASS,
+                             "Got SIGXCPU then SIGKILL after reaching

both limit");

testcases/kernel/syscalls/setrlimit/setrlimit07.c

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+                     return;
+             }
+
+             if (WTERMSIG(status) == SIGKILL && !*end) {
+                     tst_res(TFAIL,
+                             "Got only SIGKILL after reaching both

limit");

testcases/kernel/syscalls/setrlimit/setrlimit07.c

Quoted 6 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +6 -0
+                     return;
+             }
+
+             if (WTERMSIG(status) == SIGALRM && *end == SIGXCPU) {
+                     tst_res(TFAIL,
+                             "Got only SIGXCPU after reaching both

limit");

Quoted 8 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +8 -0
+                     return;
+             }
+
+             if (WTERMSIG(status) == SIGALRM && !*end) {
+                     tst_res(TFAIL,
+                             "Got no signal after reaching both limit");
+                     return;
+             }

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 122

Quoted 10 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +10 -0
+     }
+
+     tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static struct tst_test test = {
+     .test_all = verify_setrlimit64,
+        .bufs = (struct tst_buffers []) {
+                {&rlim, .size = sizeof(*rlim)},
+                {},

+1 for using guarded buffers.
Please fix the indent.

Last, but not least, code style:

$ make check-setrlimit07
CHECK testcases/kernel/syscalls/setrlimit/setrlimit07.c
setrlimit07.c:31: ERROR: "foo*bar" should be "foo *bar"
setrlimit07.c:54: WARNING: Block comments use * on subsequent lines
setrlimit07.c:57: WARNING: Block comments use a trailing */ on a separate
line
setrlimit07.c:120: ERROR: code indent should use tabs where possible
setrlimit07.c:120: WARNING: please, no spaces at the start of a line
setrlimit07.c:121: ERROR: code indent should use tabs where possible
setrlimit07.c:121: WARNING: please, no spaces at the start of a line
setrlimit07.c:122: ERROR: code indent should use tabs where possible
setrlimit07.c:122: WARNING: please, no spaces at the start of a line

Kind regards,
Petr

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 127

Quoted 5 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +5 -0
+     },
+     .setup = setup,
+     .cleanup = cleanup,
+     .forks_child = 1,
+};

[chwen] all warning and error issue reported by make check-setrlimitxx were addressed

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

PATCH v3 1/1 Add test case to cover the setting resource limit64 for process

In reply to Petr Vorel

From: chunfuwen <[email protected]>

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v3:
- Add test logic into current existed file :setrlimit06.c
- Remove setrlimit07.c file
- Use test_variants to loop different types
- Address review comments related to lapi/resurce.h
- Fix make check issue:while (1) on previous setrlimit06.c file
- Link to v1:https://lore.kernel.org/all/[email protected]/
- Note: it looks like while (1) can not be replaced here after testing by either usleep() or TST_CHECKPOINT_WAKE

---
 include/lapi/resource.h                       | 28 +++++++++++++++
 .../kernel/syscalls/setrlimit/setrlimit06.c   | 34 +++++++++++++++----
 2 files changed, 55 insertions(+), 7 deletions(-)
 create mode 100644 include/lapi/resource.h
include/lapi/resource.h new file +28 -0
new file mode 100644
index 000000000..a9bc57a0a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "config.h"
+#include <sys/resource.h>
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
testcases/kernel/syscalls/setrlimit/setrlimit06.c +27 -7
index 9ff515d81..f40774de7 100644
@@ -27,6 +27,12 @@
 #include <sys/mman.h>
 
 #include "tst_test.h"
+#include "lapi/resource.h"
+
+#define TEST_VARIANTS 2
+
+static struct rlimit *rlim;
+static struct rlimit64 *rlim_64;
 
 static int *end;
 
@@ -37,6 +43,11 @@ static void sighandler(int sig)
 
 static void setup(void)
 {
+	rlim->rlim_cur = 1;
+	rlim->rlim_max = 2;
+	rlim_64->rlim_cur = 1;
+	rlim_64->rlim_max = 2;
+
 	SAFE_SIGNAL(SIGXCPU, sighandler);
 
 	end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
@@ -58,12 +69,14 @@ static void verify_setrlimit(void)
 
 	pid = SAFE_FORK();
 	if (!pid) {
-		struct rlimit rlim = {
-			.rlim_cur = 1,
-			.rlim_max = 2,
-		};
-
-		TEST(setrlimit(RLIMIT_CPU, &rlim));
+		switch (tst_variant) {
+		case 0:
+			TEST(setrlimit(RLIMIT_CPU, rlim));
+		break;
+		case 1:
+			TEST(setrlimit_u64(RLIMIT_CPU, rlim_64));
+		break;
+		}
 		if (TST_RET == -1) {
 			tst_res(TFAIL | TTERRNO,
 				"setrlimit(RLIMIT_CPU) failed");
@@ -72,7 +85,8 @@ static void verify_setrlimit(void)
 
 		alarm(20);
 
-		while (1);
+		while (1)
+			;
 	}
 
 	SAFE_WAITPID(pid, &status, 0);
@@ -112,6 +126,12 @@ static void verify_setrlimit(void)
 static struct tst_test test = {
 	.test_all = verify_setrlimit,
 	.setup = setup,
+	.test_variants = TEST_VARIANTS,
+	.bufs = (struct tst_buffers []) {
+		{&rlim, .size = sizeof(*rlim)},
+		{&rlim_64, .size = sizeof(*rlim_64)},
+		{}
+	},
 	.cleanup = cleanup,
 	.forks_child = 1,
 	.tags = (const struct tst_tag[]) {
Signature · 5 lines
2.43.5


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

Hi!

Thanks for converting 64bit test into setrlimit06. Please take in consideration the reviews given in the v2 to process v4, unfortunately the reviews arrived slightly before this version.

Kind regards,
Andrea Cervesato

Quoted 130 lines · Chunfu Wen

From: chunfuwen <[email protected]>

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
Changes in v3:
- Add test logic into current existed file :setrlimit06.c
- Remove setrlimit07.c file
- Use test_variants to loop different types
- Address review comments related to lapi/resurce.h
- Fix make check issue:while (1) on previous setrlimit06.c file
- Link to v1:https://lore.kernel.org/all/[email protected]/
- Note: it looks like while (1) can not be replaced here after testing by either usleep() or TST_CHECKPOINT_WAKE

---
  include/lapi/resource.h                       | 28 +++++++++++++++
  .../kernel/syscalls/setrlimit/setrlimit06.c   | 34 +++++++++++++++----
  2 files changed, 55 insertions(+), 7 deletions(-)

create mode 100644 include/lapi/resource.h

include/lapi/resource.h new file +28 -0
new file mode 100644
index 000000000..a9bc57a0a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "config.h"
+#include <sys/resource.h>
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
testcases/kernel/syscalls/setrlimit/setrlimit06.c +27 -7
index 9ff515d81..f40774de7 100644
@@ -27,6 +27,12 @@
  #include <sys/mman.h>
 
  #include "tst_test.h"
+#include "lapi/resource.h"
+
+#define TEST_VARIANTS 2
+
+static struct rlimit *rlim;
+static struct rlimit64 *rlim_64;
 
  static int *end;
 
@@ -37,6 +43,11 @@ static void sighandler(int sig)
 
  static void setup(void)
  {
+	rlim->rlim_cur = 1;
+	rlim->rlim_max = 2;
+	rlim_64->rlim_cur = 1;
+	rlim_64->rlim_max = 2;
+
  	SAFE_SIGNAL(SIGXCPU, sighandler);
 
  	end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
@@ -58,12 +69,14 @@ static void verify_setrlimit(void)
 
  	pid = SAFE_FORK();
  	if (!pid) {
-		struct rlimit rlim = {
-			.rlim_cur = 1,
-			.rlim_max = 2,
-		};
-
-		TEST(setrlimit(RLIMIT_CPU, &rlim));
+		switch (tst_variant) {
+		case 0:
+			TEST(setrlimit(RLIMIT_CPU, rlim));
+		break;
+		case 1:
+			TEST(setrlimit_u64(RLIMIT_CPU, rlim_64));
+		break;
+		}
  		if (TST_RET == -1) {
  			tst_res(TFAIL | TTERRNO,
  				"setrlimit(RLIMIT_CPU) failed");
@@ -72,7 +85,8 @@ static void verify_setrlimit(void)
 
  		alarm(20);
 
-		while (1);
+		while (1)
+			;
  	}
 
  	SAFE_WAITPID(pid, &status, 0);
@@ -112,6 +126,12 @@ static void verify_setrlimit(void)
  static struct tst_test test = {
  	.test_all = verify_setrlimit,
  	.setup = setup,
+	.test_variants = TEST_VARIANTS,
+	.bufs = (struct tst_buffers []) {
+		{&rlim, .size = sizeof(*rlim)},
+		{&rlim_64, .size = sizeof(*rlim_64)},
+		{}
+	},
  	.cleanup = cleanup,
  	.forks_child = 1,
  	.tags = (const struct tst_tag[]) {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#12 lore raw

Hello Andrea,

Thank you for reviewing.
I pasted your previous review comments here, and give some inline feedback. If I missed something, please let me know.

Chunfu Wen

- [Andrea]we are already defining the "struct rlimit64" inside getrlimit03, so
we need to create a new file lapi/resource.h where we move that struct, checking if HAVE_STRUCT_RLIMIT64 is not defined. I guess the same should be done for getrlimit_u64()/setrlimit_u64() syscalls definitions. Better to move them in there in case we will need it in the future . We can skip SAFE_* variants at the moment, since we are not using them around LTP test for now.
[chwen]

- One file:resource.h was created newly, and struct rlimit64 and its related to setxx are moved into this file.
- In terms of skip SAFE_* variants, I noticed Petr Vorel had a different opinion in a previous comment that suggested using SAFE_*, so I will keep them there.

- [Andrea]in both setrlimit06 and setrlimit07 we should probably use tst_buffers
for safety reasons when passing the pointer to the rlimit/rlimit64 struct we are gonna use
[chwen]tst_buffers is already adopted in the patch

- [Andrea]it's worth to check if the other tests might introduce the same 64bit
variants
[chwen] I ever grep source code under ltp, not finding that introduce the same 64bit
variants

[Andrea]FYI i noticed that setrlimit06 description can't be fetched in the metadata because it's not initialized with /*\ . It also needs to be changed into the RST format instead of asciidoc.
[chwen] This is done in patch v4

Quoted 146 lines · Andrea Cervesato

Hi!

Thanks for converting 64bit test into setrlimit06. Please take in consideration the reviews given in the v2 to process v4, unfortunately the reviews arrived slightly before this version.

Kind regards,
Andrea Cervesato

Quoted 3 lines · Chunfu Wen

From: chunfuwen <[email protected]>

The test ensures that the process gets the correct signals in the

correct order:

Quoted 5 lines

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

Quoted 8 lines

---
Changes in v3:
- Add test logic into current existed file :setrlimit06.c
- Remove setrlimit07.c file
- Use test_variants to loop different types
- Address review comments related to lapi/resurce.h
- Fix make check issue:while (1) on previous setrlimit06.c file
- Link to v1:

https://lore.kernel.org/all/[email protected]/

Quoted 1 line

- Note: it looks like while (1) can not be replaced here after testing

by either usleep() or TST_CHECKPOINT_WAKE

Review

Quoted 41 lines
---
  include/lapi/resource.h                       | 28 +++++++++++++++
  .../kernel/syscalls/setrlimit/setrlimit06.c   | 34 +++++++++++++++----
  2 files changed, 55 insertions(+), 7 deletions(-)

create mode 100644 include/lapi/resource.h

include/lapi/resource.h new file +28 -0
new file mode 100644
index 000000000..a9bc57a0a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "config.h"
+#include <sys/resource.h>
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
(quoted diff) +0 -0

b/testcases/kernel/syscalls/setrlimit/setrlimit06.c

Quoted 72 lines

index 9ff515d81..f40774de7 100644

testcases/kernel/syscalls/setrlimit/setrlimit06.c +27 -7
@@ -27,6 +27,12 @@
  #include <sys/mman.h>
 
  #include "tst_test.h"
+#include "lapi/resource.h"
+
+#define TEST_VARIANTS 2
+
+static struct rlimit *rlim;
+static struct rlimit64 *rlim_64;
 
  static int *end;
 
@@ -37,6 +43,11 @@ static void sighandler(int sig)
 
  static void setup(void)
  {
+     rlim->rlim_cur = 1;
+     rlim->rlim_max = 2;
+     rlim_64->rlim_cur = 1;
+     rlim_64->rlim_max = 2;
+
      SAFE_SIGNAL(SIGXCPU, sighandler);
 
      end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
@@ -58,12 +69,14 @@ static void verify_setrlimit(void)
 
      pid = SAFE_FORK();
      if (!pid) {
-             struct rlimit rlim = {
-                     .rlim_cur = 1,
-                     .rlim_max = 2,
-             };
-
-             TEST(setrlimit(RLIMIT_CPU, &rlim));
+             switch (tst_variant) {
+             case 0:
+                     TEST(setrlimit(RLIMIT_CPU, rlim));
+             break;
+             case 1:
+                     TEST(setrlimit_u64(RLIMIT_CPU, rlim_64));
+             break;
+             }
              if (TST_RET == -1) {
                      tst_res(TFAIL | TTERRNO,
                              "setrlimit(RLIMIT_CPU) failed");
@@ -72,7 +85,8 @@ static void verify_setrlimit(void)
 
              alarm(20);
 
-             while (1);
+             while (1)
+                     ;
      }
 
      SAFE_WAITPID(pid, &status, 0);
@@ -112,6 +126,12 @@ static void verify_setrlimit(void)
  static struct tst_test test = {
      .test_all = verify_setrlimit,
      .setup = setup,
+     .test_variants = TEST_VARIANTS,
+     .bufs = (struct tst_buffers []) {
+             {&rlim, .size = sizeof(*rlim)},
+             {&rlim_64, .size = sizeof(*rlim_64)},
+             {}
+     },
      .cleanup = cleanup,
      .forks_child = 1,
      .tags = (const struct tst_tag[]) {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#13 lore raw

PATCH v4 1/1 Add test case to cover the setting resource limit64 for process

In reply to Andrea Cervesato via ltp

From: chunfuwen <[email protected]>

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
 include/lapi/resource.h                       | 28 ++++++++++++
 .../kernel/syscalls/setrlimit/setrlimit06.c   | 44 ++++++++++++++-----
 2 files changed, 60 insertions(+), 12 deletions(-)
 create mode 100644 include/lapi/resource.h
include/lapi/resource.h new file +28 -0
new file mode 100644
index 000000000..a9bc57a0a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "config.h"
+#include <sys/resource.h>
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
testcases/kernel/syscalls/setrlimit/setrlimit06.c +32 -12

81 lines not on this page · raw message

Signature · 5 lines
2.43.5


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

Hello Maintainers,

Could you please help me review the V4 patch when you have time?

Best Regards,

Chunfu Wen

Quoted 145 lines · Chunfu Wen

From: chunfuwen <[email protected]>

The test ensures that the process gets the correct signals in the correct order:

First, it should get SIGXCPU after reaching the soft CPU time limit64. Then, if the CPU time exceeds the hard limit, it should receive SIGKILL

---
 include/lapi/resource.h                       | 28 ++++++++++++
 .../kernel/syscalls/setrlimit/setrlimit06.c   | 44 ++++++++++++++-----
 2 files changed, 60 insertions(+), 12 deletions(-)
 create mode 100644 include/lapi/resource.h
include/lapi/resource.h new file +28 -0
new file mode 100644
index 000000000..a9bc57a0a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025 Red Hat Inc. All Rights Reserved.
+ * Author: Chunfu Wen <[email protected]>
+ */
+
+#ifndef LAPI_RESOURCE_H__
+#define LAPI_RESOURCE_H__
+
+#define _GNU_SOURCE
+
+#include "config.h"
+#include <sys/resource.h>
+#include "lapi/syscalls.h"
+
+#ifndef HAVE_STRUCT_RLIMIT64
+struct rlimit64 {
+        uint64_t rlim_cur;
+        uint64_t rlim_max;
+};
+#endif
+
+static int setrlimit_u64(int resource, const struct rlimit64 *rlim)
+{
+        return tst_syscall(__NR_prlimit64, 0, resource, rlim, NULL);
+}
+
+#endif /* LAPI_RESOURCE_H__ */
testcases/kernel/syscalls/setrlimit/setrlimit06.c +32 -13
index 9ff515d81..ded550973 100644
@@ -4,12 +4,12 @@
  * Author: Xiao Yang <[email protected]>
  */
 
-/*
- * Description:
+/*\
  * Set CPU time limit for a process and check its behavior
- * after reaching CPU time limit.
- * 1) Process got SIGXCPU after reaching soft limit of CPU time.
- * 2) Process got SIGKILL after reaching hard limit of CPU time.
+ * after reaching CPU time limit
+ *
+ * - Process got SIGXCPU after reaching soft limit of CPU time
+ * - Process got SIGKILL after reaching hard limit of CPU time
  *
  * Note:
  * This is also a regression test for the following kernel bug:
@@ -27,6 +27,12 @@
 #include <sys/mman.h>
 
 #include "tst_test.h"
+#include "lapi/resource.h"
+
+#define TEST_VARIANTS 2
+
+static struct rlimit *rlim;
+static struct rlimit64 *rlim_64;
 
 static int *end;
 
@@ -37,6 +43,11 @@ static void sighandler(int sig)
 
 static void setup(void)
 {
+       rlim->rlim_cur = 1;
+       rlim->rlim_max = 2;
+       rlim_64->rlim_cur = 1;
+       rlim_64->rlim_max = 2;
+
        SAFE_SIGNAL(SIGXCPU, sighandler);
 
        end = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE,
@@ -58,12 +69,14 @@ static void verify_setrlimit(void)
 
        pid = SAFE_FORK();
        if (!pid) {
-               struct rlimit rlim = {
-                       .rlim_cur = 1,
-                       .rlim_max = 2,
-               };
-
-               TEST(setrlimit(RLIMIT_CPU, &rlim));
+               switch (tst_variant) {
+               case 0:
+                       TEST(setrlimit(RLIMIT_CPU, rlim));
+               break;
+               case 1:
+                       TEST(setrlimit_u64(RLIMIT_CPU, rlim_64));
+               break;
+               }
                if (TST_RET == -1) {
                        tst_res(TFAIL | TTERRNO,
                                "setrlimit(RLIMIT_CPU) failed");
@@ -72,7 +85,8 @@ static void verify_setrlimit(void)
 
                alarm(20);
 
-               while (1);
+               while (1)
+                       ;
        }
 
        SAFE_WAITPID(pid, &status, 0);
@@ -112,6 +126,12 @@ static void verify_setrlimit(void)
 static struct tst_test test = {
        .test_all = verify_setrlimit,
        .setup = setup,
+       .test_variants = TEST_VARIANTS,
+       .bufs = (struct tst_buffers []) {
+               {&rlim, .size = sizeof(*rlim)},
+               {&rlim_64, .size = sizeof(*rlim_64)},
+               {}
+       },
        .cleanup = cleanup,
        .forks_child = 1,
        .tags = (const struct tst_tag[]) {
--

2.43.5

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw
Quoted 4 lines · Chunfu Wen

Hello Maintainers,

Could you please help me review the V4 patch when you have time?

I helped resolve the code conflict and pushed, thanks!

Li Wang

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

Hi Li,

thanks for checking, but we still missed a couple of things to fix, like infinite loop that might cause some issues and it should be replaced with checkpoints as pointed out by Petr.

Best regards,
Andrea Cervesato

Quoted 10 lines · Li Wang
Quoted 4 lines · Chunfu Wen

Hello Maintainers,

Could you please help me review the V4 patch when you have time?

I helped resolve the code conflict and pushed, thanks!

Li Wang

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

Hi Andrea, Petr,

Quoted 6 lines · Andrea Cervesato

Hi Li,

thanks for checking, but we still missed a couple of things to fix, like infinite loop that might cause some issues and it should be replaced with checkpoints as pointed out by Petr.

Here I wouldn't suggest using the checkpoint.

RLIMIT_CPU is a resource limit that controls the CPU time but not wall-clock time, if a process exceeds the soft limit it receives SIGXCPU. So the while(1) is a good choice unless I missed something.

P.s. the patch caused a compiling error on Alpine I haven't figured out reason:).
https://github.com/linux-test-project/ltp/actions/runs/13580985467/job/37966850497

Li Wang

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

P.s. the patch caused a compiling error on Alpine I haven't figured out reason:).

https://github.com/linux-test-project/ltp/actions/runs/13580985467/job/37966850497

Well, we have to enable _LARGEFILE64_SOURCE macro to tells glibc to expose 64-bit structures, see:

$ cat /usr/include/bits/resource.h
...
#ifdef __USE_LARGEFILE64
struct rlimit64
  {
    /* The current (soft) limit.  */
    rlim64_t rlim_cur;
    /* The hard limit.  */
    rlim64_t rlim_max;
 };
#endif
...

Sent a patch to resolve it:
https://lists.linux.it/pipermail/ltp/2025-February/042497.html

Li Wang

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#19 lore raw
Quoted 25 lines
Quoted 4 lines · Li Wang

P.s. the patch caused a compiling error on Alpine I haven't figured out reason:).

https://github.com/linux-test-project/ltp/actions/runs/13580985467/job/37966850497

Well, we have to enable _LARGEFILE64_SOURCE macro to tells glibc to expose 64-bit structures, see:

$ cat /usr/include/bits/resource.h
...
#ifdef __USE_LARGEFILE64
struct rlimit64
  {
    /* The current (soft) limit.  */
    rlim64_t rlim_cur;
    /* The hard limit.  */
    rlim64_t rlim_max;
 };
#endif
...
Quoted 2 lines

Sent a patch to resolve it:
https://lists.linux.it/pipermail/ltp/2025-February/042497.html

FYI patch already merged.

Kind regards,
Petr

Quoted 1 line

Li Wang

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v4 1/1
#20 lore raw
In reply to Chunfu Wen

Patch v4 looks good, and next we can move getrlimit_u64() definition (from getrlimit03.c)
to the lapi/resource.h, obviously this could be accomplished in a separate work.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw
In reply to chunfuwen

Hi

testcases/kernel/syscalls/setrlimit/setrlimit07.c line 80

Quoted 11 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +11 -0
+	if (!pid) {
+		TEST(setrlimit_u64(RLIMIT_CPU, rlim));
+		if (TST_RET == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"setrlimit_u64(RLIMIT_CPU) failed");
+			exit(1);
+		}
+
+		alarm(20);
+
+		while (1)

FYI we have TST_CHECKPOINT_WAKE() and others, please see
"1.9 Fork() and Parent-child synchronization" in doc/old/C-Test-API.asciidoc or online
https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#19-fork-and-parent-child-synchronization

(still not yet converted docs to sphinx)

Also worth to read if you have time (because people would put at least some usleep() instead of plain while(1);
https://people.kernel.org/metan/why-sleep-is-almost-never-acceptable-in-tests

Kind regards,
Petr

Quoted 3 lines
testcases/kernel/syscalls/setrlimit/setrlimit07.c new file +3 -0
+			;
+	}
+
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp