diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2022-03-23 09:58:40 +0100 | 
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2022-03-23 09:58:40 +0100 | 
| commit | b690490d6d466972ade172ee2e7f6ffa49e7e910 (patch) | |
| tree | 50a93da28c9128e19eb7a3038aecf75dab6b36e1 /kernel/trace/ftrace.c | |
| parent | f97ec5d75e9261a5da78dc28a8955b7cc0c4468b (diff) | |
| parent | 0f203948230720e849ad50d158adac1cd32c282f (diff) | |
Merge branch 'for-5.18/amd-sfh' into for-linus
- dead code elimination (Christophe JAILLET)
Diffstat (limited to 'kernel/trace/ftrace.c')
| -rw-r--r-- | kernel/trace/ftrace.c | 34 | 
1 files changed, 32 insertions, 2 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index be5f6b32a012..6163b6f762f7 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6394,6 +6394,27 @@ static int ftrace_cmp_ips(const void *a, const void *b)  	return 0;  } +#ifdef CONFIG_FTRACE_SORT_STARTUP_TEST +static void test_is_sorted(unsigned long *start, unsigned long count) +{ +	int i; + +	for (i = 1; i < count; i++) { +		if (WARN(start[i - 1] > start[i], +			 "[%d] %pS at %lx is not sorted with %pS at %lx\n", i, +			 (void *)start[i - 1], start[i - 1], +			 (void *)start[i], start[i])) +			break; +	} +	if (i == count) +		pr_info("ftrace section at %px sorted properly\n", start); +} +#else +static void test_is_sorted(unsigned long *start, unsigned long count) +{ +} +#endif +  static int ftrace_process_locs(struct module *mod,  			       unsigned long *start,  			       unsigned long *end) @@ -6412,8 +6433,17 @@ static int ftrace_process_locs(struct module *mod,  	if (!count)  		return 0; -	sort(start, count, sizeof(*start), -	     ftrace_cmp_ips, NULL); +	/* +	 * Sorting mcount in vmlinux at build time depend on +	 * CONFIG_BUILDTIME_TABLE_SORT, while mcount loc in +	 * modules can not be sorted at build time. +	 */ +	if (!IS_ENABLED(CONFIG_BUILDTIME_TABLE_SORT) || mod) { +		sort(start, count, sizeof(*start), +		     ftrace_cmp_ips, NULL); +	} else { +		test_is_sorted(start, count); +	}  	start_pg = ftrace_allocate_pages(count);  	if (!start_pg)  | 
