All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH V4 2/9] perf tools: validate kcore module addresses
Date: Tue, 08 Oct 2013 16:18:02 +0900	[thread overview]
Message-ID: <87ob70kz85.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1381128618-22721-3-git-send-email-adrian.hunter@intel.com> (Adrian Hunter's message of "Mon, 7 Oct 2013 09:50:11 +0300")

Hi Adrian,

On Mon,  7 Oct 2013 09:50:11 +0300, Adrian Hunter wrote:
> Before using kcore we need to check that modules are
> in memory at the same addresses that they were when
> data was recorded.
>
> This is done because, while we could remap symbols
> to different addresses, the object code linkages
> would still be different which would provide an
> erroneous view of the object code.

[SNIP]
>  
> -static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
> +static void add_module(struct module_info *mi, struct rb_root *modules)
>  {
> -	struct kcore_mapfn_data *md = data;
> -	struct map *map;
> +	struct rb_node **p = &modules->rb_node;
> +	struct rb_node *parent = NULL;
> +	struct module_info *m;
>  
> -	map = map__new2(start, md->dso, md->type);
> -	if (map == NULL)
> +	while (*p != NULL) {
> +		parent = *p;
> +		m = rb_entry(parent, struct module_info, rb_node);
> +		if (strcmp(mi->name, m->name) < 0)
> +			p = &(*p)->rb_left;
> +		else
> +			p = &(*p)->rb_right;
> +	}
> +	rb_link_node(&mi->rb_node, parent, p);
> +	rb_insert_color(&mi->rb_node, modules);
> +}

[SNIP]

> +static int __read_proc_modules(void *arg, const char *name, u64 start)
> +{
> +	struct rb_root *modules = arg;
> +	struct module_info *mi;
> +
> +	mi = zalloc(sizeof(struct module_info));
> +	if (!mi)
>  		return -ENOMEM;
>  
> -	map->end = map->start + len;
> -	map->pgoff = pgoff;
> +	mi->name = strdup(name);
> +	mi->start = start;
>  
> -	list_add(&map->node, &md->maps);
> +	add_module(mi, modules);
> +
> +	if (!mi->name)
> +		return -ENOMEM;

Why did you add the mi if it failed to allocate name?  I guess it'd
crash since the add_module() uses mi->name for strcmp().

Thanks,
Namhyung

> +
> +	return 0;
> +}

  reply	other threads:[~2013-10-08  7:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-07  6:50 [PATCH V4 0/9] perf tools: kcore improvements Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 1/9] perf tools: make a separate function to parse /proc/modules Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 2/9] perf tools: validate kcore module addresses Adrian Hunter
2013-10-08  7:18   ` Namhyung Kim [this message]
2013-10-07  6:50 ` [PATCH V4 3/9] perf tools: workaround objdump difficulties with kcore Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 4/9] perf tools: add map__find_other_map_symbol() Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 5/9] perf tools: fix annotate_browser__callq() Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 6/9] perf tools: find kcore symbols on other maps Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 7/9] perf tools: add copyfile_mode() Adrian Hunter
2013-10-07  6:50 ` [PATCH V4 8/9] perf buildid-cache: add ability to add kcore to the cache Adrian Hunter
2013-10-08  7:41   ` Namhyung Kim
2013-10-08  8:05     ` Adrian Hunter
2013-10-08  8:34       ` Namhyung Kim
2013-10-07  6:50 ` [PATCH V4 9/9] perf tools: add ability to find kcore in build-id cache Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ob70kz85.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.