Re: sched_debug / traverse allocation failures.

From: Al Viro
Date: Tue Nov 06 2012 - 17:33:24 EST


On Tue, Nov 06, 2012 at 03:49:47PM -0500, Dave Jones wrote:

> I added some instrumentation to traverse, and it appears that the /proc file
> in question is 'sched_debug'.
>
> Most the time this is quite small, but can grow to large lengths it seems,
> which when we're under memory fragmentation results in the spew above.
>
> >From my reading of the code, it doesn't actually use the seq_operations,
> to print out things record-at-a-time, but just dumps everything
> in its ->open routine.

Not ->open(), first ->read(), actually. I'd suggest turning that
sucker into a saner iterator, though - it spews a smallish header
followed by a set of per-CPU entries, so I'd probably start with
something like
static void *c_start(struct seq_file *m, loff_t *pos)
{
unsigned long n = *pos;
if (n == 0)
return (void *)1; /* header */
n--;
/* find the first online CPU >= requested position */
if (n > 0)
n = cpumask_next(n - 1, cpu_online_mask);
else
n = cpumask_first(cpu_online_mask);
*pos = n + 1;
if (n < nr_cpu_ids)
return (void *)(unsigned long)(n + 2); /* CPU #n */
return NULL; /* EOF */
}

static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
(*pos)++;
return c_start(m, pos);
}

static int c_show(struct seq_file *m, void *v)
{
if (v == (void *)1) {
print header
} else {
unsigned long cpu = (unsigned long)v - 2;
print for that cpu
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/