Re: + page-owner-tracking.patch added to -mm tree

From: Eduard - Gabriel Munteanu
Date: Fri Apr 03 2009 - 00:21:17 EST


On Thu, Apr 02, 2009 at 10:12:11AM +0300, Pekka Enberg wrote:
> On Wed, 2009-04-01 at 17:22 +0200, Ingo Molnar wrote:
> > > +kmemtrace_print_page_alloc_user(struct trace_iterator *iter,
> > > + struct kmemtrace_page_alloc_entry *entry)
> > > +{
> > > + struct kmemtrace_user_event_page_alloc *ev_alloc;
> > > + struct trace_seq *s = &iter->seq;
> > > + struct kmemtrace_user_event *ev;
> > > +
> > > + ev = trace_seq_reserve(s, sizeof(*ev));
> > > + if (!ev)
> > > + return TRACE_TYPE_PARTIAL_LINE;
> > > +
> > > + ev->event_id = KMEMTRACE_USER_PAGE_ALLOC;
> > > + ev->type_id = entry->type_id;
> > > + ev->event_size = sizeof(*ev) + sizeof(*ev_alloc);
> > > + ev->cpu = iter->cpu;
> > > + ev->timestamp = iter->ts;
> > > + ev->call_site = 0ULL; /* FIXME */
> > > + ev->ptr = 0ULL; /* FIXME */
> >
> > Here we could call save_stack_trace(), in a way like this, to save
> > up to 8 entries of the allocation back-trace:
>
> The example code compiled as-is so here's an updated patch! :-) We
> should probably do stack traces for _all_ events like you suggested but
> that's a bigger ABI change so I did it only for the new page allocation
> event.

I've thought about exporting a stack trace instead of a call-site
pointer, sounds nice. But I figure we should leave ev->call_site filled
as before, it's useful in some cases to show who is the intended caller,
e.g. caller-tracking variants of kmalloc.

It could also work out-of-the-box with the existing kmemtrace, since we
consume and ignore the remaining ev->event_size bytes we don't know how to
interpret. Moreover, events can hold 2^16 bytes which is enough to
export more than 8 previous frames.

One thing I'm not sure about this patch is whether it manages to record
an allocation only once, i.e. does it log a single event when/if the slab
allocator requests pages? Some time ago I sent a patch adding GFP_NOTRACE
to gfp.h, but was rejected. Maybe this could be a way out of the mess.

(GFP_NOTRACE would also allow us to log "backend" allocations easily and
treat them separately, for the record, or simply filter them out.)


Cheers,
Eduard

--
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/