Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1740117

Re: [PATCH v2 2/2] pidmap(2)

From Alexey Dobriyan <adobriyan@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/2] pidmap(2)
Date 2017-09-26 20:50 +0200
Message-ID <uu35E-8ph-15@gated-at.bofh.it> (permalink)
References <utlnX-4Gy-5@gated-at.bofh.it> <utlnZ-4Gy-39@gated-at.bofh.it> <utmDp-5ss-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Sep 24, 2017 at 02:27:00PM -0700, Andy Lutomirski wrote:
> On Sun, Sep 24, 2017 at 1:08 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > From: Tatsiana Brouka <Tatsiana_Brouka@epam.com>
> >
> > Implement system call for bulk retrieveing of pids in binary form.
> >
> > Using /proc is slower than necessary: 3 syscalls + another 3 for each thread +
> > converting with atoi() + instantiating dentries and inodes.
> >
> > /proc may be not mounted especially in containers. Natural extension of
> > hidepid=2 efforts is to not mount /proc at all.
> >
> > It could be used by programs like ps, top or CRIU. Speed increase will
> > become more drastic once combined with bulk retrieval of process statistics.
> >
> > Benchmark:
> >
> >         N=1<<16 times
> >         ~130 processes (~250 task_structs) on a regular desktop system
> >         opendir + readdir + closedir /proc + the same for every /proc/$PID/task
> >         (roughly what htop(1) does) vs pidmap
> >
> >         /proc 16.80 ± 0.73%
> >         pidmap 0.06 ± 0.31%
> >
> > PIDMAP_* flags are modelled after /proc/task_diag patchset.
> >
> >
> > PIDMAP(2)                  Linux Programmer's Manual                 PIDMAP(2)
> >
> > NAME
> >        pidmap - get allocated PIDs
> >
> > SYNOPSIS
> >        long pidmap(pid_t pid, int *pids, unsigned int count , unsigned int start, int flags);
> 
> I think we will seriously regret a syscall that does this.  Djalal is
> working on fixing the turd that is hidepid, and this syscall is
> basically incompatible with ever fixing hidepids.  I think that, to
> make it less regrettable, it needs to take an fd to a proc mount as a
> parameter.  This makes me wonder why it's a syscall at all -- why not
> just create a new file like /proc/pids?

See reply to fdmap(2).

pidmap(2) is indeed more complex case exactly because of
pid/tgid/tid/everything else + pidnamespaces + ->hide_pid.
However the problem remains: query task tree without all the bullshit.
C/R people succumbed with /proc/*/children, it was a mistake IMO.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2 v2] fdmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-24 22:10 +0200
  [PATCH v2 2/2] pidmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-24 22:10 +0200
    Re: [PATCH v2 2/2] pidmap(2) Andy Lutomirski <luto@amacapital.net> - 2017-09-24 23:30 +0200
      Re: [PATCH v2 2/2] pidmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-26 20:50 +0200
        Re: [PATCH v2 2/2] pidmap(2) Andy Lutomirski <luto@amacapital.net> - 2017-09-27 17:10 +0200
    Re: [PATCH v2 2/2] pidmap(2) "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2017-09-25 09:50 +0200
    Re: [PATCH v2 2/2] pidmap(2) Djalal Harouni <tixxdz@gmail.com> - 2017-09-25 12:50 +0200
    Re: [PATCH v2 2/2] pidmap(2) kbuild test robot <lkp@intel.com> - 2017-09-26 07:50 +0200
  Re: [PATCH 1/2 v2] fdmap(2) Andy Lutomirski <luto@amacapital.net> - 2017-09-24 23:40 +0200
    Re: [PATCH 1/2 v2] fdmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-26 20:50 +0200
  Re: [PATCH 1/2 v2] fdmap(2) "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2017-09-25 09:50 +0200
    Re: [PATCH 1/2 v2] fdmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-26 21:10 +0200
      Re: [PATCH 1/2 v2] fdmap(2) Andy Lutomirski <luto@amacapital.net> - 2017-09-27 17:10 +0200
        Re: [PATCH 1/2 v2] fdmap(2) "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2017-09-28 09:30 +0200
          Re: [PATCH 1/2 v2] fdmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-28 13:00 +0200
            Re: [PATCH 1/2 v2] fdmap(2) Andy Lutomirski <luto@kernel.org> - 2017-09-28 17:10 +0200
        Re: [PATCH 1/2 v2] fdmap(2) Alexey Dobriyan <adobriyan@gmail.com> - 2017-09-28 12:20 +0200
  Re: [PATCH 1/2 v2] fdmap(2) kbuild test robot <lkp@intel.com> - 2017-09-26 06:30 +0200

csiph-web