@@ -0,0 +1,13 @@
+AUTHOR = 'aganti@google.com (Ashwin Ganti)'
+TIME = 'MEDIUM'
+NAME = 'libhugetlbfs test'
+TEST_TYPE = 'client'
+TEST_CLASS = 'Kernel'
+TEST_CATEGORY = 'Functional'
+
+DOC = '''
+Tests basic huge pages functionality when using libhugetlbfs. For more info
+about libhugetlbfs see http://libhugetlbfs.ozlabs.org/
+'''
+
+job.run_test('libhugetlbfs', dir='/mnt')
@@ -79,6 +79,9 @@ variants:
- bonnie:
test_name = bonnie
test_control_file = bonnie.control
+ - libhugetlbfs:
+ test_name = libhugetlbfs
+ test_control_file = libhugetlbfs.control
- linux_s3: install setup
type = linux_s3
@@ -546,6 +549,12 @@ variants:
only default
image_format = raw
+variants:
+ - @kvm_smallpages:
+ - kvm_hugepages:
+ pre_command = "/bin/bash scripts/hugepage.sh /mnt/hugepage"
+ extra_params += " -mem-path /mnt/hugepage"
+
variants:
- @basic:
@@ -559,6 +568,7 @@ variants:
only Fedora.8.32
only install setup boot shutdown
only rtl8139
+ only kvm_smallpages
- @sample1:
only qcow2
only ide
@@ -400,6 +400,13 @@ class VM:
self.destroy()
return False
+ if output:
+ logging.debug("qemu produced some output:\n%s", output)
+ if "alloc_mem_area" in output:
+ logging.error("Could not allocate hugepage memory"
+ " -- qemu command:\n%s", qemu_command)
+ return False
+
logging.debug("VM appears to be alive with PID %d", self.pid)
return True
@@ -0,0 +1,38 @@
+#!/bin/bash
+# Alocates enaugh hugepages for $1 memory and mount hugetlbfs to $2.
+if [ $# -ne 1 ]; then
+ echo "USAGE: $0 mem_path"
+ exit 1
+fi
+
+Hugepagesize=$(grep Hugepagesize /proc/meminfo | cut -d':' -f 2 | \
+ xargs | cut -d' ' -f1)
+VMS=$(expr $(echo $KVM_TEST_vms | grep -c ' ') + 1)
+if [ "$KVM_TEST_max_vms" ] && [ "$VMS" -lt "$KVM_TEST_max_vms" ]; then
+ VMS="$KVM_TEST_max_vms"
+fi
+VMSM=$(expr $(expr $VMS \* $KVM_TEST_mem) + $(expr $VMS \* 64 ))
+TARGET=$(expr $VMSM \* 1024 \/ $Hugepagesize)
+
+NR=$(cat /proc/sys/vm/nr_hugepages)
+while [ "$NR" -ne "$TARGET" ]; do
+ NR_="$NR";echo $TARGET > /proc/sys/vm/nr_hugepages
+ sleep 5s
+ NR=$(cat /proc/sys/vm/nr_hugepages)
+ if [ "$NR" -eq "$NR_" ] ; then
+ echo "Can not alocate $TARGET of hugepages"
+ exit 2
+ fi
+done
+
+if [ ! "$(mount | grep /mnt/hugepage |grep hugetlbfs)" ]; then
+ mkdir -p $1
+ mount -t hugetlbfs none $1 || \
+ (echo "Can not mount hugetlbfs filesystem to $1"; exit 3)
+else
+ echo "hugetlbfs filesystem already mounted"
+fi