ipc,namespace: make ipc namespace allocation wait for pending free
authorRik van Riel <riel@surriel.com>
Fri, 27 Jan 2023 18:46:50 +0000 (13:46 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 28 Jan 2023 00:07:59 +0000 (19:07 -0500)
commita80c4adcb574821e534779c48ae13953b7d1d996
tree923717454dc5a0affff35d387e5cac66cc42d03b
parentb7bfaa761d760e72a969d116517eaa12e404c262
ipc,namespace: make ipc namespace allocation wait for pending free

Currently the ipc namespace allocation will fail when there are
ipc_namespace structures pending to be freed. This results in the
simple test case below, as well as some real world workloads, to
get allocation failures even when the number of ipc namespaces in
actual use is way below the limit.

int main()
{
int i;

for (i = 0; i < 100000; i++) {
if (unshare(CLONE_NEWIPC) < 0)
error(EXIT_FAILURE, errno, "unshare");
}
}

Make the allocation of an ipc_namespace wait for pending frees,
so it will succeed.

real 6m19.197s
user 0m0.041s
sys 0m1.019s

Signed-off-by: Rik van Riel <riel@surriel.com>
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
ipc/namespace.c