Re: + pid-delete-reserved_pids.patch added to -mm tree

From: Oleg Nesterov
Date: Wed Oct 04 2017 - 12:36:39 EST


On 10/04, Alexey Dobriyan wrote:
>
> On Tue, Oct 03, 2017 at 05:53:15PM +0200, Oleg Nesterov wrote:
> > On 10/02, Andrew Morton wrote:
> > >
> > > From: Alexey Dobriyan <adobriyan@xxxxxxxxx>
> > > Subject: pid: delete RESERVED_PIDS
> > >
> > > RESERVED_PIDS had a noble goal: to protect root from PID exhaustion since
> > > at least ~2.5.40
> >
> > I am just curious, where did you find the change which documents this goal?
>
> Now that you asked, I'm not exactly sure. :-( Please don't tell it is for some
> kind of stupid userspace which assumed low numbers are kernel threads.

Not necessarily kernel threads,

> > > Allow small pids to be allocated after rollover, there is nothing sacred
> > > about them.
> > >
> > > Resource exhaustion should be handled by rlimits and/or kernel memory
> > > accounting.
> >
> > I won't argue, but I always thought that the only purpose of RESERVED_PIDS
> > is to make the system/kernek daemons started at boot time more "visible" in
> > /usr/bin/ps output.
>
> They will be first in line naturally: kthreadd + init execute first and
> rarely exit.

Exactly.

But, with your patch, only until ->last_pid overlaps.

And while I don't think this can break something, I bet humans will notice
this change ;)

And in fact, from time to time I thought that perhaps it makes sense to change
alloc_pidmap() to check PF_KTHREAD and allocate the new pid from RESERVED_PIDS
interval if it is set.

So I am not sure this is change is really good but I won't argue.

Oleg.