linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Michal Koutný" <mkoutny@suse.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Alexander Mikhalitsyn" <alexander@mihalicyn.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	"Jonathan Corbet" <corbet@lwn.net>, "Kees Cook" <kees@kernel.org>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	"Oleg Nesterov" <oleg@redhat.com>
Subject: Re: [PATCH 2/2] pid: Optional first-fit pid allocation
Date: Sat, 22 Feb 2025 09:02:08 +0000	[thread overview]
Message-ID: <20250222090208.2b7aa864@pumpkin> (raw)
In-Reply-To: <20250221161854.8ea0dd0b2da05d38574cefc4@linux-foundation.org>

On Fri, 21 Feb 2025 16:18:54 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Fri, 21 Feb 2025 18:02:49 +0100 Michal Koutný <mkoutny@suse.com> wrote:
> 
> > --- 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

  reply	other threads:[~2025-02-22  9:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21 17:02 [PATCH 0/2] Alternative "pid_max" for 32-bit userspace Michal Koutný
2025-02-21 17:02 ` [PATCH 1/2] Revert "pid: allow pid_max to be set per pid namespace" Michal Koutný
2025-02-25 17:36   ` Alexander Mikhalitsyn
2025-03-10  7:32   ` kernel test robot
2025-02-21 17:02 ` [PATCH 2/2] pid: Optional first-fit pid allocation Michal Koutný
2025-02-22  0:18   ` Andrew Morton
2025-02-22  9:02     ` David Laight [this message]
2025-03-05 15:01       ` Michal Koutný
2025-03-05 15:04     ` Michal Koutný
2025-02-25 17:30   ` Alexander Mikhalitsyn
2025-03-06  8:59   ` Christian Brauner
2025-03-06  9:09     ` Michal Koutný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250222090208.2b7aa864@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander@mihalicyn.com \
    --cc=brauner@kernel.org \
    --cc=corbet@lwn.net \
    --cc=ebiederm@xmission.com \
    --cc=kees@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=oleg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).