From: Oleg Nesterov <oleg@redhat.com>
To: Gargi Sharma <gs051095@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Rik van Riel <riel@surriel.com>,
Julia Lawall <julia.lawall@lip6.fr>,
mingo@kernel.org, pasha.tatashin@oracle.com,
ktkhai@virtuozzo.com, "Eric W. Biederman" <ebiederm@xmission.com>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v4 1/2] pid: Replace pid bitmap implementation with IDR API
Date: Tue, 10 Oct 2017 16:15:23 +0200 [thread overview]
Message-ID: <20171010141523.GA16542@redhat.com> (raw)
In-Reply-To: <CAOCi2DFV_USU=m+vHp0=JHiwcZf3sUT=jf5+ktMsr_cxn9nQ=A@mail.gmail.com>
On 10/10, Gargi Sharma wrote:
>
> On Tue, Oct 10, 2017 at 12:50 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> > On 10/09, Andrew Morton wrote:
> >>
> >> Especially here. I don't think pidmap_lock is held. Is that IDR
> >> iteration safe?
> >
> > Yes, this doesn't look right, we need rcu_read_lock() or pidmap_lock.
> >
> > And, we also need rcu_read_lock() for another reason, to protect "struct pid".
>
> Ah, I missed this. From what I understood idr_for_each_entry_continue
> should be safe
Without rcu? Why?
> because calls idr_get_next which in turn calls
> radix_tree_iter_find to find the next populated entry in the idr.
and then it does rcu_dereference_raw(*slot). Without rcu or pidmap this
slot can got away if we race with free_pid().
> If
> the pid that you are looking up the task for is deleted, task will get
> a NULL from pid_task and no signal to kill will be sent.
pid->tasks is protected by tasklist_lock, but the pid itself can go away
without rcu lock.
So I think you need to take rcu_read_lock() right after tasklist_lock.
> > Gargi, I suggested to use idr_for_each_entry_continue(), but now I am wondering
> > if we should use idr_for_each() instead. IIUC this would be a bit faster? Not
> > that I think this is really important...
>
> I can run benchmarks with idr_for_each to see how much speed up is
> achieved and then we can go with whatever we think is better. How does
> that sounds?
Up to you ;) I am fine either way.
Oleg.
next prev parent reply other threads:[~2017-10-10 14:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 21:13 [PATCH v4 0/2] Replacing PID bitmap implementation with IDR API Gargi Sharma
2017-10-09 21:13 ` [PATCH v4 1/2] pid: Replace pid " Gargi Sharma
2017-10-09 23:17 ` Andrew Morton
2017-10-10 11:50 ` Oleg Nesterov
2017-10-10 12:35 ` Gargi Sharma
2017-10-10 14:15 ` Oleg Nesterov [this message]
2017-10-10 15:46 ` Rik van Riel
2017-10-10 16:11 ` Gargi Sharma
2017-10-10 17:51 ` Rik van Riel
2017-10-10 13:44 ` Rik van Riel
2017-10-09 21:13 ` [PATCH v4 2/2] pid: Remove pidhash Gargi Sharma
2017-10-11 9:47 ` kbuild test robot
2017-10-11 14:15 ` Rik van Riel
2017-10-11 14:15 ` Rik van Riel
2017-10-11 21:22 ` Luck, Tony
2017-10-11 21:22 ` 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=20171010141523.GA16542@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--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=mingo@kernel.org \
--cc=pasha.tatashin@oracle.com \
--cc=riel@surriel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.