clear-pkgs-linux-iot-lts2018/1222-vhm-ioreq-dump-callsta...

81 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yin Fengwei <fengwei.yin@intel.com>
Date: Tue, 3 Sep 2019 10:10:29 +0800
Subject: [PATCH] vhm ioreq: dump callstack for iorange adding operation
Extend the vhm iorange dump function to include the callstack
of adding iorange to specific ioreq client.
Tracked-On: projectacrn/acrn-hypervisor#3634
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/vhm/vhm_ioreq.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/vhm/vhm_ioreq.c b/drivers/vhm/vhm_ioreq.c
index ef89bf827270..16b666edfc3a 100644
--- a/drivers/vhm/vhm_ioreq.c
+++ b/drivers/vhm/vhm_ioreq.c
@@ -69,6 +69,8 @@
#include <linux/vhm/acrn_vhm_mm.h>
#include <linux/idr.h>
+#define IOREQ_RANGE_ENTRIES 8
+
static DEFINE_SPINLOCK(client_lock);
static struct idr idr_client;
@@ -77,6 +79,11 @@ struct ioreq_range {
uint32_t type;
long start;
long end;
+
+#ifdef CONFIG_STACKTRACE
+ struct stack_trace st;
+ unsigned long st_entries[IOREQ_RANGE_ENTRIES];
+#endif
};
enum IOREQ_CLIENT_BITS {
@@ -476,6 +483,14 @@ int acrn_ioreq_add_iorange(int client_id, uint32_t type,
range->start = start;
range->end = end;
+#ifdef CONFIG_STACKTRACE
+ range->st.max_entries = IOREQ_RANGE_ENTRIES;
+ range->st.entries = range->st_entries;
+ range->st.nr_entries = 0;
+ range->st.skip = 0;
+ save_stack_trace(&range->st);
+#endif
+
spin_lock_bh(&client->range_lock);
list_add(&range->list, &client->range_list);
spin_unlock_bh(&client->range_lock);
@@ -1109,6 +1124,7 @@ static struct dentry *vhm_debugfs_dir;
static void vhm_ioclient_range_show_one(struct seq_file *s,
struct ioreq_client *client)
{
+ int i;
struct list_head *pos;
seq_printf(s, " client: %s, id: %d\n",
@@ -1120,6 +1136,13 @@ static void vhm_ioclient_range_show_one(struct seq_file *s,
container_of(pos, struct ioreq_range, list);
seq_printf(s, " io range: type %d, start 0x%lx, end 0x%lx\n",
range->type, range->start, range->end);
+#ifdef CONFIG_STACKTRACE
+ seq_puts(s, " allocation stack:\n");
+ for (i = 0; i < range->st.nr_entries; i++) {
+ seq_printf(s, " %pB\n",
+ (void *)range->st_entries[i]);
+ }
+#endif
}
spin_unlock_bh(&client->range_lock);
}
--
https://clearlinux.org