Skip to content

Commit f2cc387

Browse files
sourcehawkclaude
andcommitted
fix(skills/bounding-heavy-commands): count page tables and vmalloc in the held memory of an older kernel
A kernel with a 'kernel' line in memory.stat counts page tables and vmalloc memory in it. On an older kernel the wrapper added the parts of kernel memory itself but left out pagetables, sec_pagetables, and vmalloc, so the same command reported less held memory there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f0e4791 commit f2cc387

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎skills/bounding-heavy-commands/scripts/bounded_run.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def cgroup_peak_mib(directory: str, names: Sequence[str] = ("memory.peak", "memo
847847
# The kernel cannot take back these pages at once to keep a cgroup under its limit: dirty and writeback file pages
848848
# must reach the disk first. An older kernel has no 'kernel' line, and there its parts stand in for it.
849849
HELD_FIELDS = ("anon", "shmem", "file_dirty", "file_writeback")
850-
KERNEL_PARTS = ("kernel_stack", "slab_unreclaimable", "sock", "percpu")
850+
KERNEL_PARTS = ("kernel_stack", "pagetables", "sec_pagetables", "slab_unreclaimable", "sock", "percpu", "vmalloc")
851851

852852

853853
def cgroup_held_mib(directory: str) -> Optional[int]:

‎skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,9 @@ def test_held_memory_is_what_the_kernel_cannot_take_back_at_once(self):
13301330

13311331
def test_held_memory_without_the_kernel_line_adds_the_parts_of_kernel_memory(self):
13321332
with tempfile.TemporaryDirectory() as directory:
1333-
self.write_stat(directory, anon=100, kernel_stack=1, slab_unreclaimable=2, sock=3, percpu=4, pagetables=50, slab_reclaimable=60)
1334-
self.assertEqual(bounded_run.cgroup_held_mib(directory), 110)
1333+
self.write_stat(directory, anon=100, kernel_stack=1, slab_unreclaimable=2, sock=3, percpu=4, pagetables=50,
1334+
sec_pagetables=6, vmalloc=7, slab_reclaimable=60)
1335+
self.assertEqual(bounded_run.cgroup_held_mib(directory), 173)
13351336

13361337
def test_held_memory_counts_only_the_lines_that_exist(self):
13371338
with tempfile.TemporaryDirectory() as directory:

0 commit comments

Comments
 (0)