From: Namhyung Kim <namhyung@kernel.org>
To: Cody P Schafer <cody@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
Matt Hellsley <matthltc@us.ibm.com>,
David Hansen <dave@linux.vnet.ibm.com>
Subject: Re: [PATCH 02/16] perf symbol: remove unused 'end' arg in kallsyms parse cb
Date: Fri, 10 Aug 2012 11:39:27 +0900 [thread overview]
Message-ID: <87k3x7wjvk.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1344550721-21024-3-git-send-email-cody@linux.vnet.ibm.com> (Cody P. Schafer's message of "Thu, 9 Aug 2012 15:18:27 -0700")
Hi, Cody
On Thu, 9 Aug 2012 15:18:27 -0700, Cody P. Schafer wrote:
> kallsyms__parse() takes a callback that is called on every discovered
> symbol. As /proc/kallsyms does not supply symbol sizes, the callback was
> simply called with end=start, faking the symbol size to 1.
>
> All of the callbacks (there are 2) used in calls to kallsyms__parse()
> are _only_ used as callbacks for kallsyms__parse().
>
> Given that kallsyms__parse() lacks real information about what
> end/length should be, don't make up a length in kallsyms__parse().
> Instead have the callbacks handle guessing the length.
>
> Also relocate a comment regarding symbol creation to the callback which
> does symbol creation (kallsyms__parse() is not in general used to create
> symbols).
>
> Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
> ---
> tools/perf/util/event.c | 2 +-
> tools/perf/util/symbol.c | 21 ++++++++++-----------
> tools/perf/util/symbol.h | 2 +-
> 3 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 2a6f33c..3a0f1a5 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -412,7 +412,7 @@ struct process_symbol_args {
> };
>
> static int find_symbol_cb(void *arg, const char *name, char type,
> - u64 start, u64 end __used)
> + u64 start)
> {
> struct process_symbol_args *args = arg;
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index df4736d..b2f7597 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -574,7 +574,7 @@ size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp)
>
> int kallsyms__parse(const char *filename, void *arg,
> int (*process_symbol)(void *arg, const char *name,
> - char type, u64 start, u64 end))
> + char type, u64 start))
> {
> char *line = NULL;
> size_t n;
> @@ -614,13 +614,8 @@ int kallsyms__parse(const char *filename, void *arg,
> break;
> }
>
> - /*
> - * module symbols are not sorted so we add all
> - * symbols, setting length to 1, and rely on
> - * symbols__fixup_end() to fix it up.
> - */
> err = process_symbol(arg, symbol_name,
> - symbol_type, start, start);
> + symbol_type, start);
> if (err)
> break;
> }
> @@ -647,7 +642,7 @@ static u8 kallsyms2elf_type(char type)
> }
>
> static int map__process_kallsym_symbol(void *arg, const char *name,
> - char type, u64 start, u64 end)
> + char type, u64 start)
> {
> struct symbol *sym;
> struct process_kallsyms_args *a = arg;
> @@ -656,8 +651,12 @@ static int map__process_kallsym_symbol(void *arg, const char *name,
> if (!symbol_type__is_a(type, a->map->type))
> return 0;
>
> - sym = symbol__new(start, end - start + 1,
> - kallsyms2elf_type(type), name);
> + /*
> + * module symbols are not sorted so we add all
> + * symbols, setting length to 1, and rely on
> + * symbols__fixup_end() to fix it up.
> + */
> + sym = symbol__new(start, 1, kallsyms2elf_type(type), name);
I guess that length of 1 effectively same as zero length in this case
since we end up calling symbols__fixup_end. The 'end - start + 1' part
looks like a leftover from previous change and not needed anymore -
KSYM_NAME_LEN check too, IMHO - so I suggest using 0 length to make it
clear.
And it seems you need to rebase the series onto Arnaldo's current
perf/core branch which separates out ELF bits to symbol-elf.c.
Thanks,
Namhyung
> if (sym == NULL)
> return -ENOMEM;
> /*
> @@ -2528,7 +2527,7 @@ struct process_args {
> };
>
> static int symbol__in_kernel(void *arg, const char *name,
> - char type __used, u64 start, u64 end __used)
> + char type __used, u64 start)
> {
> struct process_args *args = arg;
>
> diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
> index 1fe733a..c8ec1d7 100644
> --- a/tools/perf/util/symbol.h
> +++ b/tools/perf/util/symbol.h
> @@ -297,7 +297,7 @@ bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
> int build_id__sprintf(const u8 *build_id, int len, char *bf);
> int kallsyms__parse(const char *filename, void *arg,
> int (*process_symbol)(void *arg, const char *name,
> - char type, u64 start, u64 end));
> + char type, u64 start));
>
> void machine__destroy_kernel_maps(struct machine *machine);
> int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
next prev parent reply other threads:[~2012-08-10 2:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 22:18 [PATCH 0/16] perf: various symbol resolution fixes, including .opd section use Cody P Schafer
2012-08-09 22:18 ` [PATCH 01/16] perf symbol: correct comment wrt kallsyms loading Cody P Schafer
2012-08-09 22:18 ` [PATCH 02/16] perf symbol: remove unused 'end' arg in kallsyms parse cb Cody P Schafer
2012-08-10 2:39 ` Namhyung Kim [this message]
2012-08-10 17:11 ` Cody P Schafer
2012-08-09 22:18 ` [PATCH 03/16] perf symbol: only un-prelink non-zero symbols Cody P Schafer
2012-08-09 22:18 ` [PATCH 04/16] perf utils: remove unused function map__objdump_2ip Cody P Schafer
2012-08-09 22:18 ` [PATCH 05/16] perf symbol: don't try to synthesize plt without dynstr Cody P Schafer
2012-08-09 22:18 ` [PATCH 06/16] perf symbol: remove unneeded call to dso__set_long_name() Cody P Schafer
2012-08-09 22:18 ` [PATCH 07/16] perf symbol: symplify out_fixup in kernel syms loading Cody P Schafer
2012-08-09 22:18 ` [PATCH 08/16] perf symbol: only set vmlinux longname & mark loaded if really loaded Cody P Schafer
2012-08-09 22:18 ` [PATCH 09/16] perf symbol: avoid segfault in elf_strptr Cody P Schafer
2012-08-09 22:18 ` [PATCH 10/16] perf symbol: track symtab_type of vmlinux Cody P Schafer
2012-08-09 22:18 ` [PATCH 11/16] perf symbol: introduce symsrc structure Cody P Schafer
2012-08-09 22:18 ` [PATCH 12/16] perf symbol: set symtab_type in dso__load_sym Cody P Schafer
2012-08-09 22:18 ` [PATCH 13/16] perf symbol: switch dso__synthesize_plt_symbols() to use symsrc Cody P Schafer
2012-08-09 22:18 ` [PATCH 14/16] perf symbol: factor want_symtab out of dso__load_sym() Cody P Schafer
2012-08-09 22:18 ` [PATCH 15/16] perf symbol: convert dso__load_syms to take 2 symsrc's Cody P Schafer
2012-08-09 22:18 ` [PATCH 16/16] perf symbol: use both runtime and debug images Cody P Schafer
2012-08-10 22:22 [PATCH v2 00/16] perf: various symbol resolution fixes, including .opd section use Cody P Schafer
2012-08-10 22:22 ` [PATCH 02/16] perf symbol: remove unused 'end' arg in kallsyms parse cb Cody P Schafer
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=87k3x7wjvk.fsf@sejong.aot.lge.com \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=cody@linux.vnet.ibm.com \
--cc=dave@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthltc@us.ibm.com \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=sukadev@linux.vnet.ibm.com \
/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
Powered by JetHome