summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaryam Tahhan <maryam.tahhan@intel.com>2016-08-09 08:51:04 +0100
committerMaryam Tahhan <maryam.tahhan@intel.com>2016-08-09 08:03:34 +0000
commit5b0a5930281751842062c4b7f29de46c366b88f3 (patch)
treedd729f67da705906c81c47491e39b82b90d83eee
parent31f0a3e0a25e147e285d14e2e262ac48aa83ce65 (diff)
hugepages: change default num pages + deallocate
Change the default number of allocated pages to the min 10GB. Deallocate hugepages if we allocated them on the fly. Change-Id: If9946cec423dd095c1ca1ab3bee3698e2f025047 Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com>
-rw-r--r--conf/02_vswitch.conf4
-rw-r--r--tools/hugepages.py43
2 files changed, 32 insertions, 15 deletions
diff --git a/conf/02_vswitch.conf b/conf/02_vswitch.conf
index e5736138..81632d56 100644
--- a/conf/02_vswitch.conf
+++ b/conf/02_vswitch.conf
@@ -101,9 +101,9 @@ VSWITCH_BRIDGE_NAME = 'br0'
HUGEPAGE_DIR = '/dev/hugepages'
# If no hugepages are available, try to allocate HUGEPAGE_RAM_ALLOCATION.
-# Default is 2 x 1048576 = 2097152 kB.
+# Default is 10 GB.
# 10 GB (10485760 kB) or more is recommended for PVP & PVVP testing scenarios.
-HUGEPAGE_RAM_ALLOCATION = 2097152
+HUGEPAGE_RAM_ALLOCATION = 10485760
# Sets OVS PMDs core mask to 30 for affinitization to 5th and 6th CPU core.
# Note that the '0x' notation should not be used.
diff --git a/tools/hugepages.py b/tools/hugepages.py
index 02e4f29c..bba40122 100644
--- a/tools/hugepages.py
+++ b/tools/hugepages.py
@@ -26,7 +26,7 @@ from tools import tasks
from conf import settings
_LOGGER = logging.getLogger(__name__)
-
+_allocated_hugepages = False
#
# hugepage management
#
@@ -53,23 +53,39 @@ def allocate_hugepages():
"""Allocate hugepages on the fly
"""
hp_size = get_hugepage_size()
-
if hp_size > 0:
- nr_hp = int(math.ceil(settings.getValue('HUGEPAGE_RAM_ALLOCATION')/hp_size))
- _LOGGER.info('Will allocate %s hugepages.', nr_hp)
+ nr_hp = int(math.ceil(settings.getValue('HUGEPAGE_RAM_ALLOCATION')/hp_size))
+ _LOGGER.info('Will allocate %s hugepages.', nr_hp)
+
+ nr_hugepages = 'vm.nr_hugepages=' + str(nr_hp)
+ try:
+ tasks.run_task(['sudo', 'sysctl', nr_hugepages],
+ _LOGGER, 'Trying to allocate hugepages..', True)
+ except subprocess.CalledProcessError:
+ _LOGGER.error('Unable to allocate hugepages.')
+ return False
+ global _allocated_hugepages
+ _allocated_hugepages = True
+ return True
- nr_hugepages = 'vm.nr_hugepages=' + str(nr_hp)
+ else:
+ _LOGGER.error('Division by 0 will be supported in next release')
+ return False
+
+def deallocate_hugepages():
+ """De-allocate hugepages that were allocated on the fly
+ """
+ global _allocated_hugepages
+ if _allocated_hugepages:
+ nr_hugepages = 'vm.nr_hugepages= 0'
try:
tasks.run_task(['sudo', 'sysctl', nr_hugepages],
- _LOGGER, 'Trying to allocate hugepages..', True)
+ _LOGGER, 'Trying to de-allocate hugepages..', True)
except subprocess.CalledProcessError:
- _LOGGER.error('Unable to allocate hugepages.')
+ _LOGGER.error('Unable to de-allocate hugepages.')
return False
- return True
-
- else:
- _LOGGER.error('Division by 0 will be supported in next release')
- return False
+ _allocated_hugepages = False
+ return True
def get_free_hugepages(socket=None):
@@ -178,4 +194,5 @@ def umount_hugepages():
except subprocess.CalledProcessError:
_LOGGER.error('Unable to umount hugepages.')
-
+ if not deallocate_hugepages():
+ _LOGGER.error('Unable to deallocate previously allocated hugepages.')