lkml.org 
[lkml]   [2002]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC][PATCH] iowait statistics
Date
On 15 May 2002 17:00, Rik van Riel wrote:
> > $ top
> > fscanf failed on /proc/stat for cpu 1
>
> Doh, take a look at top.c around line 1460:
>
> for(i = 0; i < nr_cpu; i++) {
> if(fscanf(file, "cpu%*d %d %d %d %d\n",
> &u_ticks, &n_ticks, &s_ticks, &i_ticks) != 4) {
> fprintf(stderr, "fscanf failed on /proc/stat for cpu
> %d\n", i);
>
> It would have been ok (like vmstat) if it didn't expect the \n
> after the fourth number ;/
>
> Oh well, time for another procps patch ;)

While you're at it:

printf("CPU states:"
" %2ld.%ld%% user, %2ld.%ld%% system,"
" %2ld.%ld%% nice, %2ld.%ld%% idle",
user_ticks / 10UL, user_ticks % 10UL,
system_ticks / 10UL, system_ticks % 10UL,
nice_ticks / 10UL, nice_ticks % 10UL,
idle_ticks / 10UL, idle_ticks % 10UL);

" %2ld" -> "%3ld" will make 100.00% look much nicer:
Current code: " 34.56%" " 100.00%" (i.e. 100% is one char wider!)
New code: " 34.56%" "100.00%"

Same here:

printf ("CPU%d states: %2d.%-d%% user, %2d.%-d%% system,"
" %2d.%-d%% nice, %2d.%-d%% idle",
cpumap,

Another thing: in sight of moves towards 64bit jiffies isn't it wise to
use unsigned long long (or explicit u64) for all these numbers?
--
vda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.044 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site