~ionutbalutoiu/charms/trusty/neutron-api/next

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/hugepage.py

  • Committer: David Ames
  • Date: 2015-09-28 17:45:40 UTC
  • mfrom: (145 trunk)
  • mto: This revision was merged to the branch mainline in revision 146.
  • Revision ID: david.ames@canonical.com-20150928174540-wx0t0d3uwgmlsotb
PullĀ inĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    fstab_mount,
26
26
    mkdir,
27
27
)
 
28
from charmhelpers.core.strutils import bytes_from_string
 
29
from subprocess import check_output
28
30
 
29
31
 
30
32
def hugepage_support(user, group='hugetlb', nr_hugepages=256,
31
33
                     max_map_count=65536, mnt_point='/run/hugepages/kvm',
32
 
                     pagesize='2MB', mount=True):
 
34
                     pagesize='2MB', mount=True, set_shmmax=False):
33
35
    """Enable hugepages on system.
34
36
 
35
37
    Args:
49
51
        'vm.max_map_count': max_map_count,
50
52
        'vm.hugetlb_shm_group': gid,
51
53
    }
 
54
    if set_shmmax:
 
55
        shmmax_current = int(check_output(['sysctl', '-n', 'kernel.shmmax']))
 
56
        shmmax_minsize = bytes_from_string(pagesize) * nr_hugepages
 
57
        if shmmax_minsize > shmmax_current:
 
58
            sysctl_settings['kernel.shmmax'] = shmmax_minsize
52
59
    sysctl.create(yaml.dump(sysctl_settings), '/etc/sysctl.d/10-hugepage.conf')
53
60
    mkdir(mnt_point, owner='root', group='root', perms=0o755, force=False)
54
61
    lfstab = fstab.Fstab()