1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2019 Li Wang <liwang@redhat.com> 4f08c3bdfSopenharmony_ci */ 5f08c3bdfSopenharmony_ci 6f08c3bdfSopenharmony_ci/* 7f08c3bdfSopenharmony_ci * Tests .hugepages + .save_restore 8f08c3bdfSopenharmony_ci */ 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci#include "tst_test.h" 11f08c3bdfSopenharmony_ci#include "tst_hugepage.h" 12f08c3bdfSopenharmony_ci#include "tst_sys_conf.h" 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_cistatic void do_test(void) { 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci unsigned long val, hpages; 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci tst_res(TINFO, "tst_hugepages = %lu", tst_hugepages); 19f08c3bdfSopenharmony_ci SAFE_FILE_PRINTF("/proc/sys/kernel/numa_balancing", "1"); 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_ci hpages = test.hugepages.number; 22f08c3bdfSopenharmony_ci SAFE_FILE_SCANF(PATH_NR_HPAGES, "%lu", &val); 23f08c3bdfSopenharmony_ci if (val != hpages) 24f08c3bdfSopenharmony_ci tst_brk(TBROK, "nr_hugepages = %lu, but expect %lu", val, hpages); 25f08c3bdfSopenharmony_ci else 26f08c3bdfSopenharmony_ci tst_res(TPASS, "test .hugepges"); 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ci struct tst_hugepage hp = { 1000000000000, TST_REQUEST }; 29f08c3bdfSopenharmony_ci hpages = tst_reserve_hugepages(&hp); 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci SAFE_FILE_SCANF(PATH_NR_HPAGES, "%lu", &val); 32f08c3bdfSopenharmony_ci if (val != hpages) 33f08c3bdfSopenharmony_ci tst_brk(TBROK, "nr_hugepages = %lu, but expect %lu", val, hpages); 34f08c3bdfSopenharmony_ci else 35f08c3bdfSopenharmony_ci tst_res(TPASS, "tst_reserve_hugepages"); 36f08c3bdfSopenharmony_ci} 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_cistatic struct tst_test test = { 39f08c3bdfSopenharmony_ci .test_all = do_test, 40f08c3bdfSopenharmony_ci .hugepages = {2, TST_NEEDS}, 41f08c3bdfSopenharmony_ci .save_restore = (const struct tst_path_val[]) { 42f08c3bdfSopenharmony_ci {"/proc/sys/kernel/numa_balancing", "0", TST_SR_TBROK}, 43f08c3bdfSopenharmony_ci {} 44f08c3bdfSopenharmony_ci }, 45f08c3bdfSopenharmony_ci}; 46