public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
@ 2019-07-15 15:16 Xiao Yang
  2019-07-15 16:00 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2019-07-15 15:16 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Xiao Yang <ice_yangxiao@163.com>
---
 testcases/kernel/syscalls/acct/acct02.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index c2c2066..9e2f934 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -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));
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
  2019-07-15 15:16 [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct Xiao Yang
@ 2019-07-15 16:00 ` Cyril Hrubis
  2019-07-16 14:04   ` Xiao Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2019-07-15 16:00 UTC (permalink / raw)
  To: ltp

Hi!
> 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?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
  2019-07-15 16:00 ` Cyril Hrubis
@ 2019-07-16 14:04   ` Xiao Yang
  2019-07-16 14:17     ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2019-07-16 14:04 UTC (permalink / raw)
  To: ltp

On 07/16/2019 12:00 AM, Cyril Hrubis wrote:
> Hi!
>> 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
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
  2019-07-16 14:04   ` Xiao Yang
@ 2019-07-16 14:17     ` Cyril Hrubis
  2019-07-16 15:37       ` Xiao Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2019-07-16 14:17 UTC (permalink / raw)
  To: ltp

Hi!
> > 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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct
  2019-07-16 14:17     ` Cyril Hrubis
@ 2019-07-16 15:37       ` Xiao Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2019-07-16 15:37 UTC (permalink / raw)
  To: ltp

On 07/16/2019 10:17 PM, Cyril Hrubis wrote:
> Hi!
>>> 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.
Hi Cyril,

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

Best Regards,
Xiao Yang
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-16 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-15 15:16 [LTP] [PATCH] syscalls/acct02.c: Read threshold from /proc/sys/kernel/acct Xiao Yang
2019-07-15 16:00 ` Cyril Hrubis
2019-07-16 14:04   ` Xiao Yang
2019-07-16 14:17     ` Cyril Hrubis
2019-07-16 15:37       ` Xiao Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox