Skip to content
Snippets Groups Projects
Select Git revision
  • c48b07226bd41f4053aa2024c5e347183c04deb5
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

machine.c

Blame
    • Kemeng Shi's avatar
      78886f3e
      perf symbols: Fix arm64 gap between kernel start and module end · 78886f3e
      Kemeng Shi authored
      
      During execution of command 'perf report' in my arm64 virtual machine,
      this error message is showed:
      
      failed to process sample
      
      __symbol__inc_addr_samples(860): ENOMEM! sym->name=__this_module,
          start=0x1477100, addr=0x147dbd8, end=0x80002000, func: 0
      
      The error is caused with path:
      cmd_report
       __cmd_report
        perf_session__process_events
         __perf_session__process_events
          ordered_events__flush
           __ordered_events__flush
            oe->deliver (ordered_events__deliver_event)
             perf_session__deliver_event
              machines__deliver_event
               perf_evlist__deliver_sample
                tool->sample (process_sample_event)
                 hist_entry_iter__add
                  iter->add_entry_cb(hist_iter__report_callback)
                   hist_entry__inc_addr_samples
                    symbol__inc_addr_samples
                     __symbol__inc_addr_samples
                      h = annotated_source__histogram(src, evidx) (NULL)
      
      annotated_source__histogram failed is caused with path:
      ...
       hist_entry__inc_addr_samples
        symbol__inc_addr_samples
         symbol__hists
          annotated_source__alloc_histograms
           src->histograms = calloc(nr_hists, sizeof_sym_hist) (failed)
      
      Calloc failed as the symbol__size(sym) is too huge. As show in error
      message: start=0x1477100, end=0x80002000, size of symbol is about 2G.
      
      This is the same problem as 'perf annotate: Fix s390 gap between kernel
      end and module start (b9c0a649)'. Perf gets symbol information from
      /proc/kallsyms in __dso__load_kallsyms. A part of symbol in /proc/kallsyms
      from my virtual machine is as follows:
       #cat /proc/kallsyms | sort
       ...
       ffff000001475080 d rpfilter_mt_reg      [ip6t_rpfilter]
       ffff000001475100 d $d   [ip6t_rpfilter]
       ffff000001475100 d __this_module        [ip6t_rpfilter]
       ffff000080080000 t _head
       ffff000080080000 T _text
       ffff000080080040 t pe_header
       ...
      
      Take line 'ffff000001475100 d __this_module [ip6t_rpfilter]' as example.
      The start and end of symbol are both set to ffff000001475100 in
      dso__load_all_kallsyms. Then symbols__fixup_end will set the end of symbol
      to next big address to ffff000001475100 in /proc/kallsyms, ffff000080080000
      in this example. Then sizeof of symbol will be about 2G and cause the
      problem.
      
      The start of module in my machine is
       ffff000000a62000 t $x   [dm_mod]
      
      The start of kernel in my machine is
       ffff000080080000 t _head
      
      There is a big gap between end of module and begin of kernel if a samll
      amount of memory is used by module. And the last symbol in module will
      have a large address range as caotaining the big gap.
      
      Give that the module and kernel text segment sequence may change in
      the future, fix this by limiting range of last symbol in module and kernel
      to 4K in arch arm64.
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hewenliang <hewenliang4@huawei.com>
      Cc: Hu Shiyuan <hushiyuan@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/33fd24c4-0d5a-9d93-9b62-dffa97c992ca@huawei.com
      
      
      [ refreshed the patch on current codebase, added string.h include as strchr() is used ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      78886f3e
      History
      perf symbols: Fix arm64 gap between kernel start and module end
      Kemeng Shi authored
      
      During execution of command 'perf report' in my arm64 virtual machine,
      this error message is showed:
      
      failed to process sample
      
      __symbol__inc_addr_samples(860): ENOMEM! sym->name=__this_module,
          start=0x1477100, addr=0x147dbd8, end=0x80002000, func: 0
      
      The error is caused with path:
      cmd_report
       __cmd_report
        perf_session__process_events
         __perf_session__process_events
          ordered_events__flush
           __ordered_events__flush
            oe->deliver (ordered_events__deliver_event)
             perf_session__deliver_event
              machines__deliver_event
               perf_evlist__deliver_sample
                tool->sample (process_sample_event)
                 hist_entry_iter__add
                  iter->add_entry_cb(hist_iter__report_callback)
                   hist_entry__inc_addr_samples
                    symbol__inc_addr_samples
                     __symbol__inc_addr_samples
                      h = annotated_source__histogram(src, evidx) (NULL)
      
      annotated_source__histogram failed is caused with path:
      ...
       hist_entry__inc_addr_samples
        symbol__inc_addr_samples
         symbol__hists
          annotated_source__alloc_histograms
           src->histograms = calloc(nr_hists, sizeof_sym_hist) (failed)
      
      Calloc failed as the symbol__size(sym) is too huge. As show in error
      message: start=0x1477100, end=0x80002000, size of symbol is about 2G.
      
      This is the same problem as 'perf annotate: Fix s390 gap between kernel
      end and module start (b9c0a649)'. Perf gets symbol information from
      /proc/kallsyms in __dso__load_kallsyms. A part of symbol in /proc/kallsyms
      from my virtual machine is as follows:
       #cat /proc/kallsyms | sort
       ...
       ffff000001475080 d rpfilter_mt_reg      [ip6t_rpfilter]
       ffff000001475100 d $d   [ip6t_rpfilter]
       ffff000001475100 d __this_module        [ip6t_rpfilter]
       ffff000080080000 t _head
       ffff000080080000 T _text
       ffff000080080040 t pe_header
       ...
      
      Take line 'ffff000001475100 d __this_module [ip6t_rpfilter]' as example.
      The start and end of symbol are both set to ffff000001475100 in
      dso__load_all_kallsyms. Then symbols__fixup_end will set the end of symbol
      to next big address to ffff000001475100 in /proc/kallsyms, ffff000080080000
      in this example. Then sizeof of symbol will be about 2G and cause the
      problem.
      
      The start of module in my machine is
       ffff000000a62000 t $x   [dm_mod]
      
      The start of kernel in my machine is
       ffff000080080000 t _head
      
      There is a big gap between end of module and begin of kernel if a samll
      amount of memory is used by module. And the last symbol in module will
      have a large address range as caotaining the big gap.
      
      Give that the module and kernel text segment sequence may change in
      the future, fix this by limiting range of last symbol in module and kernel
      to 4K in arch arm64.
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hewenliang <hewenliang4@huawei.com>
      Cc: Hu Shiyuan <hushiyuan@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/33fd24c4-0d5a-9d93-9b62-dffa97c992ca@huawei.com
      
      
      [ refreshed the patch on current codebase, added string.h include as strchr() is used ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    test_cgrp2_array_pin.c 2.24 KiB
    /* Copyright (c) 2016 Facebook
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of version 2 of the GNU General Public
     * License as published by the Free Software Foundation.
     */
    #include <linux/unistd.h>
    #include <linux/bpf.h>
    
    #include <stdio.h>
    #include <stdint.h>
    #include <unistd.h>
    #include <string.h>
    #include <errno.h>
    #include <fcntl.h>
    
    #include "libbpf.h"
    
    static void usage(void)
    {
    	printf("Usage: test_cgrp2_array_pin [...]\n");
    	printf("       -F <file>   File to pin an BPF cgroup array\n");
    	printf("       -U <file>   Update an already pinned BPF cgroup array\n");
    	printf("       -v <value>  Full path of the cgroup2\n");
    	printf("       -h          Display this help\n");
    }
    
    int main(int argc, char **argv)
    {
    	const char *pinned_file = NULL, *cg2 = NULL;
    	int create_array = 1;
    	int array_key = 0;
    	int array_fd = -1;
    	int cg2_fd = -1;
    	int ret = -1;
    	int opt;
    
    	while ((opt = getopt(argc, argv, "F:U:v:")) != -1) {
    		switch (opt) {
    		/* General args */
    		case 'F':
    			pinned_file = optarg;
    			break;
    		case 'U':
    			pinned_file = optarg;
    			create_array = 0;
    			break;
    		case 'v':
    			cg2 = optarg;
    			break;
    		default:
    			usage();
    			goto out;
    		}
    	}
    
    	if (!cg2 || !pinned_file) {
    		usage();
    		goto out;
    	}
    
    	cg2_fd = open(cg2, O_RDONLY);
    	if (cg2_fd < 0) {
    		fprintf(stderr, "open(%s,...): %s(%d)\n",
    			cg2, strerror(errno), errno);
    		goto out;
    	}
    
    	if (create_array) {
    		array_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,
    					  sizeof(uint32_t), sizeof(uint32_t),
    					  1, 0);
    		if (array_fd < 0) {
    			fprintf(stderr,
    				"bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,...): %s(%d)\n",
    				strerror(errno), errno);
    			goto out;
    		}
    	} else {
    		array_fd = bpf_obj_get(pinned_file);
    		if (array_fd < 0) {
    			fprintf(stderr, "bpf_obj_get(%s): %s(%d)\n",
    				pinned_file, strerror(errno), errno);
    			goto out;
    		}
    	}
    
    	ret = bpf_update_elem(array_fd, &array_key, &cg2_fd, 0);
    	if (ret) {
    		perror("bpf_update_elem");
    		goto out;
    	}
    
    	if (create_array) {
    		ret = bpf_obj_pin(array_fd, pinned_file);
    		if (ret) {
    			fprintf(stderr, "bpf_obj_pin(..., %s): %s(%d)\n",
    				pinned_file, strerror(errno), errno);
    			goto out;
    		}
    	}
    
    out:
    	if (array_fd != -1)
    		close(array_fd);
    	if (cg2_fd != -1)
    		close(cg2_fd);
    	return ret;
    }