lkml.org 
[lkml]   [2007]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
Subject2.6.23.rc5: Problem with procfs -- schedstat
From
Hello everybody,

I found a problem in /proc/self/schedstat: a simple "cat" can give "wrong"
results.

        /proc# cat self/schedstat
        91117 26027 2
        /proc# cat self/schedstat
        90691 27872 2
        /proc# cat self/schedstat
        995483 15675 3

        /proc# cat self/schedstat
        478050 124422 3
        /proc# cat self/schedstat
        87912 21539 2
        /proc# cat self/schedstat
        81382 19722 2
        /proc# cat self/schedstat
        87999 119699 2
        /proc# cat self/schedstat
        87192 25990 2
        /proc# cat self/schedstat
        80114 15113 2
        3
        /proc# cat self/schedstat
        93064 28817 2
        /proc# cat self/schedstat
        90834 22816 2
        /proc# cat self/schedstat
        87806 37581 2
        /proc# cat self/schedstat
        80187 20283 2
        3
        /proc#

Please note the extra newline and possible other digits.

A strace reveals that cat does
        open("self/schedstat", O_RDONLY|O_LARGEFILE) = 3
        fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
        read(3, "946533 98256 64\n", 4096)      = 16
        write(1, "946533 98256 64\n", 16)       = 16
        read(3, "8\n", 4096)                    = 2
        write(1, "8\n", 2)                      = 2
        read(3, "", 4096)                       = 0
        close(3)                                = 0
        close(1)                                = 0
        exit_group(0)                           = ?

The simple fix would be to change the format in proc_pid_schedstat(), so
that it always returns the same number of bytes.

Or proc_info_read() gets changed - if less bytes than wanted (by userspace)
were returned, mark that file for returning EOF next time. But I fear that
that might break other entries that rely on getting repeatedly called.


Regards,

Phil


--
Versioning your /etc, /home or even your whole installation?
Try fsvs (fsvs.tigris.org)!
-
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: 2007-09-05 07:19    [W:0.022 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site