From a3d39b29c85aee2185ad96626047be5f2b3826c0 Mon Sep 17 00:00:00 2001 From: Lingutla Chandrasekhar <clingutla@codeaurora.org> Date: Mon, 25 Mar 2019 20:56:50 +0530 Subject: [PATCH] lrdp_V2: Support to print task's affinity Add support to print task's affinity in runqueue info and task dump parsers. Change-Id: I790a64764fdba7232b89beaa0c5bbbbfe5d5861f Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org> --- linux-ramdump-parser-v2/parsers/runqueue.py | 4 +++- linux-ramdump-parser-v2/parsers/taskdump.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/linux-ramdump-parser-v2/parsers/runqueue.py b/linux-ramdump-parser-v2/parsers/runqueue.py index cf60317..73ee7ee 100644 --- a/linux-ramdump-parser-v2/parsers/runqueue.py +++ b/linux-ramdump-parser-v2/parsers/runqueue.py @@ -40,12 +40,14 @@ class RunQueues(RamParser): def print_task_state(self, status, task_addr): pid_offset = self.ramdump.field_offset('struct task_struct', 'pid') comm_offset = self.ramdump.field_offset('struct task_struct', 'comm') + affinity_offset = self.ramdump.field_offset('struct task_struct', 'cpus_allowed') if 0 < task_addr: pid = self.ramdump.read_int(task_addr + pid_offset) taskname = self.ramdump.read_cstring(task_addr + comm_offset, 16) + affinity = self.ramdump.read_u64(task_addr + affinity_offset) self.print_out_str_with_tab( - '{0}: {1}({2})'.format(status, taskname, pid)) + '{0}: {1}({2}) [affinity={3:x}]'.format(status, taskname, pid, affinity)) else: self.print_out_str_with_tab('{0}: None(0)'.format(status)) diff --git a/linux-ramdump-parser-v2/parsers/taskdump.py b/linux-ramdump-parser-v2/parsers/taskdump.py index 207583f..4fbf413 100755 --- a/linux-ramdump-parser-v2/parsers/taskdump.py +++ b/linux-ramdump-parser-v2/parsers/taskdump.py @@ -61,6 +61,7 @@ def dump_thread_group(ramdump, thread_group, task_out, taskhighlight_out, check_ offset_stack = ramdump.field_offset('struct task_struct', 'stack') offset_state = ramdump.field_offset('struct task_struct', 'state') offset_prio = ramdump.field_offset('struct task_struct', 'prio') + offset_affine = ramdump.field_offset('struct task_struct', 'cpus_allowed') offset_exit_state = ramdump.field_offset( 'struct task_struct', 'exit_state') orig_thread_group = thread_group @@ -74,6 +75,7 @@ def dump_thread_group(ramdump, thread_group, task_out, taskhighlight_out, check_ next_thread_stack = next_thread_start + offset_stack next_thread_state = next_thread_start + offset_state next_thread_exit_state = next_thread_start + offset_exit_state + next_thread_affine = next_thread_start + offset_affine next_thread_info = ramdump.get_thread_info_addr(next_thread_start) thread_task_name = cleanupString( ramdump.read_cstring(next_thread_comm, 16)) @@ -87,6 +89,9 @@ def dump_thread_group(ramdump, thread_group, task_out, taskhighlight_out, check_ thread_task_pid = ramdump.read_int(next_thread_pid) if thread_task_pid is None: return + thread_task_affine = ramdump.read_u64(next_thread_affine) + if thread_task_affine is None: + return task_state = ramdump.read_word(next_thread_state) if task_state is None: return @@ -124,8 +129,8 @@ def dump_thread_group(ramdump, thread_group, task_out, taskhighlight_out, check_ thread_line = ' ' + thread_line if not first: - task_out.write('Process: {0}, cpu: {1} pid: {2} start: 0x{3:x}\n'.format( - thread_task_name, task_cpu, thread_task_pid, next_thread_start)) + task_out.write('Process: {0}, [affinity: 0x{1:x}] cpu: {2} pid: {3} start: 0x{4:x}\n'.format( + thread_task_name, thread_task_affine, task_cpu, thread_task_pid, next_thread_start)) task_out.write( '=====================================================\n') first = 1 -- GitLab