Re: [PATCH] speed up /proc/pid/stat, statm

From: Eric Dumazet
Date: Wed Feb 01 2012 - 00:54:46 EST

Le mercredi 01 fÃvrier 2012 Ã 08:55 +0900, KAMEZAWA Hiroyuki a Ãcrit :

> seq_xxxx functions set m->count == m->size when it finds possible buffer overflow.
> If m->count == m->size after ->show(), buffer will be freed and twice size buffer
> will be re-allocated, and retry.
> If we don't set m->count == m->size here, following seq_putc() will succeed and
> we'll see corrupted outputs.

I suppose we could define a self documented helper

void seq_overflow(struct seq_file *seq)
seq->count = seq->size;

Or if we were counting the approximate number of missing bytes, we could
avoid some iterations of the "double size buffer".

(letting seq->count going above seq->size, but not allowing buffer
overflow of course !)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at