Re: git: eb93b99d6986 - main - in_pcb: delay crfree() down into UMA dtor

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Tue, 28 Dec 2021 00:46:54 UTC
On Fri, Dec 17, 2021 at 10:17:55PM -0800, Gleb Smirnoff wrote:
T> T> K> The jails created by that test never go away. It’s as if 
T> T> K> `crfree(inp->inp_cred);` doesn’t actually get called. And indeed, it 
T> T> K> looks like inpcb_dtor() does not get called at all.
T> T> 
T> T> Yes, I faced this problem today, too. :(
T> T> 
T> T> My radical opinion is that per-VNET pcb zones should just be eliminated.
T> T> The only thing they serve is imposing maxsockets limit separately for
T> T> each VNET. But we already have the maxsocket limit on the socket zone,
T> T> which is _global_!
T> T> 
T> T> Anybody to explain me the sense of the per-VNET per-pcb zone limit
T> T> set to the same maxsockets value? You can't create a pcb without a
T> T> socket, which is guaranteed by the in_pcballoc() prototype. Of course
T> T> I understand that pcbs may outlive the socket. But those pcbs that
T> T> outlive a socket, are eventually garbage collected as their lifetime
T> T> is finite. Anyway jail/VNET was never declared as a resource management
T> T> framework anyway!
T> T> 
T> T> So, for this particular problem I would suggest just eliminate per-VNET
T> T> pcb zones, but in general the fact that idle SMR zone may never purge
T> T> its cache sucks and needs improvement.
T> 
T> I have created a patch that would mitigate that problem. Once the zones
T> are global, the jails will eventually die if there is some pcb zone
T> traffic.
T> 
T> https://reviews.freebsd.org/D33542

Despite I still believe that PCB zones belong to global state rather than
to a VNET, the patch doesn't help to mitigate massive memory leaks with
vnet jails on a machine that is dedicated solely to run a test suite.
If machine does nothing except a test suite, there is almost zero pcb
traffic. If there is no pcb zone traffic, the SMR caches stay, and thus
destroyed jails will also stay. Our vnet jail "weights" a lot! Even with
the global PCB zone patch applied, each vnet jail creates 33 UMA zones!

I think we need a KPI to purge the SMR caches, and we also need to put
vnet jails on a diet. These are two independent problems, of course.

-- 
Gleb Smirnoff