From 685a72c4732f23fa5d049cc1c89805bb64a76ee4 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 19:20:17 +0000 Subject: Apply patch 0009-tests-Add-utility-to-check-if-huge-pages-are-giganti.patch patch_name: 0009-tests-Add-utility-to-check-if-huge-pages-are-giganti.patch present_in_specfile: true --- diff --git a/tests/hugetests.h b/tests/hugetests.h index e3179e6..bc4e16a 100644 --- a/tests/hugetests.h +++ b/tests/hugetests.h @@ -22,6 +22,7 @@ #include #include +#include #include "libhugetlbfs_privutils.h" #include "libhugetlbfs_testprobes.h" @@ -136,6 +137,24 @@ static inline long check_hugepagesize() return __hpage_size; } +static inline void check_if_gigantic_page(void) +{ + long page_size, hpage_size, max_order; + FILE *fp; + + page_size = sysconf(_SC_PAGESIZE); + hpage_size = gethugepagesize(); + fp = popen("cat /proc/pagetypeinfo | " + "awk '/Free pages count per migrate type at order/ " + "{print $NF}'", "r"); + if (!fp || fscanf(fp, "%lu", &max_order) < 0) + FAIL("Couldn't determine max page allocation order"); + + pclose(fp); + if (hpage_size > ((1 << max_order) * page_size)) + CONFIG("Gigantic pages are not supported"); +} + int using_system_hpage_size(const char *mount); /* WARNING: Racy -- use for test cases only! */