pandora-scripts: add a script for hugetlb allocation
authorGrazvydas Ignotas <notasas@gmail.com>
Fri, 24 Aug 2012 21:45:36 +0000 (00:45 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 24 Aug 2012 21:45:36 +0000 (00:45 +0300)
recipes/pandora-system/pandora-scripts.bb
recipes/pandora-system/pandora-scripts/op_hugetlb.sh [new file with mode: 0755]
recipes/pandora-system/pandora-sudoers.bb
recipes/pandora-system/pandora-sudoers/50_openpandora

index 92a2258..4802b2c 100644 (file)
@@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "omap3-pandora"
 DEPENDS = "zenity dbus"
 RDEPENDS = "zenity dbus"
 
 DEPENDS = "zenity dbus"
 RDEPENDS = "zenity dbus"
 
-PR = "r111"
+PR = "r112"
 
 SRC_URI = " \
           file://op_paths.sh \
 
 SRC_URI = " \
           file://op_paths.sh \
@@ -84,6 +84,7 @@ SRC_URI = " \
          file://op_bright_up.sh \  
          file://op_menu.sh \ 
          file://op_xfcemenu.sh \
          file://op_bright_up.sh \  
          file://op_menu.sh \ 
          file://op_xfcemenu.sh \
+         file://op_hugetlb.sh \
 "
 
 do_install() {
 "
 
 do_install() {
@@ -117,6 +118,7 @@ do_install() {
          install -m 0755 ${WORKDIR}/op_bright_up.sh ${D}${prefix}/pandora/scripts/  
          install -m 0755 ${WORKDIR}/op_menu.sh ${D}${prefix}/pandora/scripts/ 
          install -m 0755 ${WORKDIR}/op_xfcemenu.sh ${D}${prefix}/pandora/scripts/ 
          install -m 0755 ${WORKDIR}/op_bright_up.sh ${D}${prefix}/pandora/scripts/  
          install -m 0755 ${WORKDIR}/op_menu.sh ${D}${prefix}/pandora/scripts/ 
          install -m 0755 ${WORKDIR}/op_xfcemenu.sh ${D}${prefix}/pandora/scripts/ 
+         install -m 0755 ${WORKDIR}/op_hugetlb.sh ${D}${prefix}/pandora/scripts/
          install -m 0755 ${WORKDIR}/reset_nubs.sh ${D}${prefix}/pandora/scripts/ 
          install -m 0644 ${WORKDIR}/pndlogo.png ${D}${prefix}/pandora/scripts/ 
          install -m 0755 ${WORKDIR}/ConfigModel.py ${D}${prefix}/pandora/scripts/
          install -m 0755 ${WORKDIR}/reset_nubs.sh ${D}${prefix}/pandora/scripts/ 
          install -m 0644 ${WORKDIR}/pndlogo.png ${D}${prefix}/pandora/scripts/ 
          install -m 0755 ${WORKDIR}/ConfigModel.py ${D}${prefix}/pandora/scripts/
diff --git a/recipes/pandora-system/pandora-scripts/op_hugetlb.sh b/recipes/pandora-system/pandora-scripts/op_hugetlb.sh
new file mode 100755 (executable)
index 0000000..a9f9ea5
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+if [ "$#" -ne "1" ]; then
+       echo "usage: $0 <megabytes>"
+       exit 1
+fi
+
+if ! [ -e /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages ]; then
+       echo "hugetlb error: no hugetlb support in kernel"
+       exit 1
+fi
+
+pages_needed=$(( ($1 + 1) / 2 ))
+
+# find amount of pages reserved or in use
+pages_nr=`cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages`
+pages_free=`cat /sys/kernel/mm/hugepages/hugepages-2048kB/free_hugepages`
+pages_resv=`cat /sys/kernel/mm/hugepages/hugepages-2048kB/resv_hugepages`
+
+pages_inuse_before=$(($pages_nr - $pages_free + $pages_resv))
+pages_inuse_after=$(($pages_inuse_before + $pages_needed))
+
+for a in `seq 5`; do
+       echo $pages_inuse_after > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
+       sleep .2
+       pages_nr=`cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages`
+
+       if [ "$pages_nr" = "$pages_inuse_after" ]; then
+               break
+       fi
+done
+
+if [ "$pages_nr" != "$pages_inuse_after" ]; then
+       echo "hugetlb error: could not alloc $pages_inuse_after pages (got $pages_nr)"
+else
+       echo "hugetlb: $pages_nr pages allocated."
+fi
index 1a009e9..61a5c05 100644 (file)
@@ -5,7 +5,7 @@ COMPATIBLE_MACHINE = "omap3-pandora"
 
 RDEPENDS = "sudo"
 
 
 RDEPENDS = "sudo"
 
-PR = "r17"
+PR = "r18"
 
 SRC_URI = " \
           file://50_openpandora \
 
 SRC_URI = " \
           file://50_openpandora \
index b37a5fc..1e572b5 100755 (executable)
@@ -30,3 +30,4 @@
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_bluetooth_work.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/pnd_run.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_touchinit.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_bluetooth_work.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/pnd_run.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_touchinit.sh
+%wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_hugetlb.sh