Re: + page-owner-tracking.patch added to -mm tree
From: Ingo Molnar
Date:  Wed Apr 01 2009 - 11:25:28 EST
* Pekka Enberg <penberg@xxxxxxxxxxxxxx> wrote:
> On Wed, 2009-04-01 at 15:49 +0200, Ingo Molnar wrote:
> > And this info could be added to that, and it would sure be nice to 
> > hook it up to kmemtrace primarily, which does a lot of similar 
> > looking work in the slab space. (but Eduard and Pekka will know how 
> > feasible/interesting this is to them.)
> 
> Yup, makes sense to me. Something like this is probably a good 
> starting point for a proper patch.
looks like an excellent starting point.
> +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:
#define NR_ENTRIES		8
struct kmemtrace_user_event {
...
        unsigned long		entries[NR_ENTRIES];
...
};
        struct stack_trace trace;
        trace.nr_entries	= 0;
        trace.max_entries	= NR_ENTRIES;
        trace.entries		= ev->entries;
        trace.skip		= 2;
        save_stack_trace(&trace);
( the '2' for skip will skip the useless tracer-internal backtrace 
  bits. )
ftrace has built-in stacktrace capabilities as well - but they are 
not hooked up to the binary-tracing pathway yet - right Steve?
	Ingo
--
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/