Linkage is added for jails for the iterator to use, but it is only utilized when there are no children jails at given level, for simplicity.
This largely sorts out excessive process traversals when running poudriere, which does "kill -9 -1" in jails for each package.
commit 08d130e9cc370c06faec62505cc7bfdd8bfca90b (HEAD -> jaillink1-1) Author: Mateusz Guzik <mjg@FreeBSD.org> Date: Thu Mar 10 19:58:12 2022 +0100 signal: use proc_iterate to save on work Most notably poudriere performs kill -9 -1 in jails for each port being built. This reduces the scan from hundrends of processes to literally 1. Reviewed by: Differential Revision: commit 21fe78c1b0216820142388f1c85eee6d4a9f8e6f Author: Mateusz Guzik <mjg@FreeBSD.org> Date: Thu Mar 10 19:42:37 2022 +0100 jail: add process linkage It allows iteration over processes belonging to given jail instead of having to walk the entire allproc list. Note the iteration can miss processes which remains bug-compatible with previous code. Reviewed by: Differential Revision:
Sample stats below:
processes iterated over:
value ------------- Distribution ------------- count 512 | 0 520 | 1 528 | 5 536 | 14 544 |@ 26 552 |@ 39 560 |@ 31 568 |@ 39 576 |@ 41 584 |@ 39 592 |@ 37 600 |@ 30 608 | 14 616 | 12 624 | 8 632 | 9 640 | 17 648 | 21 656 |@ 36 664 |@ 59 672 |@ 52 680 |@@ 82 688 |@ 69 696 |@@ 96 704 |@@ 103 712 |@@ 89 720 |@@ 111 728 |@@ 93 736 |@@ 105 744 |@@ 90 752 |@@ 90 760 |@@ 94 768 |@ 50 776 |@ 56 784 |@ 45 792 |@ 33 800 |@ 29 808 | 22 816 | 17 824 | 17 832 | 18 840 | 12 848 | 13 856 | 10 864 | 20 872 | 14 880 | 24 888 | 12 896 | 5 904 | 6 912 | 4 920 | 2 928 | 3 936 | 1 944 | 2 952 | 2 960 | 0 968 | 3 976 | 2 984 | 3 992 | 2 1000 | 0 1008 | 3 1016 | 1 >= 1024 | 0
processes signalled:
value ------------- Distribution ------------- count -1 | 0 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1983 1 | 0
with the patch:
value ------------- Distribution ------------- count 0 | 0 1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1454 2 | 0 value ------------- Distribution ------------- count -1 | 0 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1454 1 | 0
Note this patch does not fully solve the problem outlined by me in D28566 -- should something want to kill everything in the jail without paying for entering it, there is still no way to do it.