Skip to content

Commit

Permalink
move_pages12: compacting memory before each test loop
Browse files Browse the repository at this point in the history
These simple steps are added to prepare the system's memory state
for the test, aiming to increase the test's reliability and
consistency by starting from a clean and defragmented memory state.

To reduce accidental failures on small (1.5G) RAM system:

  7 tst_test.c:1558: TINFO: Timeout per run is 0h 21m 00s
  8 move_pages12.c:273: TINFO: Free RAM 1542656 kB
  9 move_pages12.c:289: TINFO: Increasing 16384kB hugepages pool on node 0 to 4
  10 move_pages12.c:299: TINFO: Increasing 16384kB hugepages pool on node 1 to 4
  11 move_pages12.c:216: TINFO: Allocating and freeing 4 hugepages on node 0
  12 move_pages12.c:216: TINFO: Allocating and freeing 4 hugepages on node 1
  13 move_pages12.c:207: TPASS: Bug not reproduced
  14 move_pages12.c:106: TFAIL: madvise failed: ENOMEM (12)
  ...<repeats 741 times>...
  756 move_pages12.c:207: TPASS: Bug not reproduced

Note:
  This is a single hugetlb test without invoking the hugetlb-lib of LTP,
  so we add the compacting memory/cache steps additionally.

Signed-off-by: Li Wang <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
  • Loading branch information
wangli5665 committed Feb 22, 2024
1 parent 631b5ac commit e97f419
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions testcases/kernel/syscalls/move_pages/move_pages12.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ static void do_test(unsigned int n)
pid_t cpid = -1;
int status;

SAFE_FILE_PRINTF("/proc/sys/vm/compact_memory", "1");

addr = SAFE_MMAP(NULL, tcases[n].tpages * hpsz, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);

Expand Down Expand Up @@ -269,6 +271,7 @@ static void setup(void)
pgsz = (int)get_page_size();
SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "Hugepagesize: %d", &hpsz);

SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "MemFree: %ld", &memfree);
tst_res(TINFO, "Free RAM %ld kB", memfree);

Expand Down

0 comments on commit e97f419

Please sign in to comment.