lkml.org 
[lkml]   [2017]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API
From
Date
On Sun, 2017-10-01 at 02:15 -0700, Christoph Hellwig wrote:
> > - task_active_pid_ns(current)->last_pid);
> > + task_active_pid_ns(current)->idr.idr_next-1);
>
> I think we want a well documented helper for this pattern instead
> of poking into the internals.
>
> Also is last - 1 always the correct answer?  Even with
> idr_alloc_cyclic
> we could wrap around, couldn't we?

Good point. I wonder if it makes sense to change the IDR
code, so idr_get_cursor returns the last allocated ID?

I see only two users of idr_get_cursor in the kernel,
and it looks like both would work fine if idr_get_cursor
returned the previously allocated value.

That would require a small change to idr_alloc_cyclic,
to have it start searching at a position one larger than
the cursor, and maybe renaming idr->idr_next to
idr->cursor, since it would now represent the last
value allocated, not the next.

Would that make sense?

--
All Rights Reversed.[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-10-02 15:06    [W:0.088 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site