Skip to content
Snippets Groups Projects
Commit 38976141 authored by Kyle Yan's avatar Kyle Yan
Browse files

ldrp-v2: Add new method of finding number of CPUs as of kernel 4.5

As of commit c4c54dd1 (kernel/cpu.c: change type of cpu_possible_bits
and friends), cpu_present_bits no longer exists. Add new method of finding
number of cpus and also change other functions to use the get_num_cpus
API instead of defining it again.

Change-Id: I6d38d505ba7674b94e8481e6679226803eba977e
parent 1450db14
No related branches found
No related tags found
No related merge requests found
# Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -452,8 +452,7 @@ class DebugImage_v2(): ...@@ -452,8 +452,7 @@ class DebugImage_v2():
'msm_dump_table_ids', MAX_NUM_ENTRIES) 'msm_dump_table_ids', MAX_NUM_ENTRIES)
self.dump_data_id_lookup_table = ram_dump.gdbmi.get_enum_lookup_table( self.dump_data_id_lookup_table = ram_dump.gdbmi.get_enum_lookup_table(
'msm_dump_data_ids', MAX_NUM_ENTRIES) 'msm_dump_data_ids', MAX_NUM_ENTRIES)
cpu_present_bits = ram_dump.read_word('cpu_present_bits') cpus = ram_dump.get_num_cpus()
cpus = bin(cpu_present_bits).count('1')
# per cpu entries # per cpu entries
for i in range(1, cpus): for i in range(1, cpus):
......
# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -20,9 +20,7 @@ class IrqParse(RamParser): ...@@ -20,9 +20,7 @@ class IrqParse(RamParser):
print_out_str( print_out_str(
'=========================== IRQ STATE ===============================') '=========================== IRQ STATE ===============================')
per_cpu_offset_addr = ram_dump.address_of('__per_cpu_offset') per_cpu_offset_addr = ram_dump.address_of('__per_cpu_offset')
cpu_present_bits_addr = ram_dump.address_of('cpu_present_bits') cpus = ram_dump.get_num_cpus()
cpu_present_bits = ram_dump.read_word(cpu_present_bits_addr)
cpus = bin(cpu_present_bits).count('1')
irq_desc = ram_dump.address_of('irq_desc') irq_desc = ram_dump.address_of('irq_desc')
foo, irq_desc_size = ram_dump.unwind_lookup(irq_desc, 1) foo, irq_desc_size = ram_dump.unwind_lookup(irq_desc, 1)
h_irq_offset = ram_dump.field_offset('struct irq_desc', 'handle_irq') h_irq_offset = ram_dump.field_offset('struct irq_desc', 'handle_irq')
......
# Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -284,9 +284,7 @@ class Slabinfo(RamParser): ...@@ -284,9 +284,7 @@ class Slabinfo(RamParser):
def validate_slab_cache(self, slab_out, input_slabname, map_fn): def validate_slab_cache(self, slab_out, input_slabname, map_fn):
slab_name_found = False slab_name_found = False
original_slab = self.ramdump.address_of('slab_caches') original_slab = self.ramdump.address_of('slab_caches')
cpu_present_bits_addr = self.ramdump.address_of('cpu_present_bits') cpus = self.ramdump.get_num_cpus()
cpu_present_bits = self.ramdump.read_word(cpu_present_bits_addr)
cpus = bin(cpu_present_bits).count('1')
offsetof = struct_member_offset(self.ramdump) offsetof = struct_member_offset(self.ramdump)
self.initializeOffset() self.initializeOffset()
slab_list_offset = g_offsetof.kmemcache_list slab_list_offset = g_offsetof.kmemcache_list
......
# Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -58,9 +58,7 @@ class Slabinfo_summary(RamParser): ...@@ -58,9 +58,7 @@ class Slabinfo_summary(RamParser):
slab_summary = {} slab_summary = {}
nCounter = 0 nCounter = 0
original_slab = self.ramdump.address_of('slab_caches') original_slab = self.ramdump.address_of('slab_caches')
cpu_present_bits_addr = self.ramdump.address_of('cpu_present_bits') cpus = self.ramdump.get_num_cpus()
cpu_present_bits = self.ramdump.read_word(cpu_present_bits_addr)
cpus = bin(cpu_present_bits).count('1')
slab_list_offset = self.ramdump.field_offset( slab_list_offset = self.ramdump.field_offset(
'struct kmem_cache', 'list') 'struct kmem_cache', 'list')
slab_name_offset = self.ramdump.field_offset( slab_name_offset = self.ramdump.field_offset(
......
# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2015, 2017 The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -212,9 +212,7 @@ class Workqueues(RamParser): ...@@ -212,9 +212,7 @@ class Workqueues(RamParser):
worker_pool_size = ram_dump.sizeof('struct worker_pool') worker_pool_size = ram_dump.sizeof('struct worker_pool')
pending_work_offset = ram_dump.field_offset( pending_work_offset = ram_dump.field_offset(
'struct worker_pool', 'worklist') 'struct worker_pool', 'worklist')
cpu_present_bits_addr = ram_dump.address_of('cpu_present_bits') cpus = ram_dump.get_num_cpus()
cpu_present_bits = ram_dump.read_word(cpu_present_bits_addr)
cpus = bin(cpu_present_bits).count('1')
s = '<' s = '<'
for a in range(0, 64): for a in range(0, 64):
......
# Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. # Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and # it under the terms of the GNU General Public License version 2 and
...@@ -1399,8 +1399,14 @@ class RamDump(): ...@@ -1399,8 +1399,14 @@ class RamDump():
def get_num_cpus(self): def get_num_cpus(self):
"""Gets the number of CPUs in the system.""" """Gets the number of CPUs in the system."""
major, minor, patch = self.kernel_version
cpu_present_bits_addr = self.address_of('cpu_present_bits') cpu_present_bits_addr = self.address_of('cpu_present_bits')
cpu_present_bits = self.read_word(cpu_present_bits_addr) cpu_present_bits = self.read_word(cpu_present_bits_addr)
if (major, minor) >= (4, 5):
cpu_present_bits_addr = self.address_of('__cpu_present_mask')
bits_offset = self.field_offset('struct cpumask', 'bits')
cpu_present_bits = self.read_word(cpu_present_bits_addr + bits_offset)
return bin(cpu_present_bits).count('1') return bin(cpu_present_bits).count('1')
def iter_cpus(self): def iter_cpus(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment