On 31/05/2016 04:37, Jianfeng Tan wrote: > EAL memory init allocates all free hugepages of the whole system, > which seen from sysfs, even when applications do not ask so many. > When there is a limitation on how many hugepages an application can > use (such as cgroup.hugetlb), or hugetlbfs is specified with an > option of size (exceeding the quota of the fs), it just fails to > start even there are enough hugepages allocated. > > To fix above issue, this patch: > - Changes the logic to continue memory init to see if hugetlb > requirement of application can be addressed by already allocated > hugepages. > - To make sure each hugepage is allocated successfully, we add a > recover mechanism, which relies on a mem access to fault-in > hugepages, and if it fails with SIGBUS, recover to previously > saved stack environment with siglongjmp(). > > For the case of CONFIG_RTE_EAL_SINGLE_FILE_SEGMENTS (enabled by > default when compiling IVSHMEM target), it's indispensable to > mapp all free hugepages in the system. Under this case, it fails > to start when allocating fails. > > Test example: > a. cgcreate -g hugetlb:/test-subgroup > b. cgset -r hugetlb.1GB.limit_in_bytes=2147483648 test-subgroup > c. cgexec -g hugetlb:test-subgroup \ > ./examples/helloworld/build/helloworld -c 0x2 -n 4 > > > Fixes: af75078fece ("first public release") > > Signed-off-by: Jianfeng Tan<jianfeng.tan at intel.com> > Acked-by: Neil Horman<nhorman at tuxdriver.com> > --- > v5: > - Make this method as default instead of using an option. > - When SIGBUS is triggered in the case of RTE_EAL_SINGLE_FILE_SEGMENTS, > just return error. > - Add prefix "huge_" to newly added function and static variables. > - Move the internal_config.memory assignment after the page allocations. > v4: > - Change map_all_hugepages to return unsigned instead of int. > v3: > - Reword commit message to include it fixes the hugetlbfs quota issue. > - setjmp -> sigsetjmp. > - Fix RTE_LOG complaint from ERR to DEBUG as it does not mean init error > so far. > - Fix the second map_all_hugepages's return value check. > v2: > - Address the compiling error by move setjmp into a wrap method. > > lib/librte_eal/linuxapp/eal/eal.c | 20 ----- > lib/librte_eal/linuxapp/eal/eal_memory.c | 138 > ++++++++++++++++++++++++++++--- > 2 files changed, 125 insertions(+), 33 deletions(-) >
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy at intel.com>