Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f2a1c1e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "Tooling fixes, mostly related to the KASLR fallout, but also other
  fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf buildid-cache: Check relocation when checking for existing kcore
  perf tools: Adjust kallsyms for relocated kernel
  perf tests: No need to set up ref_reloc_sym
  perf symbols: Prevent the use of kcore if the kernel has moved
  perf record: Get ref_reloc_sym from kernel map
  perf machine: Set up ref_reloc_sym in machine__create_kernel_maps()
  perf machine: Add machine__get_kallsyms_filename()
  perf tools: Add kallsyms__get_function_start()
  perf symbols: Fix symbol annotation for relocated kernel
  perf tools: Fix include for non x86 architectures
  perf tools: Fix AAAAARGH64 memory barriers
  perf tools: Demangle kernel and kernel module symbols too
  perf/doc: Remove mention of non-existent set_perf_event_pending() from design.txt
parents 49447903 2737fce8
Loading
Loading
Loading
Loading
+29 −4
Original line number Original line Diff line number Diff line
@@ -63,11 +63,35 @@ static int build_id_cache__kcore_dir(char *dir, size_t sz)
	return 0;
	return 0;
}
}


static bool same_kallsyms_reloc(const char *from_dir, char *to_dir)
{
	char from[PATH_MAX];
	char to[PATH_MAX];
	const char *name;
	u64 addr1 = 0, addr2 = 0;
	int i;

	scnprintf(from, sizeof(from), "%s/kallsyms", from_dir);
	scnprintf(to, sizeof(to), "%s/kallsyms", to_dir);

	for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
		addr1 = kallsyms__get_function_start(from, name);
		if (addr1)
			break;
	}

	if (name)
		addr2 = kallsyms__get_function_start(to, name);

	return addr1 == addr2;
}

static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
					  size_t to_dir_sz)
					  size_t to_dir_sz)
{
{
	char from[PATH_MAX];
	char from[PATH_MAX];
	char to[PATH_MAX];
	char to[PATH_MAX];
	char to_subdir[PATH_MAX];
	struct dirent *dent;
	struct dirent *dent;
	int ret = -1;
	int ret = -1;
	DIR *d;
	DIR *d;
@@ -86,10 +110,11 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
			continue;
			continue;
		scnprintf(to, sizeof(to), "%s/%s/modules", to_dir,
		scnprintf(to, sizeof(to), "%s/%s/modules", to_dir,
			  dent->d_name);
			  dent->d_name);
		if (!compare_proc_modules(from, to)) {
		scnprintf(to_subdir, sizeof(to_subdir), "%s/%s",
			scnprintf(to, sizeof(to), "%s/%s", to_dir,
			  to_dir, dent->d_name);
				  dent->d_name);
		if (!compare_proc_modules(from, to) &&
			strlcpy(to_dir, to, to_dir_sz);
		    same_kallsyms_reloc(from_dir, to_subdir)) {
			strlcpy(to_dir, to_subdir, to_dir_sz);
			ret = 0;
			ret = 0;
			break;
			break;
		}
		}
+2 −8
Original line number Original line Diff line number Diff line
@@ -287,10 +287,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
	 * have no _text sometimes.
	 * have no _text sometimes.
	 */
	 */
	err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
	err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
						 machine, "_text");
						 machine);
	if (err < 0)
		err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
							 machine, "_stext");
	if (err < 0)
	if (err < 0)
		pr_err("Couldn't record guest kernel [%d]'s reference"
		pr_err("Couldn't record guest kernel [%d]'s reference"
		       " relocation symbol.\n", machine->pid);
		       " relocation symbol.\n", machine->pid);
@@ -457,10 +454,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
	}
	}


	err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
	err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
						 machine, "_text");
						 machine);
	if (err < 0)
		err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event,
							 machine, "_stext");
	if (err < 0)
	if (err < 0)
		pr_err("Couldn't record kernel reference relocation symbol\n"
		pr_err("Couldn't record kernel reference relocation symbol\n"
		       "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
		       "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
+0 −1
Original line number Original line Diff line number Diff line
@@ -454,7 +454,6 @@ So to start with, in order to add HAVE_PERF_EVENTS to your Kconfig, you
will need at least this:
will need at least this:
	- asm/perf_event.h - a basic stub will suffice at first
	- asm/perf_event.h - a basic stub will suffice at first
	- support for atomic64 types (and associated helper functions)
	- support for atomic64 types (and associated helper functions)
	- set_perf_event_pending() implemented


If your architecture does have hardware capabilities, you can override the
If your architecture does have hardware capabilities, you can override the
weak stub hw_perf_event_init() to register hardware counters.
weak stub hw_perf_event_init() to register hardware counters.
+2 −2
Original line number Original line Diff line number Diff line
@@ -100,8 +100,8 @@


#ifdef __aarch64__
#ifdef __aarch64__
#define mb()		asm volatile("dmb ish" ::: "memory")
#define mb()		asm volatile("dmb ish" ::: "memory")
#define wmb()		asm volatile("dmb ishld" ::: "memory")
#define wmb()		asm volatile("dmb ishst" ::: "memory")
#define rmb()		asm volatile("dmb ishst" ::: "memory")
#define rmb()		asm volatile("dmb ishld" ::: "memory")
#define cpu_relax()	asm volatile("yield" ::: "memory")
#define cpu_relax()	asm volatile("yield" ::: "memory")
#endif
#endif


+0 −10
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ int test__vmlinux_matches_kallsyms(void)
	struct map *kallsyms_map, *vmlinux_map;
	struct map *kallsyms_map, *vmlinux_map;
	struct machine kallsyms, vmlinux;
	struct machine kallsyms, vmlinux;
	enum map_type type = MAP__FUNCTION;
	enum map_type type = MAP__FUNCTION;
	struct ref_reloc_sym ref_reloc_sym = { .name = "_stext", };
	u64 mem_start, mem_end;
	u64 mem_start, mem_end;


	/*
	/*
@@ -70,14 +69,6 @@ int test__vmlinux_matches_kallsyms(void)
	 */
	 */
	kallsyms_map = machine__kernel_map(&kallsyms, type);
	kallsyms_map = machine__kernel_map(&kallsyms, type);


	sym = map__find_symbol_by_name(kallsyms_map, ref_reloc_sym.name, NULL);
	if (sym == NULL) {
		pr_debug("dso__find_symbol_by_name ");
		goto out;
	}

	ref_reloc_sym.addr = UM(sym->start);

	/*
	/*
	 * Step 5:
	 * Step 5:
	 *
	 *
@@ -89,7 +80,6 @@ int test__vmlinux_matches_kallsyms(void)
	}
	}


	vmlinux_map = machine__kernel_map(&vmlinux, type);
	vmlinux_map = machine__kernel_map(&vmlinux, type);
	map__kmap(vmlinux_map)->ref_reloc_sym = &ref_reloc_sym;


	/*
	/*
	 * Step 6:
	 * Step 6:
Loading