Re: [RFC PATCH 0/5] Introduce /proc/all/ to gather stats from all processes

Greg KH
2020-08-10T15:41:31Z

On Tue, Aug 11, 2020 at 01:27:00AM +1000, Eugene Lubarsky wrote:
> On Mon, 10 Aug 2020 17:04:53 +0200
> Greg KH <gregkh@linuxfoundation.org> wrote:
> > How many syscalls does this save on?
> >
> > Perhaps you want my proposed readfile(2) syscall:
> > https://lore.kernel.org/r/20200704140250.423345-1-gregkh@linuxfoundation.org
> > to help out with things like this? :)
>
> The proposed readfile sounds great and would help, but if there are
> 1000 processes wouldn't that require 1000 readfile calls to read their
> proc files?

Yes, but that should be better than 1000 open, 1000 read, and then 1000
close calls, right? :)

> With something like this the stats for 1000 processes could be
> retrieved with an open, a few reads and a close.

And have you benchmarked any of this? Try working with the common tools
that want this information and see if it actually is noticeable (hint, I
have been doing that with the readfile work and it's surprising what the
results are in places...)

>
> >
> > > The proposed files in this proof-of-concept patch set are:
> > >
> > > * /proc/all/stat
> >
> > I think the problem will be defining "all" in the case of the specific
> > namespace you are dealing with, right? How will this handle all of
> > those issues properly for all of these different statisics?
> >
>
> Currently I'm trying to re-use the existing code in fs/proc that
> controls which PIDs are visible, but may well be missing something..

Try it out and see if it works correctly. And pid namespaces are not
the only thing these days from what I call :)

thanks,

greg k-h