[PATCH v3 1/1] task: Handle task_struct state member changes in linux-next

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The member state of task_struct has been renamed to __state and its type
changed from long to unsigned int.

https://lore.kernel.org/linux-arch/20210611082810.970791107@xxxxxxxxxxxxx/

Signed-off-by: Alexander Egorenkov <egorenar@xxxxxxxxxxxxx>
---
v2 -> v3:
 * Append task_struct_state at the end of struct size_table
 * Add task_struct_state print statement to dump_offset_table()

v1 -> v2:
 * Fix size initialization for __state

 defs.h    |  1 +
 symbols.c |  1 +
 task.c    | 10 +++++++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/defs.h b/defs.h
index 6bb00e2..5d32954 100644
--- a/defs.h
+++ b/defs.h
@@ -2304,6 +2304,7 @@ struct size_table {         /* stash of commonly-used sizes */
 	long printk_ringbuffer;
 	long prb_desc;
 	long wait_queue_entry;
+	long task_struct_state;
 };
 
 struct array_table {
diff --git a/symbols.c b/symbols.c
index 67c135f..bf6d94d 100644
--- a/symbols.c
+++ b/symbols.c
@@ -10678,6 +10678,7 @@ dump_offset_table(char *spec, ulong makestruct)
 		SIZE(page_cache_bucket));
         fprintf(fp, "                       pt_regs: %ld\n", SIZE(pt_regs));
         fprintf(fp, "                   task_struct: %ld\n", SIZE(task_struct));
+	fprintf(fp, "             task_struct_state: %ld\n", SIZE(task_struct_state));
         fprintf(fp, "             task_struct_flags: %ld\n", SIZE(task_struct_flags));
         fprintf(fp, "            task_struct_policy: %ld\n", SIZE(task_struct_policy));
         fprintf(fp, "                   thread_info: %ld\n", SIZE(thread_info));
diff --git a/task.c b/task.c
index 36cf259..672b416 100644
--- a/task.c
+++ b/task.c
@@ -297,6 +297,11 @@ task_init(void)
 	}
 
         MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "state");
+	MEMBER_SIZE_INIT(task_struct_state, "task_struct", "state");
+	if (INVALID_MEMBER(task_struct_state)) {
+		MEMBER_OFFSET_INIT(task_struct_state, "task_struct", "__state");
+		MEMBER_SIZE_INIT(task_struct_state, "task_struct", "__state");
+	}
         MEMBER_OFFSET_INIT(task_struct_exit_state, "task_struct", "exit_state");
         MEMBER_OFFSET_INIT(task_struct_pid, "task_struct", "pid");
         MEMBER_OFFSET_INIT(task_struct_comm, "task_struct", "comm");
@@ -5926,7 +5931,10 @@ task_state(ulong task)
 	if (!tt->last_task_read)
 		return 0;
 
-	state = ULONG(tt->task_struct + OFFSET(task_struct_state));
+	if (SIZE(task_struct_state) == sizeof(ulong))
+		state = ULONG(tt->task_struct + OFFSET(task_struct_state));
+	else
+		state = UINT(tt->task_struct + OFFSET(task_struct_state));
 	exit_state = VALID_MEMBER(task_struct_exit_state) ?
 		ULONG(tt->task_struct + OFFSET(task_struct_exit_state)) : 0;
 
-- 
2.31.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux