Skip to contentSkip to conversation

syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

PATCH New Xiao Yang 2 participants 5 messages Jul 15, 2019 – Jul 16, 2019

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "/proc/sys/kernel/acct" or using sysctl.

---
 testcases/kernel/syscalls/acct/acct02.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/acct/acct02.c +6 -3
index c2c2066..9e2f934 100644
@@ -150,18 +150,21 @@ static void run(void)
 static void setup(void)
 {
 	struct statfs buf;
+	float limit;
 
 	clock_ticks = SAFE_SYSCONF(_SC_CLK_TCK);
 
 	SAFE_STATFS(".", &buf);
 
 	float avail = (100.00 * buf.f_bavail) / buf.f_blocks;
+	SAFE_FILE_SCANF("/proc/sys/kernel/acct", "%f %*i %*i", &limit);
+	limit += 0.1;
 
 	/* The accounting data are silently discarded on nearly FS */
-	if (avail < 4.1) {
+	if (avail < limit) {
 		tst_brk(TCONF,
-			"Less than 4.1%% (%.2f) of free space on filesystem",
-			avail);
+			"Less than (%.2f)%% (%.2f) of free space on filesystem",
+			limit, avail);
 	}
 
 	TEST(acct(NULL));
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

Hi!

Quoted 3 lines

Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "/proc/sys/kernel/acct" or using sysctl.

Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in kernel/sysctl.c.

What about we as well temporarily lower the value if needed while the test is running?

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 3 lines

Don't use hardcoded threshold(default 4%) to check free space because it can be changed by writing "/proc/sys/kernel/acct" or using sysctl.

Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in kernel/sysctl.c.

What about we as well temporarily lower the value if needed while the test is running?

Hi Cyril,

When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.

Which one do you prefer?

Best Regards,
Xiao Yang

Quoted 1 line
#3 lore raw

PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

Hi!

Quoted 11 lines
Quoted 5 lines

Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in kernel/sysctl.c.

What about we as well temporarily lower the value if needed while the test is running?

Hi Cyril,

When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.

Which one do you prefer?

Ideally the test should modify the threshold.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

PATCH 1/1 syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct

Quoted 6 lines · Cyril Hrubis

Hi!

Quoted 5 lines
Quoted 5 lines

Good catch, I missed the sysctl API since I haven't realized that the proc handlers are all stuffed in a different file in kernel/sysctl.c.

What about we as well temporarily lower the value if needed while the test is running?

Quoted 7 lines
Quoted 6 lines

Hi Cyril,

When free space is not enough, test can change the threshold by itself or remind user to modify the threshold by sysctl API manually.

Which one do you prefer?

Ideally the test should modify the threshold.

Hi Cyril,

OK, I will improve the patch as you suggested. :-)

Best Regards,
Xiao Yang

Quoted 1 line