Messages in this thread | | | Date | Fri, 23 Jul 1999 16:44:58 +0200 | From | Andi Kleen <> | Subject | Re: Measured overhead of timer interrupts |
| |
On Fri, Jul 23, 1999 at 05:16:45AM +0200, Albert D. Cahalan wrote: > > Andi Kleen writes: > > On Thu, Jul 22, 1999 at 09:12:22PM +0200, Khimenko Victor wrote: > >> In <19990722171109.A1783@fred.muc.de> Andi Kleen (ak@muc.de) wrote: > >>> On Thu, Jul 22, 1999 at 05:02:14PM +0200, Ingo Molnar wrote: > >>>> On 22 Jul 1999, Andi Kleen wrote: > > >>>>> It is a kernel bug, HZ is not exported. Actually two, > >>>>> because none of the /proc should have used it as units, > >>>>> but that cannot be fixed anymore. > > One value alone is poor. We ought to have: > > CLOCKS_HZ for the one ugly system call > PROC_HZ for general /proc output > PROCNET_HZ for /proc/net specifically > TRUE_HZ what the kernel really uses, even if not periodic > > >> /proc interface are in permanent change. We should keep it consistent > >> in one stable kernel series but I see no reason to keep it consistent > >> between major kernel updates: quite a lot of things will be changed anyway. > > > > This is not really true. There are new columns or lines added to /proc > > files, but old ones are not changes, and correctly writen /proc parsers > > should not break (unfortunately there are lots of incorrectly writen > > proc parser around..) > > I know this is not true. I wrote the new ps. (prepare for rant) > There is no way to write a parser that will survive all of: > > 1. new columns
It is handleable.
You wrote the code to parse:
Bla blub bli 1 2 3
the new kernel has
Bla blub blo bli 1 2 5 3
So in perl code (for compactness, C is only a bit wordier, untested, I'm sure a perl guru could write it in less lines):
%known_titles = ("Bla" => -1, "blub" => -1, "bli" => -1);
# match known titles to column numbers. $titleline = <PROCFH>; @fields = split(/\s+/,$titleline); $column = 0; foreach (@fields) { if ($known_titles{$_}) { $known_titles{$_} = $column; } $column++; } # handling for missing columns is easy to add here.
#now read /proc file while(<PROCFH>) { @fields = split(/\s+/); $bla = $fields[$known_titles{"Bla"}]; $bli = $fields[$known_titles{"bli"}]; $blub = $fields[$known_titles{"blub"}]; # process them.. }
> 2. new spelling for keywords or row names
That is simply a bug and should never happen.
> 3. new rows
New rows are easy. You have to deal with them all the times.
> 4. apparent keyword columns that suddenly get whitespace
???
-Andi -- This is like TV. I don't like TV.
- 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/
| |