kgr: ignore zombie tasks during the patching

There is no special treatment of zombie tasks in kGraft. This means that
they can block the patching process almost infinitely if their
TIF_KGR_IN_PROGRESS flag is set, because they cannot run anymore and
cannot clear the flag.

Simple reproducer:

	# echo 'main() { if(fork()) sleep(300); }' > zombie.c
	# gcc -o zombie zombie.c
	# ./zombie &
	# ps xa | fgrep Z
	# zypper in -t pattern lp_sles
	... installation running
	# kgr status
	# kgr -vv blocking
	2705 [zombie]
	  [<ffffffff8105b877>] do_exit+0x6f7/0xa80
	  [<ffffffff8105bc79>] do_group_exit+0x39/0xa0
	  [<ffffffff8105bcf0>] __wake_up_parent+0x0/0x30
	  [<ffffffff8152dd09>] system_call_fastpath+0x16/0x1b
	  [<00007fd128f9c4f9>] 0x7fd128f9c4f9
	  [<ffffffffffffffff>] 0xffffffffffffffff

Let's ignore the zombie tasks in kgr_still_patching() check. Such task
is in TASK_DEAD state. We also need to be sure that the task is not
running anymore. Otherwise there would be unpleasant race conditions. So
also check task's ->on_cpu. It is set to 0 by the next task in

Signed-off-by: Miroslav Benes <>
Acked-by: Jiri Kosina <>
Reviewed-by: Petr Mladek <>
Signed-off-by: Jiri Slaby <>
1 file changed