• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define PATH_OC_HPAGES "/proc/sys/vm/nr_overcommit_hugepages"
12 
13 #define MEMINFO_HPAGE_TOTAL  "HugePages_Total:"
14 #define MEMINFO_HPAGE_FREE   "HugePages_Free:"
15 #define MEMINFO_HPAGE_RSVD   "HugePages_Rsvd:"
16 #define MEMINFO_HPAGE_SURP   "HugePages_Surp:"
17 #define MEMINFO_HPAGE_SIZE   "Hugepagesize:"
18 
19 extern char *nr_opt; /* -s num   Set the number of the been allocated hugepages */
20 extern char *Hopt;   /* -H /..   Location of hugetlbfs, i.e.  -H /var/hugetlbfs */
21 
22 enum tst_hp_policy {
23 	TST_REQUEST,
24 	TST_NEEDS,
25 };
26 
27 struct tst_hugepage {
28 	const unsigned long number;
29 	enum  tst_hp_policy policy;
30 };
31 
32 /*
33  * Get the default hugepage size. Returns 0 if hugepages are not supported.
34  */
35 size_t tst_get_hugepage_size(void);
36 
37 /*
38  * Try the best to request a specified number of huge pages from system,
39  * it will store the reserved hpage number in tst_hugepages.
40  *
41  * Note: this depend on the status of system memory fragmentation.
42  */
43 unsigned long tst_reserve_hugepages(struct tst_hugepage *hp);
44 
45 /*
46  * This variable is used for recording the number of hugepages which system can
47  * provides. It will be equal to 'hpages' if tst_reserve_hugepages on success,
48  * otherwise set it to a number of hugepages that we were able to reserve.
49  *
50  * If system does not support hugetlb, then it will be set to 0.
51  */
52 extern unsigned long tst_hugepages;
53 
54 #endif /* TST_HUGEPAGE_H */
55