linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 5/8] perf probe powerpc: Allow matching against dot symbols
Date: Thu, 12 Mar 2015 17:30:59 -0300	[thread overview]
Message-ID: <20150312203059.GG3550@kernel.org> (raw)
In-Reply-To: <062b1dbee6747d8013ea91d7020216969aefb128.1418654436.git.naveen.n.rao@linux.vnet.ibm.com>

Em Mon, Dec 15, 2014 at 08:20:35PM +0530, Naveen N. Rao escreveu:
> Allow perf probe to work on powerpc ABIv1 without the need to specify
> the leading dot '.' for functions. 'perf probe do_fork' works with this
> patch.
> 
> Introduce HAVE_ARCH_SYMBOL_HANDLING to indicate need for special
> handling of symbols. In this patch, we override probe_function_filter()
> on powerpc to account for dot symbols.

This one looks better, does arch specific stuff in tools/perf/arch,
good, some nits below.
 
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
> Changes from the previous patchset:
> Introduced arch helper to override the way probe function filter works.
> 
>  tools/perf/arch/powerpc/Makefile            |  1 +
>  tools/perf/arch/powerpc/util/sym-handling.c | 28 ++++++++++++++++++++++++++++
>  tools/perf/config/Makefile                  |  1 +
>  tools/perf/util/probe-event.c               | 10 +++++-----
>  tools/perf/util/probe-event.h               |  5 +++++
>  5 files changed, 40 insertions(+), 5 deletions(-)
>  create mode 100644 tools/perf/arch/powerpc/util/sym-handling.c
> 
> diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
> index 6f7782b..1c3d435 100644
> --- a/tools/perf/arch/powerpc/Makefile
> +++ b/tools/perf/arch/powerpc/Makefile
> @@ -3,4 +3,5 @@ PERF_HAVE_DWARF_REGS := 1
>  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
>  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/skip-callchain-idx.o
>  endif
> +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/sym-handling.o
>  LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
> diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
> new file mode 100644
> index 0000000..0a77825
> --- /dev/null
> +++ b/tools/perf/arch/powerpc/util/sym-handling.c
> @@ -0,0 +1,28 @@
> +/*
> + * Special symbol handling for PowerPC:
> + * - Handle dot symbols on ABIv1
> + *
> + * Copyright (C) 2014 Naveen N Rao, IBM Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +
> +#include "map.h"
> +#include "symbol.h"
> +#include "probe-event.h"
> +
> +int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
> +{
> +	if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) {
> +		if ((strcmp(looking_function_name, sym->name) == 0) ||
> +		    (sym->name[0] == '.' && looking_function_name[0] != '.' &&
> +		     strcmp(looking_function_name, sym->name+1) == 0)) {
> +			num_matched_functions++;
> +			return 0;
> +		}
> +	}
> +	return 1;
> +}
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index 5d4b039..35cf934 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -383,6 +383,7 @@ ifeq ($(ARCH),powerpc)
>    ifndef NO_DWARF
>      CFLAGS += -DHAVE_SKIP_CALLCHAIN_IDX
>    endif
> +  CFLAGS += -DHAVE_ARCH_SYMBOL_HANDLING


Dunno about this naming, looks too general: SYMBOL_HANDLING, but can't
come to some better one now, anyone?

>  endif
>  
>  ifndef NO_LIBUNWIND
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 74b7fef..7eb9b27 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -50,6 +50,8 @@
>  #define PERFPROBE_GROUP "probe"
>  
>  bool probe_event_dry_run;	/* Dry run flag */
> +char *looking_function_name;
> +int num_matched_functions;
>  
>  #define semantic_error(msg ...) pr_err("Semantic error :" msg)
>  
> @@ -2210,11 +2212,8 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
>  	return ret;
>  }
>  
> -static char *looking_function_name;
> -static int num_matched_functions;
> -
> -static int probe_function_filter(struct map *map __maybe_unused,
> -				      struct symbol *sym)
> +#ifndef HAVE_ARCH_SYMBOL_HANDLING
> +int probe_function_filter(struct map *map __maybe_unused, struct symbol *sym)
>  {
>  	if ((sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL) &&
>  	    strcmp(looking_function_name, sym->name) == 0) {
> @@ -2223,6 +2222,7 @@ static int probe_function_filter(struct map *map __maybe_unused,
>  	}
>  	return 1;
>  }
> +#endif /* HAVE_ARCH_SYMBOL_HANDLING */

Can't we do something like providing a weak function and let the linked
to its work? I guess we have cases like this in tools/ already. I.e. not
using the ifndef block. Minor nit tho.

>  
>  #define strdup_or_goto(str, label)	\
>  	({ char *__p = strdup(str); if (!__p) goto label; __p; })
> diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
> index e01e994..8564451 100644
> --- a/tools/perf/util/probe-event.h
> +++ b/tools/perf/util/probe-event.h
> @@ -7,6 +7,8 @@
>  #include "strfilter.h"
>  
>  extern bool probe_event_dry_run;
> +extern char *looking_function_name;
> +extern int num_matched_functions;

>  
>  /* kprobe-tracer and uprobe-tracer tracing point */
>  struct probe_trace_point {
> @@ -136,6 +138,9 @@ extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
>  extern int show_available_funcs(const char *module, struct strfilter *filter,
>  				bool user);
>  
> +extern int probe_function_filter(struct map *map __maybe_unused,
> +					struct symbol *sym);
> +

Please do not prefix function declarations with 'extern', even when we
have one just before, its not needed, patches removing the existing ones
would be accepted.

>  /* Maximum index number of event-name postfix */
>  #define MAX_EVENT_INDEX	1024
>  
> -- 
> 2.1.3

  reply	other threads:[~2015-03-12 20:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 14:50 [PATCHv2 0/8] Fix perf probe issues on powerpc Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 1/8] kprobes: Fix kallsyms lookup across powerpc ABIv1 and ABIv2 Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 2/8] perf probe: Improve detection of file/function name in the probe pattern Naveen N. Rao
2015-03-12 20:24   ` Arnaldo Carvalho de Melo
2015-03-12 20:25     ` Arnaldo Carvalho de Melo
2015-03-13  2:03     ` Ananth N Mavinakayanahalli
2015-03-13 11:20     ` Masami Hiramatsu
2015-04-27  5:05       ` Naveen N. Rao
2015-04-27  5:09       ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 3/8] perf probe powerpc: Fix symbol fixup issues due to ELF type Naveen N. Rao
2015-03-12 20:23   ` Arnaldo Carvalho de Melo
2015-04-27  5:06     ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 4/8] perf probe powerpc: Handle powerpc dot symbols Naveen N. Rao
2015-03-12 20:26   ` Arnaldo Carvalho de Melo
2014-12-15 14:50 ` [PATCHv2 5/8] perf probe powerpc: Allow matching against " Naveen N. Rao
2015-03-12 20:30   ` Arnaldo Carvalho de Melo [this message]
2015-04-27  5:08     ` Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 6/8] perf tools powerpc: Fix PPC64 ELF ABIv2 symbol decoding Naveen N. Rao
2015-03-12 20:35   ` Arnaldo Carvalho de Melo
2014-12-15 14:50 ` [PATCHv2 7/8] perf probe powerpc: Use DWARF info only if necessary Naveen N. Rao
2014-12-15 14:50 ` [PATCHv2 8/8] perf probe powerpc: Fixup function entry if using kallsyms lookup Naveen N. Rao
2015-03-12 20:37   ` Arnaldo Carvalho de Melo
2015-01-28  5:42 ` [PATCHv2 0/8] Fix perf probe issues on powerpc Naveen N. Rao
2015-01-28  6:14   ` Michael Ellerman
2015-01-28  6:43     ` Naveen N. Rao
2015-01-30  2:19       ` Michael Ellerman

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=20150312203059.GG3550@kernel.org \
    --to=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=naveen.n.rao@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;
as well as URLs for NNTP newsgroup(s).