• [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API

    From Rik van Riel@21:1/5 to Christoph Hellwig on Mon Oct 2 15:10:03 2017
    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)
  • From Rik van Riel@21:1/5 to Gargi Sharma on Mon Oct 2 15:20:01 2017
    On Sun, 2017-10-01 at 16:05 +0530, Gargi Sharma wrote:
    On Sun, Oct 1, 2017 at 2:45 PM, Christoph Hellwig <hch@infradead.org>
    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.

    idr_get_cursor() get can be used instead of idr.idr_next, so that we
    do not
    expose the internals.

    Also is last - 1 always the correct answer?  Even with
    idr_alloc_cyclic
    we could wrap around, couldn't we?

    -1 will be incorrect when the pids wrap around. Should we go back to
    setting up last_pid as it was done before? Or should we use
    idr_get_cursor
    and determine if pid was rolled over and then perform necessary
    action?

    Looking at it some more, it appears the value is only ever used
    in /proc/loadavg.

    Would anyone object to the code simply calling idr_get_cursor()
    as is, and leaving out the -1?

    Somehow I suspect nobody will care that the pid value in /proc/loadavg
    reflects the next PID allocated, rather than the previous one.

    Any objections?

    --
    All Rights Reversed.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2

    iQEcBAABCAAGBQJZ0ju6AAoJEM553pKExN6DTkEH/iM5Kajl7iwXr/t7QIh7tVzS Wq6y3rAvnd8kDWhAGYfDglVk7i+9sDPYtBjvvu2yiVyOkH+MVNmu5jIwur7hSl8W 3uKLynhTf5+siumtB7VM7Jr4YJDGvDjoVMpoffVazXifkuWTG5dGkRgqzqxAtpDK ypOWpF0efDshLhabfWZkzfAsrB5CJtpWy+bwgqoOLI6pzU3S59aMY1nFKxcS1lqn byXDDUj2220lKKCV8ccCa0XmTDdTQamMgNcAAuAkbU90DAPcAxAc4lA3E+vWIhm2 c4p6dDSoqVOQ1D+4lQ9J16PVRZx56HJD1TNcZnMHVnOCqjyf3o0xqIOeOGPf4bE=
    =xoH8
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)