public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Erik Andersen <andersen@codepoet.org>
To: Kai Henningsen <kaih@khms.westfalen.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: ps performance sucks (was Re: dcache_rcu [performance results])
Date: Tue, 5 Nov 2002 14:33:43 -0700	[thread overview]
Message-ID: <20021105213342.GA23168@codepoet.org> (raw)
In-Reply-To: <8$GqvaL1w-B@khms.westfalen.de>

On Tue Nov 05, 2002 at 09:57:00PM +0200, Kai Henningsen wrote:
> mbligh@aracnet.com (Martin J. Bligh)  wrote on 04.11.02 in <1118170000.1036458859@flay>:
> 
> > I had a very brief think about this at the weekend, seeing
> > if I could make a big melting pot /proc/psinfo file that did
> > seqfile and read everything out in one go, using seq_file
> > internally to interate over the tasklist. The most obvious
> > problem that sprung to mind seems to be the tasklist locking -
> > you obviously can't just hold a lock over the whole thing.
> 
> Well, one thing i to make certain you can actually do it with one or two  
> system calls. Say, one system call to figure out how big a buffer is  
> necessary (essentially, #tasks*size), then one read with a suitably-sized  
> buffer. Then have a loop in the kernel that drops the lock as often as  
> necessary, and otherwise puts it all in the buffer in one go. (If the  
> #tasks grows too fast so it overruns the buffer even with some slack given  
> in advance, tough, have a useful return code to indicate that and let ps  
> retry.)
> 
> I briefly thought about mmap, but I don't think that actually buys  
> anything.

Once again, reminds me of my /dev/ps driver, which had the
following ioctls:

#define DEVPS_GET_NUM_PIDS     0xeba1 /* Get a list of all PIDs */ 
#define DEVPS_GET_PID_LIST     0xeba2 /* Get a list of all PIDs */ 
#define DEVPS_GET_PID_INFO     0xeba3 /* Get info about a specific PID */
#define DEVPS_GET_CURRENT_PID  0xeba4 /* Get the current PID */

So a user spave ps app would call DEVPS_GET_NUM_PIDS to find out
how many processes there are, then it would allocate some memory
(and would allocate a some extra just in case some new processes 
were to start up, the kernel would truncate things if we gave it
too little space) .  Then ps would grab the pid list by calling 
the DEVPS_GET_PID_LIST ioctl, and then for each item in the list
it would call DEVPS_GET_PID_INFO.  Assuming that call was
successful, ps would print out a line of output and move on to
the next pid in the list.

The idea need not be implemented without using ioctl and without
using binary structures (which were the things Linus objected to)

The same thing could be easily done using flat ascii...

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

  reply	other threads:[~2002-11-05 21:27 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-30 10:49 [PATCH 2.5.44] dcache_rcu Maneesh Soni
2002-10-31 10:53 ` dcache_rcu [performance results] Dipankar Sarma
2002-11-02  1:36   ` Andrew Morton
2002-11-02  9:13     ` Dipankar Sarma
2002-11-04 17:29       ` Martin J. Bligh
2002-11-05  0:00         ` jw schultz
2002-11-05  1:14           ` ps performance sucks (was Re: dcache_rcu [performance results]) Martin J. Bligh
2002-11-05  3:57             ` Werner Almesberger
2002-11-05  4:42               ` Erik Andersen
2002-11-05  5:44                 ` Martin J. Bligh
2002-11-05  5:59                   ` Alexander Viro
2002-11-05  6:05                     ` Martin J. Bligh
2002-11-05  6:15                     ` Robert Love
2002-11-05  6:13                   ` Erik Andersen
2002-11-05  6:14                 ` Werner Almesberger
2002-11-05  4:26             ` jw schultz
2002-11-05  5:51               ` Martin J. Bligh
2002-11-05 19:57             ` Kai Henningsen
2002-11-05 21:33               ` Erik Andersen [this message]
2002-11-05 22:09             ` Karim Yaghmour
     [not found] <993103655@toto.iv>
2002-11-05 22:49 ` Peter Chubb
2002-11-06  0:06   ` Martin J. Bligh
2002-11-05 23:16     ` bert hubert
2002-11-06  0:57       ` Martin J. Bligh
2002-11-06  0:10         ` bert hubert
2002-11-06  1:23           ` Martin J. Bligh
2002-11-06  0:34             ` Alexander Viro
2002-11-07 12:06               ` Rusty Russell
2002-11-08  3:57                 ` William Lee Irwin III
2002-11-08  4:17                   ` Robert Love
2002-11-08  4:27                     ` Daniel Jacobowitz
2002-11-08  4:29                     ` William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021105213342.GA23168@codepoet.org \
    --to=andersen@codepoet.org \
    --cc=kaih@khms.westfalen.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox