Skip to content

Commit

Permalink
Fixing pvalloc memleak test
Browse files Browse the repository at this point in the history
Request to allocate 30K bytes using pvalloc(), results
in allocating 3*64Kb(on 64Kb pagesize system). The assertion
expects leak to be 30Kb, whereas leaked memory is much more
due to pvalloc's implementation for power.

Signed-off-by: Abhishek Dubey <[email protected]>
  • Loading branch information
Abhishek Dubey committed Nov 14, 2023
1 parent ec981a5 commit c2d9adf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/python/test_tools_memleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest import main, skipUnless, TestCase
from utils import kernel_version_ge
import os
import platform
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -102,7 +103,13 @@ def test_memalign(self):
self.assertEqual(cfg.leaking_amount, self.run_leaker("memalign"))

def test_pvalloc(self):
self.assertEqual(cfg.leaking_amount, self.run_leaker("pvalloc"))
# pvalloc's implementation for power invokes mmap(), which adjusts the
# allocated size to meet pvalloc's constraints. Actual leaked memory
# could be more than requested, hence assertLessEqual.
if platform.machine() == 'ppc64le':
self.assertLessEqual(cfg.leaking_amount, self.run_leaker("pvalloc"))
else:
self.assertEqual(cfg.leaking_amount, self.run_leaker("pvalloc"))

def test_aligned_alloc(self):
self.assertEqual(cfg.leaking_amount, self.run_leaker("aligned_alloc"))
Expand Down

0 comments on commit c2d9adf

Please sign in to comment.