1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2019 Red Hat, Inc. 4 */ 5 6 #ifndef TST_HUGEPAGE__ 7 #define TST_HUGEPAGE__ 8 9 #define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/" 10 #define PATH_NR_HPAGES "/proc/sys/vm/nr_hugepages" 11 12 extern char *nr_opt; /* -s num Set the number of the been allocated hugepages */ 13 extern char *Hopt; /* -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs */ 14 15 /* 16 * Get the default hugepage size. Returns 0 if hugepages are not supported. 17 */ 18 size_t tst_get_hugepage_size(void); 19 20 /* 21 * Try the best to request a specified number of huge pages from system, 22 * it will store the reserved hpage number in tst_hugepages. 23 * 24 * Note: this depend on the status of system memory fragmentation. 25 */ 26 unsigned long tst_request_hugepages(unsigned long hpages); 27 28 /* 29 * This variable is used for recording the number of hugepages which system can 30 * provides. It will be equal to 'hpages' if tst_request_hugepages on success, 31 * otherwise set it to a number of hugepages that we were able to reserve. 32 * 33 * If system does not support hugetlb, then it will be set to 0. 34 */ 35 extern unsigned long tst_hugepages; 36 37 #endif /* TST_HUGEPAGE_H */ 38