* [LTP] [PATCH v2] syscalls/setrlimit03.c: read /proc/sys/fs/nr_open for RLIMIT_NOFILE limit
@ 2019-01-31 17:49 Tommi Rantala
2019-02-06 12:02 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Tommi Rantala @ 2019-01-31 17:49 UTC (permalink / raw)
To: ltp
From: Tommi Rantala <tommi.t.rantala@nokia.com>
Since kernel v2.6.25 RLIMIT_NOFILE limit is no longer hardcoded to
NR_OPEN, but can be set via /proc/sys/fs/nr_open, see kernel commit
9cfe015aa424b3c003baba3841a60dd9b5ad319b ("get rid of NR_OPEN and
introduce a sysctl_nr_open").
nr_open default value is 1024*1024, so setrlimit03 has been passing fine
on new kernels, only "unexpectedly succeeding" if nr_open is set to some
larger value.
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
---
testcases/kernel/syscalls/setrlimit/setrlimit03.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit03.c b/testcases/kernel/syscalls/setrlimit/setrlimit03.c
index 29b52aa7f..12455fe05 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit03.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit03.c
@@ -35,7 +35,10 @@
# define NR_OPEN (1024*1024)
#endif
+#define NR_OPEN_PATH "/proc/sys/fs/nr_open"
+
static struct rlimit rlim1, rlim2;
+static unsigned int nr_open = NR_OPEN;
static struct tcase {
struct rlimit *rlimt;
@@ -51,7 +54,10 @@ static void verify_setrlimit(unsigned int n)
TEST(setrlimit(RLIMIT_NOFILE, tc->rlimt));
if (TST_RET != -1) {
- tst_res(TFAIL, "call succeeded unexpectedly");
+ tst_res(TFAIL, "call succeeded unexpectedly "
+ "(nr_open=%u rlim_cur=%lu rlim_max=%lu)", nr_open,
+ (unsigned long)(tc->rlimt->rlim_cur),
+ (unsigned long)(tc->rlimt->rlim_max));
return;
}
@@ -65,10 +71,13 @@ static void verify_setrlimit(unsigned int n)
static void setup(void)
{
+ if (!access(NR_OPEN_PATH, F_OK))
+ SAFE_FILE_SCANF(NR_OPEN_PATH, "%u", &nr_open);
+
SAFE_GETRLIMIT(RLIMIT_NOFILE, &rlim1);
rlim2.rlim_max = rlim1.rlim_cur;
rlim2.rlim_cur = rlim1.rlim_max + 1;
- rlim1.rlim_max = NR_OPEN + 1;
+ rlim1.rlim_max = nr_open + 1;
}
static struct tst_test test = {
--
2.19.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [LTP] [PATCH v2] syscalls/setrlimit03.c: read /proc/sys/fs/nr_open for RLIMIT_NOFILE limit
2019-01-31 17:49 [LTP] [PATCH v2] syscalls/setrlimit03.c: read /proc/sys/fs/nr_open for RLIMIT_NOFILE limit Tommi Rantala
@ 2019-02-06 12:02 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2019-02-06 12:02 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-06 12:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 17:49 [LTP] [PATCH v2] syscalls/setrlimit03.c: read /proc/sys/fs/nr_open for RLIMIT_NOFILE limit Tommi Rantala
2019-02-06 12:02 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox