lkml.org 
[lkml]   [2017]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 1/2] pid: Replace pid bitmap implementation with IDR API
On 10/12, Andrew Morton wrote:
>
> On Wed, 11 Oct 2017 20:54:32 -0400 Rik van Riel <riel@surriel.com> wrote:
>
> > Documenting the locking on all the existing code, plus the
> > new code, seems a little out of scope of an Outreachy
> > internship...
>
> I'm not referring to all the existing code! Just this new
> pid_namespace.idr's locking. If it was protected by
> spin_lock_irq(&pidmap_lock) everywhere then an explanation wouldn't be
> needed. But we have this oddball site where pidmap_lock isn't taken
> but it uses rcu_read_lock() which is surprising to say the least.
> Readers could be forgiven for thinking that is a bug.

Actually this all looks simple, or I missed something...

pid_namespace.idr is protected by pidmap_lock, it is always modified
with this lock held.

idr_find/idr_find_ext/etc can be called under rcu_read_lock() simply
because idr/radix_tree is rcu-safe and this is already documented in
idr.h, say, the comment above idr_find() says

* This function can be called under rcu_read_lock(), given that the leaf
* pointers lifetimes are correctly managed.

Oleg.

\
 
 \ /
  Last update: 2017-10-13 16:59    [W:0.045 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site