3 * Copyright (c) International Business Machines Corp., 2009
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * get_no_of_hugepages() --> Return No. of hugepages for this systems
24 * hugepages_size() --> Return Hugepages Size for this system
29 #include <sys/types.h>
34 int get_no_of_hugepages() {
39 f
= popen("grep 'HugePages_Total' /proc/meminfo | cut -d ':' -f2 | tr -d ' \n'", "r");
41 tst_resm(TBROK
, "Could not get info about Total_Hugepages from /proc/meminfo");
44 if (!fgets(buf
, 10, f
)) {
46 tst_resm(TBROK
, "Could not read Total_Hugepages from /proc/meminfo");
57 int hugepages_size() {
62 f
= popen("grep 'Hugepagesize' /proc/meminfo | cut -d ':' -f2 | tr -d 'kB \n'", "r");
64 tst_resm(TBROK
, "Could not get info about HugePages_Size from /proc/meminfo");
67 if (!fgets(buf
, 10, f
)) {
69 tst_resm(TBROK
, "Could not read HugePages_Size from /proc/meminfo");