From: David Laight <David.Laight@ACULAB.COM>
To: 'Matthew Wilcox' <willy@infradead.org>
Cc: 'Martin Steigerwald' <martin@lichtvoll.de>,
Michal Hocko <mhocko@kernel.org>,
Daniel Colascione <dancol@google.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
"rppt@linux.ibm.com" <rppt@linux.ibm.com>,
Tim Murray <timmurray@google.com>,
Joel Fernandes <joelaf@google.com>,
"Suren Baghdasaryan" <surenb@google.com>,
Jonathan Corbet <corbet@lwn.net>,
"Andrew Morton" <akpm@linux-foundation.org>,
Roman Gushchin <guro@fb.com>,
"Mike Rapoport" <rppt@linux.vnet.ibm.com>,
Vlastimil Babka <vbabka@suse.cz>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Dennis Zhou (Facebook)" <dennisszhou@gmail.com>,
Prashant Dhamdhere <pdhamdhe@redhat.com>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>
Subject: RE: [PATCH v2] Document /proc/pid PID reuse behavior
Date: Thu, 8 Nov 2018 13:42:41 +0000 [thread overview]
Message-ID: <47072118046a450b904556ca8154f5c9@AcuMS.aculab.com> (raw)
In-Reply-To: <20181108122747.GM3074@bombadil.infradead.org>
From: Matthew Wilcox
> Sent: 08 November 2018 12:28
>
> On Thu, Nov 08, 2018 at 12:02:49PM +0000, David Laight wrote:
> > From: Martin Steigerwald
> > > Sent: 07 November 2018 17:05
> > ...
> > > Its not quite on-topic, but I am curious now: AFAIK PID limit is 16
> > > bits. Right? Could it be raised to 32 bits? I bet it would be a major
> > > change throughout different parts of the kernel.
> >
> > It is probably 15 bits (since -ve pid numbers are used for process groups).
> >
> > My guess is that userspace and the system call interface will handle 32bit
> > (signed) pid numbers.
> > (I don't remember 'linux emulation' being one of the emulations that
> > would truncate 32bit pids when one of the BDSs went to 32bit pids.)
> > The main problem will be that big numbers will mess up the alignment
> > of printouts from ps and top (etc).
> > This can be mitigated by only allocating 'big' numbers on systems
> > that have a lot of pids.
> > You also really want an O(1) allocator.
>
> The allocator is O(log n) -- it's the IDR allocator, used in cyclic mode.
> n in this case is the highest ID which is still in use. The tree is
> log_64(n) levels high. It walks to the bottom of the tree and puts a
> pointer into the tree. If the cursor has wrapped to the beginning of
> the tree, it may encounter a PID which is still in use; if it does,
> it does a bitmap scan of that node, and will then walk up the tree,
> doing a bitmap scan forward at each level until it finds a free PID.
Right, but you can choose the pid so that you get a perfect hash.
You can then put a FIFO free list through the unused entries of
the hash table (just an array).
Then pid allocate just picks the oldest free entry and ups the
high bits (that the hash masks out) to make the old value stale.
Almost no cache lines are involved in the whole operation.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2018-11-08 13:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 15:06 [PATCH] " Daniel Colascione
2018-11-01 7:08 ` Mike Rapoport
2018-11-05 13:22 ` [PATCH v2] " Daniel Colascione
2018-11-06 6:01 ` Mike Rapoport
2018-11-07 17:16 ` Matthew Wilcox
2018-11-07 18:21 ` Daniel Colascione
2018-11-06 13:05 ` Michal Hocko
2018-11-07 15:48 ` Daniel Colascione
2018-11-07 16:00 ` Michal Hocko
2018-11-07 16:10 ` Daniel Colascione
2018-11-07 16:19 ` Michal Hocko
2018-11-19 11:16 ` Aleksa Sarai
2018-11-07 17:04 ` Martin Steigerwald
2018-11-08 12:02 ` David Laight
2018-11-08 12:27 ` Matthew Wilcox
2018-11-08 13:42 ` David Laight [this message]
2018-11-08 14:07 ` Matthew Wilcox
2018-11-08 14:14 ` David Laight
2018-11-08 13:25 ` Michal Hocko
2018-11-19 10:54 ` Pavel Machek
2018-11-19 16:24 ` Daniel Colascione
2018-11-20 8:50 ` Pavel Machek
2018-11-20 9:05 ` Vlastimil Babka
2018-11-20 9:18 ` Pavel Machek
2018-11-20 17:39 ` Matthew Wilcox
2018-11-20 17:48 ` Daniel Colascione
2018-11-20 17:59 ` Matthew Wilcox
2018-11-20 16:37 ` Joel Fernandes
2018-11-20 16:49 ` Jonathan Corbet
2018-11-20 16:57 ` Pavel Machek
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=47072118046a450b904556ca8154f5c9@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dancol@google.com \
--cc=dennisszhou@gmail.com \
--cc=guro@fb.com \
--cc=joelaf@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin@lichtvoll.de \
--cc=mhocko@kernel.org \
--cc=pdhamdhe@redhat.com \
--cc=rppt@linux.ibm.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=surenb@google.com \
--cc=timmurray@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®