Add MAX_ORDER constant
This commit is contained in:
parent
8ef28a0640
commit
beb00ce17e
@ -454,6 +454,22 @@ class BaseKernelConfig:
|
||||
@see: _gfp_create_reverse_lookup()
|
||||
"""
|
||||
|
||||
MAX_ORDER = -1
|
||||
"""
|
||||
The kernel memory allocator divides physically contiguous memory
|
||||
blocks into "zones", where each zone is a power of two number of
|
||||
pages. This option selects the largest power of two that the kernel
|
||||
keeps in the memory allocator.
|
||||
|
||||
This config option is actually maximum order plus one. For example,
|
||||
a value of 11 means that the largest free memory block is 2^10 pages.
|
||||
|
||||
The value will be calculated dynamically based on the numbers of
|
||||
orders in OOMAnalyser._extract_buddyinfo().
|
||||
|
||||
@see: OOMAnalyser._extract_buddyinfo().
|
||||
"""
|
||||
|
||||
pstable_items = [
|
||||
"pid",
|
||||
"uid",
|
||||
@ -3031,6 +3047,17 @@ class OOMAnalyser:
|
||||
size = size[:-2] # strip "kB"
|
||||
self.oom_result.details["_buddyinfo_pagesize_kb"] = int(size)
|
||||
|
||||
# MAX_ORDER is actually maximum order plus one. For example,
|
||||
# a value of 11 means that the largest free memory block is 2^10 pages.
|
||||
# __pragma__ ('jsiter')
|
||||
max_order = 0
|
||||
for o in self.oom_result.details["_buddyinfo"]["DMA"]:
|
||||
# JS: integer is sometimes a string :-/
|
||||
if (isinstance(o, str) and o.isdigit()) or isinstance(o, int):
|
||||
max_order += 1
|
||||
# __pragma__ ('nojsiter')
|
||||
self.oom_result.kconfig.MAX_ORDER = max_order
|
||||
|
||||
def _extract_watermarks(self):
|
||||
"""
|
||||
Extract memory watermark information from all zones
|
||||
|
6
test.py
6
test.py
@ -937,6 +937,12 @@ Hardware name: HP ProLiant DL385 G7, BIOS A18 12/08/2012
|
||||
'Wrong watermark level for node %s in zone "%s" (got: %d, expect %d)'
|
||||
% (node, zone, level, except_level),
|
||||
)
|
||||
self.assertEqual(
|
||||
analyser.oom_result.kconfig.MAX_ORDER,
|
||||
11, # This is a hard coded value as extracted from kernel 6.2.0
|
||||
"Unexpected number of chunk sizes (got: %s, expect: 11 (kernel 6.2.0))"
|
||||
% analyser.oom_result.kconfig.MAX_ORDER,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user