public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>, David Ahern <dsahern@gmail.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	kernel-team@lge.com
Subject: Re: [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end
Date: Thu, 8 Feb 2018 09:34:18 +0900	[thread overview]
Message-ID: <20180208003418.GA24686@sejong> (raw)
In-Reply-To: <20180207144838.16823-7-jolsa@kernel.org>

Hi Jiri,

On Wed, Feb 07, 2018 at 03:48:34PM +0100, Jiri Olsa wrote:
> The machine__set_kernel_mmap does the same job as map_groups__fixup_end
> when used on kernel maps within machine__create_kernel_maps call.

I'm not sure.  Modules have end address after machine__create_module()
but vmlinux_maps is not.  So map_groups__fixup() will set the end of
vmlinux_maps but with this change it will have ~0ULL.

Thanks,
Namhyung


> 
> This way we can also remove map_groups__fixup_end function, because there's
> no user to it. Also moving machine__set_kernel_mmap up in code, so we don't
> need forward declaration.
> 
> Link: http://lkml.kernel.org/n/tip-9kqrs3bsojwe4ktwpnkxc6g4@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/util/machine.c | 49 ++++++++++++++++++-----------------------------
>  1 file changed, 19 insertions(+), 30 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 7563b750137d..49ebd451151a 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1028,13 +1028,6 @@ int machine__load_vmlinux_path(struct machine *machine, enum map_type type)
>  	return ret;
>  }
>  
> -static void map_groups__fixup_end(struct map_groups *mg)
> -{
> -	int i;
> -	for (i = 0; i < MAP__NR_TYPES; ++i)
> -		__map_groups__fixup_end(mg, i);
> -}
> -
>  static char *get_kernel_version(const char *root_dir)
>  {
>  	char version[PATH_MAX];
> @@ -1220,6 +1213,24 @@ static int machine__create_modules(struct machine *machine)
>  	return 0;
>  }
>  
> +static void machine__set_kernel_mmap(struct machine *machine,
> +				     u64 start, u64 end)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAP__NR_TYPES; i++) {
> +		machine->vmlinux_maps[i]->start = start;
> +		machine->vmlinux_maps[i]->end   = end;
> +
> +		/*
> +		 * Be a bit paranoid here, some perf.data file came with
> +		 * a zero sized synthesized MMAP event for the kernel.
> +		 */
> +		if (machine->vmlinux_maps[i]->end == 0)
> +			machine->vmlinux_maps[i]->end = ~0ULL;
> +	}
> +}
> +
>  int machine__create_kernel_maps(struct machine *machine)
>  {
>  	struct dso *kernel = machine__get_kernel(machine);
> @@ -1244,11 +1255,6 @@ int machine__create_kernel_maps(struct machine *machine)
>  				 "continuing anyway...\n", machine->pid);
>  	}
>  
> -	/*
> -	 * Now that we have all the maps created, just set the ->end of them:
> -	 */
> -	map_groups__fixup_end(&machine->kmaps);
> -
>  	if (!machine__get_running_kernel_start(machine, &name, &addr)) {
>  		if (name &&
>  		    maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) {
> @@ -1257,27 +1263,10 @@ int machine__create_kernel_maps(struct machine *machine)
>  		}
>  	}
>  
> +	machine__set_kernel_mmap(machine, addr, 0);
>  	return 0;
>  }
>  
> -static void machine__set_kernel_mmap(struct machine *machine,
> -				     u64 start, u64 end)
> -{
> -	int i;
> -
> -	for (i = 0; i < MAP__NR_TYPES; i++) {
> -		machine->vmlinux_maps[i]->start = start;
> -		machine->vmlinux_maps[i]->end   = end;
> -
> -		/*
> -		 * Be a bit paranoid here, some perf.data file came with
> -		 * a zero sized synthesized MMAP event for the kernel.
> -		 */
> -		if (machine->vmlinux_maps[i]->end == 0)
> -			machine->vmlinux_maps[i]->end = ~0ULL;
> -	}
> -}
> -
>  static bool machine__uses_kcore(struct machine *machine)
>  {
>  	struct dso *dso;
> -- 
> 2.13.6
> 

  reply	other threads:[~2018-02-08  0:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 14:48 [PATCHv2 00/10] perf tool: Assorted fixes Jiri Olsa
2018-02-07 14:48 ` [PATCH 01/10] tools lib symbol: Skip non-address kallsyms line Jiri Olsa
2018-02-07 14:48 ` [PATCH 02/10] perf tools: Free root_dir in machine__init error path Jiri Olsa
2018-02-07 14:48 ` [PATCH 03/10] perf tools: Move kernel mmap name into struct machine Jiri Olsa
2018-02-07 14:48 ` [PATCH 04/10] perf tools: Don't search for active kernel start in __machine__create_kernel_maps Jiri Olsa
2018-02-07 14:48 ` [PATCH 05/10] perf tools: Generalize machine__set_kernel_mmap function Jiri Olsa
2018-02-07 14:48 ` [PATCH 06/10] perf tools: Use machine__set_kernel_mmap instead of map_groups__fixup_end Jiri Olsa
2018-02-08  0:34   ` Namhyung Kim [this message]
2018-02-08  8:56     ` Jiri Olsa
2018-02-07 14:48 ` [PATCH 07/10] perf tools: Rename __map_groups__fixup_end to map_groups__fixup_end Jiri Olsa
2018-02-07 14:48 ` [PATCH 08/10] perf tools: Remove machine__load_kallsyms function Jiri Olsa
2018-02-07 14:48 ` [PATCH 09/10] perf tools: Do not create kernel maps in sample__resolve Jiri Olsa
2018-02-07 14:48 ` [PATCH 10/10] perf tools: Check if we read regular file in dso__load Jiri Olsa

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=20180208003418.GA24686@sejong \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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