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/[email protected]
> Signed-off-by: Jiri Olsa <[email protected]>
> ---
>  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 via email to