diff --git a/OOMAnalyser.py b/OOMAnalyser.py index f2d6809..71134d5 100644 --- a/OOMAnalyser.py +++ b/OOMAnalyser.py @@ -2700,7 +2700,7 @@ class OOMAnalyser: """RE to match the OOM line with kernel version""" REC_FREE_MEMORY_CHUNKS = re.compile( - "Node (?P\d+) (?PDMA|DMA32|Normal): (?P.*) = \d+kB" + "Node (?P\d+) (?PDMA|DMA32|Normal): (?P.*) = (?P\d+)kB" ) """RE to extract free memory chunks in a zone""" @@ -2938,7 +2938,8 @@ class OOMAnalyser: mm/page_alloc.c:show_migration_types(). This function fills: - * OOMResult.details["_buddyinfo"] with [][][] = + * OOMResult.details["_buddyinfo"] with [][][] = + * OOMResult.details["_buddyinfo"] with [zone]["total_free_kb_per_node"][node] = int(total_free_kb_per_node) * OOMResult.details["_buddyinfo_pagesize_kb"] with the extracted page size """ self.oom_result.details["_buddyinfo"] = {} @@ -2961,23 +2962,29 @@ class OOMAnalyser: if zone not in buddy_info: buddy_info[zone] = {} - zone_details = buddy_info[zone] + + if "total_free_kb_per_node" not in buddy_info[zone]: + buddy_info[zone]["total_free_kb_per_node"] = {} + buddy_info[zone]["total_free_kb_per_node"][node] = int( + int(match.group("total_free_kb_per_node")) + ) order = -1 # to start with 0 after the first increment in for loop for element in match.group("zone_usage").split(" "): if element.startswith("("): # skip migration types continue order += 1 - if order not in zone_details: - zone_details[order] = {} - order_details = zone_details[order] + if order not in buddy_info[zone]: + buddy_info[zone][order] = {} count = element.split("*")[0] count.strip() - order_details[node] = int(count) - if "_total" not in order_details: - order_details["_total"] = 0 - order_details["_total"] += order_details[node] + buddy_info[zone][order][node] = int(count) + if "free_chunks_total" not in buddy_info[zone][order]: + buddy_info[zone][order]["free_chunks_total"] = 0 + buddy_info[zone][order]["free_chunks_total"] += buddy_info[zone][order][ + node + ] if not self.oom_result.details["_buddyinfo_pagesize_kb"] and order == 0: size = element.split("*")[1] diff --git a/test.py b/test.py index a183b30..dcea9ca 100755 --- a/test.py +++ b/test.py @@ -871,28 +871,28 @@ Hardware name: HP ProLiant DL385 G7, BIOS A18 12/08/2012 for zone, order, node, except_count in [ ("Normal", 6, 0, 0), # order 6 - page size 256kB ("Normal", 6, 1, 2), # order 6 - page size 256kB - ("Normal", 6, "_total", 0 + 2), # order 6 - page size 256kB + ("Normal", 6, "free_chunks_total", 0 + 2), # order 6 - page size 256kB ("Normal", 0, 0, 1231), # order 0 - page size 4kB ("Normal", 0, 1, 2245), # order 0 - page size 4kB - ("Normal", 0, "_total", 1231 + 2245), # order 0 - page size 4kB + ("Normal", 0, "free_chunks_total", 1231 + 2245), # order 0 - page size 4kB ("DMA", 5, 0, 1), # order 5 - page size 128kB - ("DMA", 5, "_total", 1), # order 5 - page size 128kB + ("DMA", 5, "free_chunks_total", 1), # order 5 - page size 128kB ("DMA32", 4, 0, 157), # order 4 - page size 64k - ("DMA32", 4, "_total", 157), # order 4 - page size 64k + ("DMA32", 4, "free_chunks_total", 157), # order 4 - page size 64k + ("Normal", "total_free_kb_per_node", 0, 38260), + ("Normal", "total_free_kb_per_node", 1, 50836), ]: self.assertTrue( zone in buddyinfo, "Missing details for zone %s in buddy info" % zone ) - zone_info = buddyinfo[zone] self.assertTrue( - order in zone_info, - 'Missing details for order "%d" in buddy info' % order, + order in buddyinfo[zone], + 'Missing details for order "%s" in buddy info' % order, ) - order_info = zone_info[order] - count = order_info[node] + count = buddyinfo[zone][order][node] self.assertTrue( count == except_count, - 'Wrong chunk count for order %d in zone "%s" for node "%s" (got: %d, expect %d)' + 'Wrong chunk count for order %s in zone "%s" for node "%s" (got: %d, expect %d)' % (order, zone, node, count, except_count), )