Blame SOURCES/0002-Fix-waitq-command-for-Linux-4.13-and-later-kernels.patch

f27a4c
From eaf14f852ae79f7745934e213661f1c6abac711e Mon Sep 17 00:00:00 2001
f27a4c
From: Greg Edwards <gedwards@ddn.com>
f27a4c
Date: Wed, 23 Jun 2021 13:50:47 -0600
f27a4c
Subject: [PATCH] Fix 'waitq' command for Linux 4.13 and later kernels
f27a4c
f27a4c
The wait queue structs and members were renamed in 4.13 in commits:
f27a4c
f27a4c
  ac6424b981bc ("sched/wait: Rename wait_queue_t => wait_queue_entry_t")
f27a4c
  9d9d676f595b ("sched/wait: Standardize internal naming of wait-queue heads")
f27a4c
  2055da97389a ("sched/wait: Disambiguate wq_entry->task_list and wq_head->task_list naming")
f27a4c
f27a4c
Add support to the 'waitq' command for these more recent kernels.
f27a4c
f27a4c
[ kh: suppressed compilation warnings ]
f27a4c
f27a4c
Signed-off-by: Greg Edwards <gedwards@ddn.com>
f27a4c
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
f27a4c
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
f27a4c
---
f27a4c
 defs.h    |  4 ++++
f27a4c
 kernel.c  | 27 +++++++++++++++++++++++----
f27a4c
 symbols.c | 10 +++++++++-
f27a4c
 3 files changed, 36 insertions(+), 5 deletions(-)
f27a4c
f27a4c
diff --git a/defs.h b/defs.h
f27a4c
index 42c8074e6ac6..6bb00e29d811 100644
f27a4c
--- a/defs.h
f27a4c
+++ b/defs.h
f27a4c
@@ -2138,6 +2138,9 @@ struct offset_table {                    /* stash of commonly-used offsets */
f27a4c
 	long atomic_long_t_counter;
f27a4c
 	long block_device_bd_device;
f27a4c
 	long block_device_bd_stats;
f27a4c
+	long wait_queue_entry_private;
f27a4c
+	long wait_queue_head_head;
f27a4c
+	long wait_queue_entry_entry;
f27a4c
 };
f27a4c
 
f27a4c
 struct size_table {         /* stash of commonly-used sizes */
f27a4c
@@ -2300,6 +2303,7 @@ struct size_table {         /* stash of commonly-used sizes */
f27a4c
 	long printk_info;
f27a4c
 	long printk_ringbuffer;
f27a4c
 	long prb_desc;
f27a4c
+	long wait_queue_entry;
f27a4c
 };
f27a4c
 
f27a4c
 struct array_table {
f27a4c
diff --git a/kernel.c b/kernel.c
f27a4c
index 528f6ee524f6..e123f760e036 100644
f27a4c
--- a/kernel.c
f27a4c
+++ b/kernel.c
f27a4c
@@ -615,7 +615,15 @@ kernel_init()
f27a4c
 		kt->flags |= TVEC_BASES_V1;
f27a4c
 
f27a4c
         STRUCT_SIZE_INIT(__wait_queue, "__wait_queue");
f27a4c
-        if (VALID_STRUCT(__wait_queue)) {
f27a4c
+	STRUCT_SIZE_INIT(wait_queue_entry, "wait_queue_entry");
f27a4c
+	if (VALID_STRUCT(wait_queue_entry)) {
f27a4c
+		MEMBER_OFFSET_INIT(wait_queue_entry_private,
f27a4c
+			"wait_queue_entry", "private");
f27a4c
+		MEMBER_OFFSET_INIT(wait_queue_head_head,
f27a4c
+			"wait_queue_head", "head");
f27a4c
+		MEMBER_OFFSET_INIT(wait_queue_entry_entry,
f27a4c
+			"wait_queue_entry", "entry");
f27a4c
+	} else if (VALID_STRUCT(__wait_queue)) {
f27a4c
 		if (MEMBER_EXISTS("__wait_queue", "task"))
f27a4c
 			MEMBER_OFFSET_INIT(__wait_queue_task,
f27a4c
 				"__wait_queue", "task");
f27a4c
@@ -9367,9 +9375,9 @@ dump_waitq(ulong wq, char *wq_name)
f27a4c
 	struct list_data list_data, *ld;
f27a4c
 	ulong *wq_list;			/* addr of wait queue element */
f27a4c
 	ulong next_offset;		/* next pointer of wq element */
f27a4c
-	ulong task_offset;		/* offset of task in wq element */
f27a4c
+	ulong task_offset = 0;		/* offset of task in wq element */
f27a4c
 	int cnt;			/* # elems on Queue */
f27a4c
-	int start_index;		/* where to start in wq array */
f27a4c
+	int start_index = -1;		/* where to start in wq array */
f27a4c
 	int i;
f27a4c
 
f27a4c
 	ld = &list_data;
f27a4c
@@ -9397,9 +9405,20 @@ dump_waitq(ulong wq, char *wq_name)
f27a4c
                 ld->list_head_offset = OFFSET(__wait_queue_task_list);
f27a4c
                 ld->member_offset = next_offset;
f27a4c
 
f27a4c
+		start_index = 1;
f27a4c
+	} else if (VALID_STRUCT(wait_queue_entry)) {
f27a4c
+		ulong head_offset;
f27a4c
+
f27a4c
+		next_offset = OFFSET(list_head_next);
f27a4c
+		task_offset = OFFSET(wait_queue_entry_private);
f27a4c
+		head_offset = OFFSET(wait_queue_head_head);
f27a4c
+		ld->end = ld->start = wq + head_offset + next_offset;
f27a4c
+		ld->list_head_offset = OFFSET(wait_queue_entry_entry);
f27a4c
+		ld->member_offset = next_offset;
f27a4c
+
f27a4c
 		start_index = 1;
f27a4c
 	} else {
f27a4c
-		return;
f27a4c
+		error(FATAL, "cannot determine wait queue structures\n");
f27a4c
 	}
f27a4c
 
f27a4c
 	hq_open();
f27a4c
diff --git a/symbols.c b/symbols.c
f27a4c
index 370d4c3e8ac0..67c135f12984 100644
f27a4c
--- a/symbols.c
f27a4c
+++ b/symbols.c
f27a4c
@@ -9817,7 +9817,13 @@ dump_offset_table(char *spec, ulong makestruct)
f27a4c
         	OFFSET(__wait_queue_head_task_list));
f27a4c
         fprintf(fp, "        __wait_queue_task_list: %ld\n", 
f27a4c
         	OFFSET(__wait_queue_task_list));
f27a4c
- 
f27a4c
+	fprintf(fp, "      wait_queue_entry_private: %ld\n",
f27a4c
+		OFFSET(wait_queue_entry_private));
f27a4c
+	fprintf(fp, "          wait_queue_head_head: %ld\n",
f27a4c
+		OFFSET(wait_queue_head_head));
f27a4c
+	fprintf(fp, "        wait_queue_entry_entry: %ld\n",
f27a4c
+		OFFSET(wait_queue_entry_entry));
f27a4c
+
f27a4c
 	fprintf(fp, "        pglist_data_node_zones: %ld\n",
f27a4c
 		OFFSET(pglist_data_node_zones));
f27a4c
 	fprintf(fp, "      pglist_data_node_mem_map: %ld\n",
f27a4c
@@ -10717,6 +10723,8 @@ dump_offset_table(char *spec, ulong makestruct)
f27a4c
 	fprintf(fp, "                    wait_queue: %ld\n", SIZE(wait_queue));
f27a4c
 	fprintf(fp, "                  __wait_queue: %ld\n", 
f27a4c
 		SIZE(__wait_queue));
f27a4c
+	fprintf(fp, "              wait_queue_entry: %ld\n",
f27a4c
+		SIZE(wait_queue_entry));
f27a4c
 	fprintf(fp, "                        device: %ld\n", SIZE(device));
f27a4c
 	fprintf(fp, "                    net_device: %ld\n", SIZE(net_device));
f27a4c
 
f27a4c
-- 
f27a4c
2.30.2
f27a4c