summaryrefslogtreecommitdiffstats
path: root/kernel/stacktrace.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2022-01-17 18:03:39 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2022-01-17 18:03:39 -0800
commit87a0b2fafc09766d8c55461a18345a1cfb10a7fe (patch)
treef2ecd87b34a4709e49b51470056f6b6e528fefca /kernel/stacktrace.c
parentb6e43dddaea3dbfa93327f986beb3ec5e8157c4c (diff)
parentdf0cc57e057f18e44dac8e6c18aba47ab53202f9 (diff)
downloadcachepc-linux-87a0b2fafc09766d8c55461a18345a1cfb10a7fe.tar.gz
cachepc-linux-87a0b2fafc09766d8c55461a18345a1cfb10a7fe.zip
Merge tag 'v5.16' into next
Sync up with mainline to bring in the latest API changes.
Diffstat (limited to 'kernel/stacktrace.c')
-rw-r--r--kernel/stacktrace.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 9f8117c7cfdd..9c625257023d 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -13,6 +13,7 @@
#include <linux/export.h>
#include <linux/kallsyms.h>
#include <linux/stacktrace.h>
+#include <linux/interrupt.h>
/**
* 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)
#endif /* CONFIG_USER_STACKTRACE_SUPPORT */
#endif /* !CONFIG_ARCH_STACKWALK */
+
+static inline bool in_irqentry_text(unsigned long ptr)
+{
+ return (ptr >= (unsigned long)&__irqentry_text_start &&
+ ptr < (unsigned long)&__irqentry_text_end) ||
+ (ptr >= (unsigned long)&__softirqentry_text_start &&
+ ptr < (unsigned long)&__softirqentry_text_end);
+}
+
+/**
+ * filter_irq_stacks - Find first IRQ stack entry in trace
+ * @entries: Pointer to stack trace array
+ * @nr_entries: Number of entries in the storage array
+ *
+ * Return: Number of trace entries until IRQ stack starts.
+ */
+unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries)
+{
+ unsigned int i;
+
+ for (i = 0; i < nr_entries; i++) {
+ if (in_irqentry_text(entries[i])) {
+ /* Include the irqentry function into the stack. */
+ return i + 1;
+ }
+ }
+ return nr_entries;
+}
+EXPORT_SYMBOL_GPL(filter_irq_stacks);