* [LTP] [PATCH v2] syscalls/fanotify07: add stop_children() to cleanup()
@ 2021-11-05 9:02 Zhao Gongyi
2021-11-16 10:56 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-11-05 9:02 UTC (permalink / raw)
To: ltp
When we run the testcase simultaneously, and the ulimit of open
files is small, the testcase will fail and remain many while(1)
tasks in system, it makes the system very stuck.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: add stop_children() to cleanup(),suggested by Amir and Matthew.
testcases/kernel/syscalls/fanotify/fanotify07.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c b/testcases/kernel/syscalls/fanotify/fanotify07.c
index cc56d9019..40d1b96ce 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify07.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify07.c
@@ -86,15 +86,21 @@ static int stop_children(void)
int child_ret;
int i, ret = 0;
- for (i = 0; i < MAX_CHILDREN; i++)
+ for (i = 0; i < MAX_CHILDREN; i++) {
+ if (!child_pid[i])
+ continue;
SAFE_KILL(child_pid[i], SIGKILL);
+ }
for (i = 0; i < MAX_CHILDREN; i++) {
+ if (!child_pid[i])
+ continue;
SAFE_WAITPID(child_pid[i], &child_ret, 0);
if (!WIFSIGNALED(child_ret))
ret = 1;
}
+ memset(child_pid, 0, sizeof(pid_t) * MAX_CHILDREN);
return ret;
}
@@ -190,6 +196,8 @@ static void setup(void)
static void cleanup(void)
{
+ stop_children();
+
if (fd_notify > 0)
SAFE_CLOSE(fd_notify);
}
@@ -201,6 +209,7 @@ static struct tst_test test = {
.needs_tmpdir = 1,
.forks_child = 1,
.needs_root = 1,
};
#else
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH v2] syscalls/fanotify07: add stop_children() to cleanup()
2021-11-05 9:02 [LTP] [PATCH v2] syscalls/fanotify07: add stop_children() to cleanup() Zhao Gongyi
@ 2021-11-16 10:56 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-11-16 10:56 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: Matthew Bobrowski, ltp
Hi all,
> When we run the testcase simultaneously, and the ulimit of open
> files is small, the testcase will fail and remain many while(1)
> tasks in system, it makes the system very stuck.
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> v1->v2: add stop_children() to cleanup(),suggested by Amir and Matthew.
> testcases/kernel/syscalls/fanotify/fanotify07.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c b/testcases/kernel/syscalls/fanotify/fanotify07.c
> index cc56d9019..40d1b96ce 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify07.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify07.c
> @@ -86,15 +86,21 @@ static int stop_children(void)
> int child_ret;
> int i, ret = 0;
> - for (i = 0; i < MAX_CHILDREN; i++)
> + for (i = 0; i < MAX_CHILDREN; i++) {
> + if (!child_pid[i])
> + continue;
> SAFE_KILL(child_pid[i], SIGKILL);
> + }
> for (i = 0; i < MAX_CHILDREN; i++) {
> + if (!child_pid[i])
> + continue;
> SAFE_WAITPID(child_pid[i], &child_ret, 0);
> if (!WIFSIGNALED(child_ret))
> ret = 1;
I slightly prefer instead of using memset code which Amir suggested:
child_pid[i] = 0;
> }
Otherwise LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
NOTE: patch was corrupted, please take care next time
(error: corrupt patch at line 131)
Also
Kind regards,
Petr
> + memset(child_pid, 0, sizeof(pid_t) * MAX_CHILDREN);
> return ret;
> }
> @@ -190,6 +196,8 @@ static void setup(void)
> static void cleanup(void)
> {
> + stop_children();
> +
> if (fd_notify > 0)
> SAFE_CLOSE(fd_notify);
> }
> @@ -201,6 +209,7 @@ static struct tst_test test = {
> .needs_tmpdir = 1,
> .forks_child = 1,
> .needs_root = 1,
> };
> #else
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] syscalls/fanotify07: add stop_children() to cleanup()
@ 2021-11-22 8:23 zhaogongyi via ltp
0 siblings, 0 replies; 3+ messages in thread
From: zhaogongyi via ltp @ 2021-11-22 8:23 UTC (permalink / raw)
To: Petr Vorel; +Cc: Matthew Bobrowski, ltp@lists.linux.it
Hi,
I have resubmit a new version patch as your review, please see https://patchwork.ozlabs.org/project/ltp/patch/20211122082146.59895-1-zhaogongyi@huawei.com/
Thanks so much!
Gongyi
>
> Hi all,
>
> > When we run the testcase simultaneously, and the ulimit of open files
> > is small, the testcase will fail and remain many while(1) tasks in
> > system, it makes the system very stuck.
>
> > Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> > ---
> > v1->v2: add stop_children() to cleanup(),suggested by Amir and
> Matthew.
>
> > testcases/kernel/syscalls/fanotify/fanotify07.c | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
>
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c
> > b/testcases/kernel/syscalls/fanotify/fanotify07.c
> > index cc56d9019..40d1b96ce 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify07.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify07.c
> > @@ -86,15 +86,21 @@ static int stop_children(void)
> > int child_ret;
> > int i, ret = 0;
>
> > - for (i = 0; i < MAX_CHILDREN; i++)
> > + for (i = 0; i < MAX_CHILDREN; i++) {
> > + if (!child_pid[i])
> > + continue;
> > SAFE_KILL(child_pid[i], SIGKILL);
> > + }
>
> > for (i = 0; i < MAX_CHILDREN; i++) {
> > + if (!child_pid[i])
> > + continue;
> > SAFE_WAITPID(child_pid[i], &child_ret, 0);
> > if (!WIFSIGNALED(child_ret))
> > ret = 1;
> I slightly prefer instead of using memset code which Amir suggested:
> child_pid[i] = 0;
> > }
>
> Otherwise LGTM.
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> NOTE: patch was corrupted, please take care next time
> (error: corrupt patch at line 131)
> Also
>
> Kind regards,
> Petr
>
> > + memset(child_pid, 0, sizeof(pid_t) * MAX_CHILDREN);
> > return ret;
> > }
>
> > @@ -190,6 +196,8 @@ static void setup(void)
>
> > static void cleanup(void)
> > {
> > + stop_children();
> > +
> > if (fd_notify > 0)
> > SAFE_CLOSE(fd_notify);
> > }
> > @@ -201,6 +209,7 @@ static struct tst_test test = {
> > .needs_tmpdir = 1,
> > .forks_child = 1,
> > .needs_root = 1,
> > };
>
> > #else
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-22 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-05 9:02 [LTP] [PATCH v2] syscalls/fanotify07: add stop_children() to cleanup() Zhao Gongyi
2021-11-16 10:56 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2021-11-22 8:23 zhaogongyi via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox