diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2015-10-30 10:26:49 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2015-10-31 22:04:13 +0000 |
commit | a29879587ad084ecfbdaa82319d790e73cb01b2c (patch) | |
tree | 7c03c6dd267f068111cbf7a86d1ca9c035c94ad5 /debian/patches | |
parent | a748a69c46d315da2e5852ec7db5e795ce2ce1b6 (diff) |
selftests: vm: Try harder to allocate huge pages
Diffstat (limited to 'debian/patches')
-rw-r--r-- | debian/patches/bugfix/all/selftests-vm-try-harder-to-allocate-huge-pages.patch | 40 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/debian/patches/bugfix/all/selftests-vm-try-harder-to-allocate-huge-pages.patch b/debian/patches/bugfix/all/selftests-vm-try-harder-to-allocate-huge-pages.patch new file mode 100644 index 000000000..e5a9d9648 --- /dev/null +++ b/debian/patches/bugfix/all/selftests-vm-try-harder-to-allocate-huge-pages.patch @@ -0,0 +1,40 @@ +From: Ben Hutchings <ben@decadent.org.uk> +Date: Sat, 31 Oct 2015 17:56:11 +0000 +Subject: selftests: vm: Try harder to allocate huge pages + +If we need to increase the number of huge pages, drop caches first +to reduce fragmentation and then check that we actually allocated +as many as we wanted. Retry once if that doesn't work. + +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- +--- a/tools/testing/selftests/vm/run_vmtests ++++ b/tools/testing/selftests/vm/run_vmtests +@@ -20,13 +20,26 @@ done < /proc/meminfo + if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then + nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` + needpgs=`expr $needmem / $pgsize` +- if [ $freepgs -lt $needpgs ]; then ++ tries=2 ++ while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do + lackpgs=$(( $needpgs - $freepgs )) ++ echo 3 > /proc/sys/vm/drop_caches + echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages + if [ $? -ne 0 ]; then + echo "Please run this test as root" + exit 1 + fi ++ while read name size unit; do ++ if [ "$name" = "HugePages_Free:" ]; then ++ freepgs=$size ++ fi ++ done < /proc/meminfo ++ tries=$((tries - 1)) ++ done ++ if [ $freepgs -lt $needpgs ]; then ++ printf "Not enough huge pages available (%d < %d)\n" \ ++ $freepgs $needpgs ++ exit 1 + fi + else + echo "no hugetlbfs support in kernel?" diff --git a/debian/patches/series b/debian/patches/series index 5f18c078b..3bb6d83bb 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -86,3 +86,4 @@ bugfix/all/selftests-add-missing-include-directives.patch bugfix/all/selftests-memfd-stop-unnecessary-rebuilds.patch bugfix/all/selftests-kprobe-choose-an-always-defined-function-t.patch bugfix/all/selftests-make-scripts-executable.patch +bugfix/all/selftests-vm-try-harder-to-allocate-huge-pages.patch |