* [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop
@ 2021-07-14 18:08 Amir Goldstein
2021-07-15 7:08 ` Petr Vorel
0 siblings, 1 reply; 5+ messages in thread
From: Amir Goldstein @ 2021-07-14 18:08 UTC (permalink / raw)
To: ltp
Both fanotify19 and fanotify18 leaked fds when run in a loop.
fanotify19 was not checking child process exit status correctly
which resulted in random failures.
Reported-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
testcases/kernel/syscalls/fanotify/fanotify18.c | 5 ++++-
testcases/kernel/syscalls/fanotify/fanotify19.c | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify18.c b/testcases/kernel/syscalls/fanotify/fanotify18.c
index 8a7eebba3..54a4b8ba0 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify18.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify18.c
@@ -136,7 +136,7 @@ static void test_fanotify(unsigned int n)
(tc->mark_flags & DISALLOWED_MARK_FLAGS ||
tc->mark_mask & FAN_ALL_PERM_EVENTS)) {
tst_res(TPASS, "Received result EPERM, as expected");
- return;
+ goto out;
}
tst_brk(TBROK | TERRNO,
@@ -151,6 +151,9 @@ static void test_fanotify(unsigned int n)
tst_res(TPASS,
"fanotify_init() and fanotify_mark() returned successfully, "
"as expected");
+
+out:
+ SAFE_CLOSE(fd_notify);
}
static void setup(void)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify19.c b/testcases/kernel/syscalls/fanotify/fanotify19.c
index 60714408d..fac257bb4 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify19.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify19.c
@@ -132,7 +132,7 @@ static void do_fork(void)
SAFE_WAITPID(child, &status, 0);
- if (WIFEXITED(child) && WEXITSTATUS(child) != 0)
+ if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
tst_brk(TBROK, "Child process terminated incorrectly. Aborting");
}
@@ -255,6 +255,8 @@ static void test_fanotify(unsigned int n)
event = FAN_EVENT_NEXT(event, len);
}
}
+
+ SAFE_CLOSE(fd_notify);
}
static void setup(void)
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop
2021-07-14 18:08 [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop Amir Goldstein
@ 2021-07-15 7:08 ` Petr Vorel
2021-07-15 9:05 ` Amir Goldstein
0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2021-07-15 7:08 UTC (permalink / raw)
To: ltp
Hi Amir,
> Both fanotify19 and fanotify18 leaked fds when run in a loop.
> fanotify19 was not checking child process exit status correctly
> which resulted in random failures.
Thanks for a quick fix!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
FYI both fixes prolonged running for about 100% (comparing with runs on master
which don't fail). Of course, that's not a problem at all, it's just interesting
for me how simple closing of file descriptor can be expensive.
Kind regards,
Petr
# time ./fanotify19 -i40
Summary:
passed 360
failed 0
broken 0
skipped 0
warnings 0
real 0m0,871s
user 0m0,028s
sys 0m0,116s
vs.
Summary:
passed 360
failed 0
broken 0
skipped 0
warnings 0
real 0m0,387s
user 0m0,016s
sys 0m0,122s
# time ./fanotify19 -i10
Summary:
passed 160
failed 0
broken 0
skipped 0
warnings 0
real 0m0,436s
user 0m0,032s
sys 0m0,128s
vs.
Summary:
passed 160
failed 0
broken 0
skipped 0
warnings 0
real 0m0,876s
user 0m0,052s
sys 0m0,105s
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop
2021-07-15 7:08 ` Petr Vorel
@ 2021-07-15 9:05 ` Amir Goldstein
2021-07-15 9:29 ` Petr Vorel
2021-07-15 11:42 ` Petr Vorel
0 siblings, 2 replies; 5+ messages in thread
From: Amir Goldstein @ 2021-07-15 9:05 UTC (permalink / raw)
To: ltp
On Thu, Jul 15, 2021 at 10:08 AM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> > Both fanotify19 and fanotify18 leaked fds when run in a loop.
> > fanotify19 was not checking child process exit status correctly
> > which resulted in random failures.
>
> Thanks for a quick fix!
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> FYI both fixes prolonged running for about 100% (comparing with runs on master
> which don't fail). Of course, that's not a problem at all, it's just interesting
> for me how simple closing of file descriptor can be expensive.
>
Nice observation! LTP is not the only test suite that observed this issue. See:
https://lore.kernel.org/linux-fsdevel/CAC-ggsFLmFpz5Y=-9MMLwxuO2LOS9rhpewDp_-u2hrT9J79ryg@mail.gmail.com/
In order to fix that issue we will need some LTP helpers to take care of closing
fanotify/inotify fds in batches for loop runs, which is kind of what
happened before
the fd leak fix only the batch was infinite...
Attached sample patch for fanotify18.
You will need to run some more experiments to see if it is worth it or not
and then if it is worth it, probably generalize the helpers.
Thanks,
Amir.
> Kind regards,
> Petr
>
> # time ./fanotify19 -i40
>
> Summary:
> passed 360
> failed 0
> broken 0
> skipped 0
> warnings 0
>
> real 0m0,871s
> user 0m0,028s
> sys 0m0,116s
>
> vs.
>
> Summary:
> passed 360
> failed 0
> broken 0
> skipped 0
> warnings 0
>
> real 0m0,387s
> user 0m0,016s
> sys 0m0,122s
>
> # time ./fanotify19 -i10
> Summary:
> passed 160
> failed 0
> broken 0
> skipped 0
> warnings 0
>
> real 0m0,436s
> user 0m0,032s
> sys 0m0,128s
>
> vs.
>
> Summary:
> passed 160
> failed 0
> broken 0
> skipped 0
> warnings 0
>
> real 0m0,876s
> user 0m0,052s
> sys 0m0,105s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-syscalls-fanotify-Closing-group-fd-in-batches.patch
Type: text/x-patch
Size: 3862 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210715/3b5dbd3e/attachment.bin>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop
2021-07-15 9:05 ` Amir Goldstein
@ 2021-07-15 9:29 ` Petr Vorel
2021-07-15 11:42 ` Petr Vorel
1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-15 9:29 UTC (permalink / raw)
To: ltp
Hi Amir,
...
> > FYI both fixes prolonged running for about 100% (comparing with runs on master
> > which don't fail). Of course, that's not a problem at all, it's just interesting
> > for me how simple closing of file descriptor can be expensive.
> Nice observation! LTP is not the only test suite that observed this issue. See:
> https://lore.kernel.org/linux-fsdevel/CAC-ggsFLmFpz5Y=-9MMLwxuO2LOS9rhpewDp_-u2hrT9J79ryg@mail.gmail.com/
> In order to fix that issue we will need some LTP helpers to take care of closing
> fanotify/inotify fds in batches for loop runs, which is kind of what
> happened before
> the fd leak fix only the batch was infinite...
> Attached sample patch for fanotify18.
> You will need to run some more experiments to see if it is worth it or not
> and then if it is worth it, probably generalize the helpers.
Thanks for detailed info and patch. I'm going to merge the original patch as
it's not an issue to run tests slower (more important is to actually fix the
issue) and have look into your patchset whether it's worth of adding it.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop
2021-07-15 9:05 ` Amir Goldstein
2021-07-15 9:29 ` Petr Vorel
@ 2021-07-15 11:42 ` Petr Vorel
1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2021-07-15 11:42 UTC (permalink / raw)
To: ltp
Hi Amir,
merged, thanks!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-15 11:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 18:08 [LTP] [PATCH] syscalls/fanotify: Fix running tests in a loop Amir Goldstein
2021-07-15 7:08 ` Petr Vorel
2021-07-15 9:05 ` Amir Goldstein
2021-07-15 9:29 ` Petr Vorel
2021-07-15 11:42 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.