Re: atomic ps [was: vm locking question]

From: Peter T. Breuer (ptb@it.uc3m.es)
Date: Thu Apr 13 2000 - 06:54:26 EST


"A month of sundays ago Borislav Deianov wrote:"
> On Wed, Apr 12, 2000 at 11:51:25PM +0100, Alan Cox wrote:
> > Why do you want an atomic ps - nobody else has one
>
> solves the following problem: there currently is no way to atomically
> get more than 3K out of /proc, even if it's all in the same file. I

You are mistaken on the latter point. There is no difficulty - once
you unravel the obscurantist coding. My version of the proconfig patch
commonly produces 12K of output from /proc/config, for example.

This is the code that has to be used ...

static int
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
get_proc_config(char *page, char **start, off_t offset, int len, int * eof, void *data)
#else
get_proc_config (char *page, char **start, off_t offset, int len, int unused)
#endif
{
    int count = 0; // no. chars output

    // bsearch internal table until we locate the internal offset
    int i = proc_config_find (offset);

    // now print as much as we can from there on
    count = print_entries (page, i, len);

    // trick for multi page output from proc
    *start = (char *) count;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
    if (count <= 0)
        *eof = 1;
#endif
    return count;
}
 

That's all. I agree that the proc code is obscure. Nobody has realized
that it works. That's why everyone thinks it doesn't. I've meant to
submit a patch to clean it up for a long while.

> have that problem with the fair scheduler. Rusty Russell once
> complained that firewall counters in 2.2 also suffer from this.

Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:20 EST