[v3,0/2] ipc,namespace: fix free vs allocation race

Message ID 20230127184651.3681682-1-riel@surriel.com
Headers
Series ipc,namespace: fix free vs allocation race |

Message

Rik van Riel Jan. 27, 2023, 6:46 p.m. UTC
  The IPC namespace code frees ipc_namespace structures asynchronously,
via a work queue item. This results in ipc_namespace structures being
freed very slowly, and the allocation path getting false failures
since the to-be-freed ipc_namespace structures have not been freed
yet.

Fix that by having the allocator wait when there are ipc_namespace
structures pending to be freed.

Also speed up the freeing of ipc_namespace structures. We had some
discussions about this last year, and ended up trying out various
"nicer" ideas that did not work, so I went back to the original,
with Al Viro's suggestion for a helper function:

https://lore.kernel.org/all/Yg8StKzTWh+7FLuA@zeniv-ca.linux.org.uk/

This series fixes both the false allocation failures, and the slow
freeing of ipc_namespace structures.

v3: remove mq_put_mnt (thank you Giuseppe)
v2: a few more fs/namespace.c cleanups suggested by Al Viro (thank you!)
  

Comments

Giuseppe Scrivano Jan. 27, 2023, 6:56 p.m. UTC | #1
Rik van Riel <riel@surriel.com> writes:

> The IPC namespace code frees ipc_namespace structures asynchronously,
> via a work queue item. This results in ipc_namespace structures being
> freed very slowly, and the allocation path getting false failures
> since the to-be-freed ipc_namespace structures have not been freed
> yet.
>
> Fix that by having the allocator wait when there are ipc_namespace
> structures pending to be freed.
>
> Also speed up the freeing of ipc_namespace structures. We had some
> discussions about this last year, and ended up trying out various
> "nicer" ideas that did not work, so I went back to the original,
> with Al Viro's suggestion for a helper function:
>
> https://lore.kernel.org/all/Yg8StKzTWh+7FLuA@zeniv-ca.linux.org.uk/
>
> This series fixes both the false allocation failures, and the slow
> freeing of ipc_namespace structures.
>
> v3: remove mq_put_mnt (thank you Giuseppe)
> v2: a few more fs/namespace.c cleanups suggested by Al Viro (thank you!)

Tested-by: Giuseppe Scrivano <gscrivan@redhat.com>
  
Al Viro Jan. 28, 2023, 1:31 a.m. UTC | #2
On Fri, Jan 27, 2023 at 01:46:49PM -0500, Rik van Riel wrote:
> The IPC namespace code frees ipc_namespace structures asynchronously,
> via a work queue item. This results in ipc_namespace structures being
> freed very slowly, and the allocation path getting false failures
> since the to-be-freed ipc_namespace structures have not been freed
> yet.
> 
> Fix that by having the allocator wait when there are ipc_namespace
> structures pending to be freed.
> 
> Also speed up the freeing of ipc_namespace structures. We had some
> discussions about this last year, and ended up trying out various
> "nicer" ideas that did not work, so I went back to the original,
> with Al Viro's suggestion for a helper function:
> 
> https://lore.kernel.org/all/Yg8StKzTWh+7FLuA@zeniv-ca.linux.org.uk/
> 
> This series fixes both the false allocation failures, and the slow
> freeing of ipc_namespace structures.
> 
> v3: remove mq_put_mnt (thank you Giuseppe)
> v2: a few more fs/namespace.c cleanups suggested by Al Viro (thank you!)

Applied (#work.namespace)