linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Namhyung Kim <namhyung@kernel.org>
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 8/9] perf buildid-cache: add ability to add kcore to the cache
Date: Tue, 08 Oct 2013 11:05:37 +0300	[thread overview]
Message-ID: <5253BCD1.6080606@intel.com> (raw)
In-Reply-To: <87k3hoky4x.fsf@sejong.aot.lge.com>

On 08/10/13 10:41, Namhyung Kim wrote:
> On Mon,  7 Oct 2013 09:50:17 +0300, Adrian Hunter wrote:
>> kcore can be used to view the running kernel object code.
>> However, kcore changes as modules are loaded and unloaded,
>> and when the kernel decides to modify its own code.
>> Consequently it is useful to create a copy of kcore at a
>> particular time.  Unlike vmlinux, kcore is not unique
>> for a given build-id.  And in addition, the kallsyms
>> and modules files are also needed.  The tool therefore
>> creates a directory:
>>
>> 	~/.debug/[kernel.kcore]/<build-id>/<YYYYmmddHHMMSShh>
>>
>> which contains: kcore, kallsyms and modules.
> 
> Hmm..  I think the problem is that the kallsyms and kcore also have
> module information and the build-id of kernel can identify the core
> kernel part only.  So why not splitting modules from kcore and kallsyms?
> 
> As the modules have their own build-id, we can extract module info from
> kcore and kallsyms and put them under ~/.debug/[module]/<build-id>.
> While at it, we can even synthesize symbol table and inject it into the
> module kcore and get rid of the module kallsyms file.
> 
> This way, we can identify all binaries using build-id only, no?

No.

kcore doesn't just give the module object code - it gives it
linked in to the kernel.  Unless you have the modules at the same
addresses the linking doesn't match what you traced.

> 
>>
>> Note that the copied kcore contains only code sections.
>> See the kcore_copy() function for how that is determined.
>>
>> The tool will not make additional copies of kcore if there
>> is already one with the same modules at the same addresses.
>>
>> Currently, perf tools will not look for kcore in the cache.
>> That is addressed in another patch.
>>
> [SNIP]
> 
>> +static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
>> +{
>> +	char root_dir[PATH_MAX];
>> +	char notes[PATH_MAX];
>> +	u8 build_id[BUILD_ID_SIZE];
>> +	char *p;
>> +
>> +	strlcpy(root_dir, proc_dir, sizeof(root_dir));
>> +
>> +	p = strrchr(root_dir, '/');
>> +	if (!p)
>> +		return -1;
>> +	*p = '\0';
>> +
>> +	snprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir);
> 
> Please use scnprintf() rather than snprintf().  I can see them in other
> places (and on other patches) too.

OK

> 
> Thanks,
> Namhyung
> 
>> +
>> +	if (sysfs__read_build_id(notes, build_id, sizeof(build_id)))
>> +		return -1;
>> +
>> +	build_id__sprintf(build_id, sizeof(build_id), sbuildid);
>> +
>> +	return 0;
>> +}
> 
> 


  reply	other threads:[~2013-10-08  8:06 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
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 [this message]
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=5253BCD1.6080606@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --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=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).