On Fri, 20 Jan 2012 16:59:24 +0100
Eric Dumazet<eric.dumazet@xxxxxxxxx> wrote:
On a typical 16 cpus machine, "cat /proc/stat" gives more than 4096
bytes, and is slow :
# strace -T -o /tmp/STRACE cat /proc/stat | wc -c
5826
# grep "cpu " /tmp/STRACE
read(0, "cpu 1949310 19 2144714 12117253"..., 32768) = 5826<0.001504>
Thats partly because show_stat() must be called twice since initial
buffer size is too small (4096 bytes for less than 32 possible cpus)
Fix this by :
1) Taking into account nr_irqs in the initial buffer sizing.
2) Using ksize() to allow better filling of initial buffer.
3) Reduce the bloat on "intr ..." line :
Dont output trailing " 0" values at the end of irq range.
An alternative to 1) would be to remember the largest m->count reached
in show_stat()
nice catch. But how about using usual seq_file rather than single_open() ?
I just don't like multi-page buffer for this small file...very much.
A rough patch here, maybe optimization will not be enough. (IOW, this may be slow.)