lkml.org 
[lkml]   [2012]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] speed up /proc/pid/stat, statm
From
Date
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@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: 2012-02-01 06:57    [from the cache]
©2003-2011 Jasper Spaans