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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAABCAAGBQJZ0jmeAAoJEM553pKExN6DKUYH+gPLvG7MeRkqpzxQTAgY2yWh S170OfZ2T+s58AZdObxyilM41RwSyG+EBm0eYsMBmewKjzoko4bLxiQKe4bInilk 1FKiwAv4YG/toA50ELsngwD3/4qF2+rwFwydU/4S/D6shQbZ7jdn1tlRQQtOeYpS kqll0JyGOop3NPVRXqtklydbTcZCP/OkpNHMmUNVqgtnp76y4RGihFUyUOo8oID1 sHS8subuelblSNLG+B5W/0m/lniwBUXAcs1PnE2YnkucJc1RnoZfAGS79GPFbKej yUVJaNq8t4MV4UKO+j1WI/a9/l5hdBCXwWX69AgHzsSYQs61tERmwLVxqDgm5zo=
=ZH8S
-----END PGP SIGNATURE-----
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)