Thread (12 messages) flat view 12 messages, 6 authors, 2025-03-10

Re: [PATCH 2/2] pid: Optional first-fit pid allocation

From: David Laight <hidden>
Date: 2025-02-22 09:02:12
Also in: linux-doc, linux-fsdevel, lkml

On Fri, 21 Feb 2025 16:18:54 -0800
Andrew Morton [off-list ref] wrote:
On Fri, 21 Feb 2025 18:02:49 +0100 Michal Koutný [off-list ref] wrote:
quoted
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -1043,6 +1043,8 @@ The last pid allocated in the current (the one task using this sysctl
 lives in) pid namespace. When selecting a pid for a next task on fork
 kernel tries to allocate a number starting from this one.
 
+When set to -1, first-fit pid numbering is used instead of the next-fit.
+  
This seems thin.  Is there more we can tell our users?  What are the
visible effects of this?  What are the benefits?  Why would they want
to turn it on?

I mean, there are veritable paragraphs in the changelogs, but just a
single line in the user-facing docs.  Seems there could be more...
It also seems a good way of being able to predict the next pid and
doing all the 'nasty' things that allows because there is no guard
time on pid reuse.

Both first-fit and next-fit have the same issue.
Picking a random pid is better.

Or pick the pid after finding an empty slot in the 'hash' table.
Then you guarantee O(1) lookup and can easily stop pids being reused
quickly.

	David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help