[0/4] perf bench messaging: Kill child processes when exit abnormally in process mode

Message ID 20230923093037.961232-1-yangjihong1@huawei.com
Headers
Series perf bench messaging: Kill child processes when exit abnormally in process mode |

Message

Yang Jihong Sept. 23, 2023, 9:30 a.m. UTC
  If perf bench messaging in process mode exits abnormally, the forked child
processes does not exit.

The test result is as follows:

  # perf bench sched messaging -l 1000000 -g 1 &
  [4] 553
  # Running 'sched/messaging' benchmark:
  # kill -15 533
  # ps -ef | grep perf
  root         425     371  0 09:11 pts/0    00:00:00 perf bench sched messaging -l 1000000 -g 1
  root         426     425 17 09:11 pts/0    00:01:56 perf bench sched messaging -l 1000000 -g 1
  root         427     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         428     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         429     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         430     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         431     425 17 09:11 pts/0    00:01:56 perf bench sched messaging -l 1000000 -g 1
  root         432     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         433     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         434     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         435     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         436     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         437     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         438     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         439     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         440     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         441     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         442     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         443     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         444     425 17 09:11 pts/0    00:01:54 perf bench sched messaging -l 1000000 -g 1
  root         445     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
  root         446     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
  root         447     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
  root         448     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
  root         449     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
  root         450     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
  root         451     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
  root         452     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
  root         453     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
  root         454     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
<SNIP>

Capture signals SIGINT and SIGTERM to kill child processes in signal handler

Yang Jihong (4):
  perf bench messaging: Fix coding style issues for sched-messaging
  perf bench messaging: Factor out create_worker()
  perf bench messaging: Store chlid process pid when creating worker for
    process mode
  perf bench messaging: Kill child processes when exit abnormally in
    process mode

 tools/perf/bench/sched-messaging.c | 102 ++++++++++++++++++-----------
 1 file changed, 64 insertions(+), 38 deletions(-)
  

Comments

Namhyung Kim Sept. 28, 2023, 3:55 a.m. UTC | #1
On Sat, Sep 23, 2023 at 2:32 AM Yang Jihong <yangjihong1@huawei.com> wrote:
>
> If perf bench messaging in process mode exits abnormally, the forked child
> processes does not exit.
>
> The test result is as follows:
>
>   # perf bench sched messaging -l 1000000 -g 1 &
>   [4] 553
>   # Running 'sched/messaging' benchmark:
>   # kill -15 533
>   # ps -ef | grep perf
>   root         425     371  0 09:11 pts/0    00:00:00 perf bench sched messaging -l 1000000 -g 1
>   root         426     425 17 09:11 pts/0    00:01:56 perf bench sched messaging -l 1000000 -g 1
>   root         427     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         428     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         429     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         430     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         431     425 17 09:11 pts/0    00:01:56 perf bench sched messaging -l 1000000 -g 1
>   root         432     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         433     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         434     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         435     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         436     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         437     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         438     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         439     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         440     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         441     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         442     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         443     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         444     425 17 09:11 pts/0    00:01:54 perf bench sched messaging -l 1000000 -g 1
>   root         445     425 17 09:11 pts/0    00:01:55 perf bench sched messaging -l 1000000 -g 1
>   root         446     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
>   root         447     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
>   root         448     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
>   root         449     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
>   root         450     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
>   root         451     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
>   root         452     425 16 09:11 pts/0    00:01:50 perf bench sched messaging -l 1000000 -g 1
>   root         453     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
>   root         454     425 16 09:11 pts/0    00:01:49 perf bench sched messaging -l 1000000 -g 1
> <SNIP>
>
> Capture signals SIGINT and SIGTERM to kill child processes in signal handler
>
> Yang Jihong (4):
>   perf bench messaging: Fix coding style issues for sched-messaging
>   perf bench messaging: Factor out create_worker()
>   perf bench messaging: Store chlid process pid when creating worker for
>     process mode
>   perf bench messaging: Kill child processes when exit abnormally in
>     process mode

Applied to perf-tools-next, thanks!