filter_irq_stacks() has little to do with the stackdepot implementation, except that it is usually used by users (such as KASAN) of stackdepot to reduce the stack trace. However, filter_irq_stacks() itself is not useful without a stack trace as obtained by stack_trace_save() and friends. Therefore, move filter_irq_stacks() to kernel/stacktrace.c, so that new users of filter_irq_stacks() do not have to start depending on STACKDEPOT only for filter_irq_stacks().
Showing the changes to kernel/stacktrace.c (1 of 4 files). Show all
Unified · Split
| @@ -13,6 +13,7 @@ · 12 unmodified lines | |||
| 13 | #include <linux/export.h> | 13 | #include <linux/export.h> |
| 14 | #include <linux/kallsyms.h> | 14 | #include <linux/kallsyms.h> |
| 15 | #include <linux/stacktrace.h> | 15 | #include <linux/stacktrace.h> |
| 16 | #include <linux/interrupt.h> | ||
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | * stack_trace_print - Print the entries in the stack trace | 19 | * stack_trace_print - Print the entries in the stack trace |
| @@ -373,3 +374,32 @@ unsigned int stack_trace_save_user(unsigned long *store, unsigned int size) · 354 unmodified lines | |||
| 373 | #endif /* CONFIG_USER_STACKTRACE_SUPPORT */ | 374 | #endif /* CONFIG_USER_STACKTRACE_SUPPORT */ |
| 374 | 375 | ||
| 375 | #endif /* !CONFIG_ARCH_STACKWALK */ | 376 | #endif /* !CONFIG_ARCH_STACKWALK */ |
| 377 | |||
| 378 | static inline bool in_irqentry_text(unsigned long ptr) | ||
| 379 | { | ||
| 380 | return (ptr >= (unsigned long)&__irqentry_text_start && | ||
| 381 | ptr < (unsigned long)&__irqentry_text_end) || | ||
| 382 | (ptr >= (unsigned long)&__softirqentry_text_start && | ||
| 383 | ptr < (unsigned long)&__softirqentry_text_end); | ||
| 384 | } | ||
| 385 | |||
| 386 | /** | ||
| 387 | * filter_irq_stacks - Find first IRQ stack entry in trace | ||
| 388 | * @entries: Pointer to stack trace array | ||
| 389 | * @nr_entries: Number of entries in the storage array | ||
| 390 | * | ||
| 391 | * Return: Number of trace entries until IRQ stack starts. | ||
| 392 | */ | ||
| 393 | unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries) | ||
| 394 | { | ||
| 395 | unsigned int i; | ||
| 396 | |||
| 397 | for (i = 0; i < nr_entries; i++) { | ||
| 398 | if (in_irqentry_text(entries[i])) { | ||
| 399 | /* Include the irqentry function into the stack. */ | ||
| 400 | return i + 1; | ||
| 401 | } | ||
| 402 | } | ||
| 403 | return nr_entries; | ||
| 404 | } | ||
| 405 | EXPORT_SYMBOL_GPL(filter_irq_stacks); | ||