Adjust vm.max_map_count for OVSDPDK

OVSDPDK allocates all available hugepages on start to "Setting up
physically contiguous memory". This requires vm.max_map_count
adjustment.

Depends-On: Ibfbfa5bd37d74f9618299af39336acb33a18cf69
Change-Id: I4ea48e4ac2a5fe46855999aaa5b6e2e1a2b360ff
Implements: blueprint support-dpdk
This commit is contained in:
Vladimir Eremin 2016-03-15 20:20:24 +03:00
parent 691a2c3de5
commit 4e25add8d3
No known key found for this signature in database
GPG Key ID: 2E97FC2056F3E83F
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,36 @@
module Puppet::Parser::Functions
newfunction(:max_map_count_hugepages,
:type => :rvalue,
:arity => 1,
:doc => <<-'ENDOFDOC'
@desc Calculate vm.max_map_count from hugepages data
@params hugepages's array
[
{ 'count' => 512, 'numa_id' => 0, 'size' => 2048 },
{ 'count' => 8, 'numa_id' => 1, 'size' => 1048576 }
]
@return mapped hash of sysfs opts
66570
@example max_map_count_hugepages(hiera('hugepages'))
ENDOFDOC
) do |args|
hugepages_config = args.flatten
sum = 65530
hugepages_config.each do |hpg|
raise(
Puppet::ParseError,
"max_map_count_hugepages(): expected a hash with 'count' key, got #{hpg}"
) unless hpg.is_a? Hash and hpg['count']
sum += hpg['count']*2
end
sum
end
end

View File

@ -10,3 +10,8 @@ sysfs_config_value { 'hugepages':
value => map_sysfs_hugepages($hugepages),
sysfs => '/sys/devices/system/node/node*/hugepages/hugepages-*kB/nr_hugepages',
}
# LP 1507921
sysctl::value { 'vm.max_map_count':
value => max_map_count_hugepages($hugepages),
}

View File

@ -0,0 +1,26 @@
require 'spec_helper'
describe 'max_map_count_hugepages' do
let :input_data do
[
{ 'count' => 512, 'numa_id' => 0, 'size' => 2048 },
{ 'count' => 8, 'numa_id' => 1, 'size' => 1048576 }
]
end
let :output do
66570
end
it { is_expected.not_to eq(nil) }
it { is_expected.to run.with_params().and_raise_error(ArgumentError, /Wrong number of arguments given/) }
it { is_expected.to run.with_params('string').and_raise_error(Puppet::ParseError, /expected a hash with/) }
it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /expected a hash with/) }
it { is_expected.to run.with_params([{'numa_id' => 0}]).and_raise_error(Puppet::ParseError, /expected a hash with/) }
it { is_expected.to run.with_params(input_data).and_return(output) }
it { is_expected.to run.with_params([]).and_return(65530) }
end

View File

@ -10,6 +10,7 @@ describe manifest do
'node1/hugepages/hugepages-1048576kB' => 8,
'default' => 0
}
max_map_count = hugepages.empty? ? '65530' : '66570'
it "should allocate defined hugepages" do
should contain_class('sysfs')
@ -19,6 +20,7 @@ describe manifest do
'value' => mapped_sysfs_hugepages,
'sysfs' => '/sys/devices/system/node/node*/hugepages/hugepages-*kB/nr_hugepages',
)
should contain_sysctl__value('vm.max_map_count').with_value(max_map_count)
end
end
test_ubuntu_and_centos manifest