From: Oleg Nesterov <oleg@redhat.com>
To: Gargi Sharma <gs051095@gmail.com>
Cc: Andrei Vagin <avagin@virtuozzo.com>,
linux-kernel@vger.kernel.org, Rik van Riel <riel@surriel.com>,
Julia Lawall <julia.lawall@lip6.fr>,
Andrew Morton <akpm@linux-foundation.org>,
mingo@kernel.org, pasha.tatashin@oracle.com,
ktkhai@virtuozzo.com, "Eric W. Biederman" <ebiederm@xmission.com>,
Christoph Hellwig <hch@infradead.org>,
lkp@intel.com, tony.luck@intel.com
Subject: Re: [v6,1/2] pid: Replace pid bitmap implementation with IDR API
Date: Mon, 23 Oct 2017 17:31:36 +0200 [thread overview]
Message-ID: <20171023153136.GA27553@redhat.com> (raw)
In-Reply-To: <CAOCi2DGpda4OXTCJFn1k6i4zP5CJjPOZPaHuxaeT3auNPg2upw@mail.gmail.com>
On 10/22, Gargi Sharma wrote:
>
> On Fri, Oct 20, 2017 at 6:21 PM, Andrei Vagin <avagin@virtuozzo.com> wrote:
> > On Fri, Oct 20, 2017 at 05:06:47PM +0100, Gargi Sharma wrote:
> >> On Thu, Oct 19, 2017 at 5:18 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> >> >
> >> > unsigned int last;
> >> > int err;
> >> >
> >> > tmp.data = &last;
> >> > err = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
> >> > if (!err)
> >> > idr_set_cursor(&pid_ns->idr, last + 1);
> >> > return err;
> >> I'm not sure entirely understand how this takes care of rolling over of PIDs?
> >> Can we ignore that? If yes, won't the tests for CRIU still break?
> >
> > Gargi, I don't understand what you mean. Could you elaborate? Do you
> > mean a case when idr_next is bigger than pid_max? I think this logic
> > remains the same what we had before switching to idr.
>
> When the PIDs are allocated, if the allocation exceeds pid_max wraps
> around and starts allocating PIDs starting from pid_min.
You misunderstood the problem introduced by your patch...
We do not care about pid_max overlap. The problem is that criu writes
to /proc/sys/kernel/ns_last_pid to control the pid number allocated by
the next fork().
So if you do "echo 100 > /proc/sys/kernel/ns_last_pid" the next fork()
should create the process with tid=101 (of course, if 101 is free).
After your patch the new task will have tid=100. See?
> > CRIU tests works with a following patch. It is slightly modified version
> > of Oleg's patch.
Andrei, could you write the changelog and send the fix to akpm? Feel free
to add my ack or sob.
Oleg.
> > diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
> > index fea2c24..1c791b3 100644
> > --- a/kernel/pid_namespace.c
> > +++ b/kernel/pid_namespace.c
> > @@ -287,6 +287,7 @@ static int pid_ns_ctl_handler(struct ctl_table
> > *table, int write,
> > {
> > struct pid_namespace *pid_ns = task_active_pid_ns(current);
> > struct ctl_table tmp = *table;
> > + int ret;
> >
> > if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
> > return -EPERM;
> > @@ -298,7 +299,12 @@ static int pid_ns_ctl_handler(struct ctl_table
> > *table, int write,
> > */
> >
> > tmp.data = &pid_ns->idr.idr_next;
> > - return proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
> > + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
> > + if (ret < 0)
> > + return ret;
> > +
> > + idr_set_cursor(&pid_ns->idr, pid_ns->idr.idr_next + 1);
> > + return 0;
> > }
> >
> > extern int pid_max;
> >
> >
> >>
> >> Thanks,
> >> Gargi
> >> >
> >> > Oleg.
> >> >
next prev parent reply other threads:[~2017-10-23 15:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 22:19 [PATCH v6 0/2] Replacing PID bitmap implementation with IDR API Gargi Sharma
2017-10-11 22:19 ` [PATCH v6 1/2] pid: Replace pid " Gargi Sharma
2017-10-11 22:28 ` Rik van Riel
2017-10-11 22:37 ` Andrew Morton
2017-10-12 0:54 ` Rik van Riel
2017-10-12 22:58 ` Andrew Morton
2017-10-13 14:58 ` Oleg Nesterov
2017-10-19 7:30 ` [v6,1/2] " Andrei Vagin
2017-10-19 13:20 ` Gargi Sharma
2017-10-19 16:18 ` Oleg Nesterov
2017-10-20 16:06 ` Gargi Sharma
2017-10-20 17:21 ` Andrei Vagin
2017-10-22 8:05 ` Gargi Sharma
2017-10-23 15:31 ` Oleg Nesterov [this message]
2017-10-11 22:19 ` [PATCH v6 2/2] pid: Remove pidhash Gargi Sharma
2017-10-11 22:28 ` Rik van Riel
2017-10-11 22:47 ` Luck, Tony
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=20171023153136.GA27553@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@virtuozzo.com \
--cc=ebiederm@xmission.com \
--cc=gs051095@gmail.com \
--cc=hch@infradead.org \
--cc=julia.lawall@lip6.fr \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mingo@kernel.org \
--cc=pasha.tatashin@oracle.com \
--cc=riel@surriel.com \
--cc=tony.luck@intel.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