All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kselftests/sched: cleanup the child processes
@ 2021-09-02  2:43 Li Zhijian
  2021-09-02 11:25 ` Chris Hyser
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Li Zhijian @ 2021-09-02  2:43 UTC (permalink / raw)
  To: chris.hyser, peterz, shuah, linux-kselftest
  Cc: linux-kernel, Li Zhijian, Philip Li, kernel test robot

Previously, 'make -C sched run_tests' will block forever when it occurs
something wrong where the *selftests framework* is waiting for its child
processes to exit.

[root@iaas-rpma sched]# ./cs_prctl_test

 ## Create a thread/process/process group hiearchy
Not a core sched system
tid=74985, / tgid=74985 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74986, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74988, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74989, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74990, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74987, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74991, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74992, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74993, / tgid=74987 / pgid=74985: ffffffffffffffff

Not a core sched system
(268) FAILED: get_cs_cookie(0) == 0

 ## Set a cookie on entire process group
-1 = prctl(62, 1, 0, 2, 0)
core_sched create failed -- PGID: Invalid argument
(cs_prctl_test.c:272) -
[root@iaas-rpma sched]# ps
    PID TTY          TIME CMD
   4605 pts/2    00:00:00 bash
  74986 pts/2    00:00:00 cs_prctl_test
  74987 pts/2    00:00:00 cs_prctl_test
  74999 pts/2    00:00:00 ps

CC: Philip Li <philip.li@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 tools/testing/selftests/sched/cs_prctl_test.c | 28 ++++++++++++-------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 63fe6521c56d..1829383715c6 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -64,6 +64,17 @@ enum pid_type {PIDTYPE_PID = 0, PIDTYPE_TGID, PIDTYPE_PGID};
 
 const int THREAD_CLONE_FLAGS = CLONE_THREAD | CLONE_SIGHAND | CLONE_FS | CLONE_VM | CLONE_FILES;
 
+struct child_args {
+	int num_threads;
+	int pfd[2];
+	int cpid;
+	int thr_tids[MAX_THREADS];
+};
+
+static struct child_args procs[MAX_PROCESSES];
+static int num_processes = 2;
+static int need_cleanup = 0;
+
 static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4,
 		  unsigned long arg5)
 {
@@ -80,8 +91,14 @@ static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned l
 #define handle_error(msg) __handle_error(__FILE__, __LINE__, msg)
 static void __handle_error(char *fn, int ln, char *msg)
 {
+	int pidx;
 	printf("(%s:%d) - ", fn, ln);
 	perror(msg);
+	if (need_cleanup) {
+		for (pidx = 0; pidx < num_processes; ++pidx)
+			kill(procs[pidx].cpid, 15);
+		need_cleanup = 0;
+	}
 	exit(EXIT_FAILURE);
 }
 
@@ -108,13 +125,6 @@ static unsigned long get_cs_cookie(int pid)
 	return cookie;
 }
 
-struct child_args {
-	int num_threads;
-	int pfd[2];
-	int cpid;
-	int thr_tids[MAX_THREADS];
-};
-
 static int child_func_thread(void __attribute__((unused))*arg)
 {
 	while (1)
@@ -214,10 +224,7 @@ void _validate(int line, int val, char *msg)
 
 int main(int argc, char *argv[])
 {
-	struct child_args procs[MAX_PROCESSES];
-
 	int keypress = 0;
-	int num_processes = 2;
 	int num_threads = 3;
 	int delay = 0;
 	int res = 0;
@@ -264,6 +271,7 @@ int main(int argc, char *argv[])
 
 	printf("\n## Create a thread/process/process group hiearchy\n");
 	create_processes(num_processes, num_threads, procs);
+	need_cleanup = 1;
 	disp_processes(num_processes, procs);
 	validate(get_cs_cookie(0) == 0);
 
-- 
2.31.1




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

* Re: [PATCH] kselftests/sched: cleanup the child processes
  2021-09-02  2:43 [PATCH] kselftests/sched: cleanup the child processes Li Zhijian
@ 2021-09-02 11:25 ` Chris Hyser
  2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Li Zhijian
  2021-10-05 14:12 ` tip-bot2 for Li Zhijian
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Hyser @ 2021-09-02 11:25 UTC (permalink / raw)
  To: Li Zhijian, peterz, shuah, linux-kselftest
  Cc: linux-kernel, Philip Li, kernel test robot



On 9/1/21 10:43 PM, Li Zhijian wrote:
> Previously, 'make -C sched run_tests' will block forever when it occurs
> something wrong where the *selftests framework* is waiting for its child
> processes to exit.
> 
> [root@iaas-rpma sched]# ./cs_prctl_test
> 
>   ## Create a thread/process/process group hiearchy
> Not a core sched system
> tid=74985, / tgid=74985 / pgid=74985: ffffffffffffffff
> Not a core sched system
>      tid=74986, / tgid=74986 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74988, / tgid=74986 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74989, / tgid=74986 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74990, / tgid=74986 / pgid=74985: ffffffffffffffff
> Not a core sched system
>      tid=74987, / tgid=74987 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74991, / tgid=74987 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74992, / tgid=74987 / pgid=74985: ffffffffffffffff
> Not a core sched system
>          tid=74993, / tgid=74987 / pgid=74985: ffffffffffffffff
> 
> Not a core sched system
> (268) FAILED: get_cs_cookie(0) == 0
> 
>   ## Set a cookie on entire process group
> -1 = prctl(62, 1, 0, 2, 0)
> core_sched create failed -- PGID: Invalid argument
> (cs_prctl_test.c:272) -
> [root@iaas-rpma sched]# ps
>      PID TTY          TIME CMD
>     4605 pts/2    00:00:00 bash
>    74986 pts/2    00:00:00 cs_prctl_test
>    74987 pts/2    00:00:00 cs_prctl_test
>    74999 pts/2    00:00:00 ps
> 
> CC: Philip Li <philip.li@intel.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> ---
>   tools/testing/selftests/sched/cs_prctl_test.c | 28 ++++++++++++-------
>   1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
> index 63fe6521c56d..1829383715c6 100644
> --- a/tools/testing/selftests/sched/cs_prctl_test.c
> +++ b/tools/testing/selftests/sched/cs_prctl_test.c
> @@ -64,6 +64,17 @@ enum pid_type {PIDTYPE_PID = 0, PIDTYPE_TGID, PIDTYPE_PGID};
>   
>   const int THREAD_CLONE_FLAGS = CLONE_THREAD | CLONE_SIGHAND | CLONE_FS | CLONE_VM | CLONE_FILES;
>   
> +struct child_args {
> +	int num_threads;
> +	int pfd[2];
> +	int cpid;
> +	int thr_tids[MAX_THREADS];
> +};
> +
> +static struct child_args procs[MAX_PROCESSES];
> +static int num_processes = 2;
> +static int need_cleanup = 0;
> +
>   static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4,
>   		  unsigned long arg5)
>   {
> @@ -80,8 +91,14 @@ static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned l
>   #define handle_error(msg) __handle_error(__FILE__, __LINE__, msg)
>   static void __handle_error(char *fn, int ln, char *msg)
>   {
> +	int pidx;
>   	printf("(%s:%d) - ", fn, ln);
>   	perror(msg);
> +	if (need_cleanup) {
> +		for (pidx = 0; pidx < num_processes; ++pidx)
> +			kill(procs[pidx].cpid, 15);
> +		need_cleanup = 0;
> +	}
>   	exit(EXIT_FAILURE);
>   }
>   
> @@ -108,13 +125,6 @@ static unsigned long get_cs_cookie(int pid)
>   	return cookie;
>   }
>   
> -struct child_args {
> -	int num_threads;
> -	int pfd[2];
> -	int cpid;
> -	int thr_tids[MAX_THREADS];
> -};
> -
>   static int child_func_thread(void __attribute__((unused))*arg)
>   {
>   	while (1)
> @@ -214,10 +224,7 @@ void _validate(int line, int val, char *msg)
>   
>   int main(int argc, char *argv[])
>   {
> -	struct child_args procs[MAX_PROCESSES];
> -
>   	int keypress = 0;
> -	int num_processes = 2;
>   	int num_threads = 3;
>   	int delay = 0;
>   	int res = 0;
> @@ -264,6 +271,7 @@ int main(int argc, char *argv[])
>   
>   	printf("\n## Create a thread/process/process group hiearchy\n");
>   	create_processes(num_processes, num_threads, procs);
> +	need_cleanup = 1;
>   	disp_processes(num_processes, procs);
>   	validate(get_cs_cookie(0) == 0);
>   

Reviewed-by: Chris Hyser <chris.hyser@oracle.com>

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

* [tip: sched/core] kselftests/sched: cleanup the child processes
  2021-09-02  2:43 [PATCH] kselftests/sched: cleanup the child processes Li Zhijian
  2021-09-02 11:25 ` Chris Hyser
@ 2021-09-09 11:18 ` tip-bot2 for Li Zhijian
  2021-10-05 14:12 ` tip-bot2 for Li Zhijian
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Li Zhijian @ 2021-09-09 11:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kernel test robot, Li Zhijian, Peter Zijlstra (Intel),
	Chris Hyser, x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     9964e5cf7598cbef7ebd34f8c3a760019dfb55e3
Gitweb:        https://git.kernel.org/tip/9964e5cf7598cbef7ebd34f8c3a760019dfb55e3
Author:        Li Zhijian <lizhijian@cn.fujitsu.com>
AuthorDate:    Thu, 02 Sep 2021 10:43:33 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 09 Sep 2021 11:27:32 +02:00

kselftests/sched: cleanup the child processes

Previously, 'make -C sched run_tests' will block forever when it occurs
something wrong where the *selftests framework* is waiting for its child
processes to exit.

[root@iaas-rpma sched]# ./cs_prctl_test

 ## Create a thread/process/process group hiearchy
Not a core sched system
tid=74985, / tgid=74985 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74986, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74988, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74989, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74990, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74987, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74991, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74992, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74993, / tgid=74987 / pgid=74985: ffffffffffffffff

Not a core sched system
(268) FAILED: get_cs_cookie(0) == 0

 ## Set a cookie on entire process group
-1 = prctl(62, 1, 0, 2, 0)
core_sched create failed -- PGID: Invalid argument
(cs_prctl_test.c:272) -
[root@iaas-rpma sched]# ps
    PID TTY          TIME CMD
   4605 pts/2    00:00:00 bash
  74986 pts/2    00:00:00 cs_prctl_test
  74987 pts/2    00:00:00 cs_prctl_test
  74999 pts/2    00:00:00 ps

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Chris Hyser <chris.hyser@oracle.com>
Link: https://lore.kernel.org/r/20210902024333.75983-1-lizhijian@cn.fujitsu.com
---
 tools/testing/selftests/sched/cs_prctl_test.c | 28 +++++++++++-------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 63fe652..1829383 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -64,6 +64,17 @@ enum pid_type {PIDTYPE_PID = 0, PIDTYPE_TGID, PIDTYPE_PGID};
 
 const int THREAD_CLONE_FLAGS = CLONE_THREAD | CLONE_SIGHAND | CLONE_FS | CLONE_VM | CLONE_FILES;
 
+struct child_args {
+	int num_threads;
+	int pfd[2];
+	int cpid;
+	int thr_tids[MAX_THREADS];
+};
+
+static struct child_args procs[MAX_PROCESSES];
+static int num_processes = 2;
+static int need_cleanup = 0;
+
 static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4,
 		  unsigned long arg5)
 {
@@ -80,8 +91,14 @@ static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned l
 #define handle_error(msg) __handle_error(__FILE__, __LINE__, msg)
 static void __handle_error(char *fn, int ln, char *msg)
 {
+	int pidx;
 	printf("(%s:%d) - ", fn, ln);
 	perror(msg);
+	if (need_cleanup) {
+		for (pidx = 0; pidx < num_processes; ++pidx)
+			kill(procs[pidx].cpid, 15);
+		need_cleanup = 0;
+	}
 	exit(EXIT_FAILURE);
 }
 
@@ -108,13 +125,6 @@ static unsigned long get_cs_cookie(int pid)
 	return cookie;
 }
 
-struct child_args {
-	int num_threads;
-	int pfd[2];
-	int cpid;
-	int thr_tids[MAX_THREADS];
-};
-
 static int child_func_thread(void __attribute__((unused))*arg)
 {
 	while (1)
@@ -214,10 +224,7 @@ void _validate(int line, int val, char *msg)
 
 int main(int argc, char *argv[])
 {
-	struct child_args procs[MAX_PROCESSES];
-
 	int keypress = 0;
-	int num_processes = 2;
 	int num_threads = 3;
 	int delay = 0;
 	int res = 0;
@@ -264,6 +271,7 @@ int main(int argc, char *argv[])
 
 	printf("\n## Create a thread/process/process group hiearchy\n");
 	create_processes(num_processes, num_threads, procs);
+	need_cleanup = 1;
 	disp_processes(num_processes, procs);
 	validate(get_cs_cookie(0) == 0);
 

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

* [tip: sched/core] kselftests/sched: cleanup the child processes
  2021-09-02  2:43 [PATCH] kselftests/sched: cleanup the child processes Li Zhijian
  2021-09-02 11:25 ` Chris Hyser
  2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Li Zhijian
@ 2021-10-05 14:12 ` tip-bot2 for Li Zhijian
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Li Zhijian @ 2021-10-05 14:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kernel test robot, Li Zhijian, Peter Zijlstra (Intel),
	Chris Hyser, x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     1c36432b278cecf1499f21fae19836e614954309
Gitweb:        https://git.kernel.org/tip/1c36432b278cecf1499f21fae19836e614954309
Author:        Li Zhijian <lizhijian@cn.fujitsu.com>
AuthorDate:    Thu, 02 Sep 2021 10:43:33 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 05 Oct 2021 15:51:43 +02:00

kselftests/sched: cleanup the child processes

Previously, 'make -C sched run_tests' will block forever when it occurs
something wrong where the *selftests framework* is waiting for its child
processes to exit.

[root@iaas-rpma sched]# ./cs_prctl_test

 ## Create a thread/process/process group hiearchy
Not a core sched system
tid=74985, / tgid=74985 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74986, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74988, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74989, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74990, / tgid=74986 / pgid=74985: ffffffffffffffff
Not a core sched system
    tid=74987, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74991, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74992, / tgid=74987 / pgid=74985: ffffffffffffffff
Not a core sched system
        tid=74993, / tgid=74987 / pgid=74985: ffffffffffffffff

Not a core sched system
(268) FAILED: get_cs_cookie(0) == 0

 ## Set a cookie on entire process group
-1 = prctl(62, 1, 0, 2, 0)
core_sched create failed -- PGID: Invalid argument
(cs_prctl_test.c:272) -
[root@iaas-rpma sched]# ps
    PID TTY          TIME CMD
   4605 pts/2    00:00:00 bash
  74986 pts/2    00:00:00 cs_prctl_test
  74987 pts/2    00:00:00 cs_prctl_test
  74999 pts/2    00:00:00 ps

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Chris Hyser <chris.hyser@oracle.com>
Link: https://lore.kernel.org/r/20210902024333.75983-1-lizhijian@cn.fujitsu.com
---
 tools/testing/selftests/sched/cs_prctl_test.c | 28 +++++++++++-------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 7db9cf8..8109b17 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -62,6 +62,17 @@ enum pid_type {PIDTYPE_PID = 0, PIDTYPE_TGID, PIDTYPE_PGID};
 
 const int THREAD_CLONE_FLAGS = CLONE_THREAD | CLONE_SIGHAND | CLONE_FS | CLONE_VM | CLONE_FILES;
 
+struct child_args {
+	int num_threads;
+	int pfd[2];
+	int cpid;
+	int thr_tids[MAX_THREADS];
+};
+
+static struct child_args procs[MAX_PROCESSES];
+static int num_processes = 2;
+static int need_cleanup = 0;
+
 static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4,
 		  unsigned long arg5)
 {
@@ -78,8 +89,14 @@ static int _prctl(int option, unsigned long arg2, unsigned long arg3, unsigned l
 #define handle_error(msg) __handle_error(__FILE__, __LINE__, msg)
 static void __handle_error(char *fn, int ln, char *msg)
 {
+	int pidx;
 	printf("(%s:%d) - ", fn, ln);
 	perror(msg);
+	if (need_cleanup) {
+		for (pidx = 0; pidx < num_processes; ++pidx)
+			kill(procs[pidx].cpid, 15);
+		need_cleanup = 0;
+	}
 	exit(EXIT_FAILURE);
 }
 
@@ -106,13 +123,6 @@ static unsigned long get_cs_cookie(int pid)
 	return cookie;
 }
 
-struct child_args {
-	int num_threads;
-	int pfd[2];
-	int cpid;
-	int thr_tids[MAX_THREADS];
-};
-
 static int child_func_thread(void __attribute__((unused))*arg)
 {
 	while (1)
@@ -212,10 +222,7 @@ void _validate(int line, int val, char *msg)
 
 int main(int argc, char *argv[])
 {
-	struct child_args procs[MAX_PROCESSES];
-
 	int keypress = 0;
-	int num_processes = 2;
 	int num_threads = 3;
 	int delay = 0;
 	int res = 0;
@@ -262,6 +269,7 @@ int main(int argc, char *argv[])
 
 	printf("\n## Create a thread/process/process group hiearchy\n");
 	create_processes(num_processes, num_threads, procs);
+	need_cleanup = 1;
 	disp_processes(num_processes, procs);
 	validate(get_cs_cookie(0) == 0);
 

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

end of thread, other threads:[~2021-10-05 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02  2:43 [PATCH] kselftests/sched: cleanup the child processes Li Zhijian
2021-09-02 11:25 ` Chris Hyser
2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Li Zhijian
2021-10-05 14:12 ` tip-bot2 for Li Zhijian

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.